Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/ObjectID_8h_source.html
Дата изменения: Unknown
Дата индексирования: Mon Feb 14 20:06:48 2011
Кодировка:

Поисковые слова: clouds
casacore: casa/System/ObjectID.h Source File

ObjectID.h

Go to the documentation of this file.
00001 //# ObjectID.h: A unique identifier for distributed and other objects
00002 //# Copyright (C) 1996,1998,1999,2000,2001,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: ObjectID.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 
00029 #ifndef CASA_OBJECTID_H
00030 #define CASA_OBJECTID_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/BasicSL/String.h>
00035 #include <casa/iosfwd.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 //# Forward declarations
00040 template<class T> class Block;
00041 
00042 // <summary> 
00043 // ObjectID:  A unique identifier for distributed and other objects.
00044 // </summary>
00045 
00046 // <use visibility=export>
00047 
00048 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tObjectID.cc" demos="">
00049 
00050 // <prerequisite>
00051 //   <li> none
00052 // </prerequisite>
00053 //
00054 // <etymology>
00055 // The ObjectID class name reflects its role as the single identifier for 
00056 // distributed and other user-level objects.
00057 // </etymology>
00058 //
00059 // <synopsis> 
00060 // The ObjectID class is used to give a unique identifier to ``high-level''
00061 // objects in the system. Internally the ObjectID consists of a sequence number
00062 // (unique within the creating process), a process id, a creation time, and a
00063 // host id. Pragmatically the ObjectID should be unique with no dangers of
00064 // collisions.
00065 //
00066 // A special ``Null'' ObjectID is available. 
00067 // </synopsis> 
00068 //
00069 // <motivation>
00070 // The fundamental purpose for an ObjectID is to provide a unique identifier
00071 // for persistent objects, or for objects that might be accessed outside the
00072 // creating processes address space.
00073 // </motivation>
00074 //
00075 // <todo asof="1997/09/23">
00076 //   <li> Nothing (hostid -> hostname on this date).
00077 // </todo>
00078 
00079 class ObjectID
00080 {
00081 public:
00082     // If <src>makeNull</src> is True, make the null ObjectID, otherwise create
00083     // a unique ObjectID.
00084     ObjectID(Bool makeNull = False);
00085     // Create explicitly from the provided constituents.
00086     ObjectID(Int sequence, Int pid, Int time, const String &hostname);
00087 
00088     // Copy <src>other</src>. Note that if the ObjectID is embedded inside an
00089     // object, the enclosing object probably does not want to copy the ObjectID
00090     // since generally speaking the identity of the enclosing object should be
00091     // immutable.
00092     // <group>
00093     ObjectID(const ObjectID &other);
00094     ObjectID &operator=(const ObjectID &other);
00095     // </group>
00096     
00097     // Is this ObjectID set?
00098     Bool isNull() const;
00099 
00100     // Compare two ObjectID's for (in)equality.
00101     // <group>
00102     Bool operator==(const ObjectID &other) const;
00103     Bool operator!=(const ObjectID &other) const;
00104     // </group>
00105 
00106     // It is useful to interconvert between strings and ObjecID's, e.g. when
00107     // saving to FITS or writing to a table. The form of the string is:
00108     // <srcblock>
00109     // sequence=123 host=hostname pid=pid time=time
00110     // </srcblock>
00111     // with an optional comma between the fields.
00112     // However, in general user code should not depend on the exact form of
00113     // the string.
00114     // <group>
00115     // If this fails, an error message is set and the ObjectID is the null
00116     // ObjectID.
00117     Bool fromString(String &error, const String &in);
00118     // Note that <src>out</src> is zero'd before it is set.
00119     void toString(String &out) const;
00120     // </group>
00121 
00122     // Ordinarily the user does not need to get at the exact state of the,
00123     // ObjectID, however it is available for those times when it is necessary.
00124     // <group>
00125     Int sequence() const;
00126     Int pid() const;
00127     Int creationTime() const;
00128     const String &hostName() const;
00129     // </group>
00130 
00131     // Extract objectID strings (as set by glish script substitute.g) from
00132     // a command, convert them to ObjectID objects, store those in the
00133     // Block, and replace the strings by their Block indices as
00134     // <src>$OBJ#n#O</src> where n is the index.
00135     static String extractIDs (Block<ObjectID>& objectIDs,
00136                               const String& command);
00137 
00138 private:
00139     Int sequence_number_p;
00140     Int process_id_p;
00141     Int creation_time_p;
00142     String hostname_p;
00143 
00144     // Make a unique sequence number, returns 0 on first call, 1 on next, ...
00145     static Int sequence_number();
00146 };
00147 
00148 uInt hashFunc(const ObjectID &);
00149 
00150 ostream &operator<<(ostream &os, const ObjectID &id);
00151 
00152 //# Inlines
00153 
00154 inline Int ObjectID::sequence() const 
00155 {
00156     return sequence_number_p;
00157 }
00158 
00159 inline Int ObjectID::pid() const 
00160 {
00161     return process_id_p;
00162 }
00163 
00164 inline Int ObjectID::creationTime() const
00165 {
00166     return creation_time_p;
00167 }
00168 
00169 inline const String &ObjectID::hostName() const
00170 {
00171     return hostname_p;
00172 }
00173 
00174 
00175 } //# NAMESPACE CASA - END
00176 
00177 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines