Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CdbOrigin.hh

Go to the documentation of this file.
00001 #ifndef CDB_ORIGIN_HH
00002 #define CDB_ORIGIN_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbOrigin.hh,v 1.3 2003/08/13 23:34:13 gapon Exp $
00006 
00007 #include "BdbTime/BdbTime.hh"
00008 
00009 #include "CdbBase/CdbCPtrBase.hh"
00010 #include "CdbBase/CdbOriginPtrFwd.hh"
00011 #include "CdbBase/CdbDatabasePtrFwd.hh"
00012 
00013 #include "CdbBase/CdbItr.hh"
00014 
00015 #include <string>
00016 
00017 class CdbProperty;
00018 
00019 /// The transient interface to an origin object.
00020 /**
00021   * More details to come...
00022   */
00023 class CdbOrigin {
00024 
00025 friend class CdbCPtrBase< CdbOrigin >;  // Who destroys me
00026 
00027 private:
00028 
00029   /// The constructor (NOT IMPLEMENTED)
00030   /**
00031     * Is disabled...
00032     */
00033     CdbOrigin( );
00034 
00035   /// The copy constructor (NOT IMPLEMENTED)
00036   /**
00037     * Is disabled...
00038     */
00039     CdbOrigin( const CdbOrigin& theOrigin );
00040 
00041   /// The assignment operator (NOT IMPLEMENTED)
00042   /**
00043     * Is disabled...
00044     */
00045     CdbOrigin& operator=( const CdbOrigin& theOrigin );
00046 
00047 protected:
00048 
00049   /// The normal constructor.
00050   /**
00051     * Initialize context with specified parameters.
00052     *
00053     * @see CdbDatabase
00054     * @see CdbDatabasePtr
00055     */
00056     CdbOrigin( const CdbDatabasePtr& theDatabasePtr,    /**< the smart pointer providing a back back link to the parent database object */
00057                const char*           theName,           /**< the name of the origin */
00058                unsigned short        theId              /**< the identifier of the origin */
00059              );
00060 
00061   /// The destructor.
00062   /**
00063     * More details...
00064     */
00065     virtual ~CdbOrigin( );
00066 
00067 public:
00068 
00069   /// The static locator for an origin object (by name)
00070   /**
00071     * This locator uses the name of the origin to resolve the right
00072     * instance of the origin object in the scope of a database.
00073     *
00074     * The database itself as well as the top-level API object are two
00075     * optional parameters of this method. If either (or both) of them are
00076     * not specified then the corresponding default values will be used.
00077     *
00078     * @see CdbOrigin
00079     * @see CdbOriginPtr
00080     *
00081     * @return the completion status of the operation
00082     */
00083     static CdbStatus instance( CdbOriginPtr& theOriginPtr,
00084                                const char*   theOriginName,
00085                                const char*   theDatabaseName       = 0,     /**< the database name */
00086                                const char*   theImplementationName = 0,     /**< the implementation name */
00087                                const char*   theTechnologyName     = 0      /**< the technology name */
00088                              );
00089 
00090   /// The static locator for an origin object (by id)
00091   /**
00092     * This locator is similar to teh one defined above. It just uses an identifier
00093     * instead of a name.
00094     */
00095     static CdbStatus instance( CdbOriginPtr&  theOriginPtr,
00096                                unsigned short theOriginId,
00097                                const char*    theDatabaseName       = 0,    /**< the database name */
00098                                const char*    theImplementationName = 0,    /**< the implementation name */
00099                                const char*    theTechnologyName     = 0     /**< the technology name */
00100                              );
00101 
00102 public:
00103 
00104   /// Return a smart pointer to the parent database object.
00105   /**
00106     * @see CdbDatabase
00107     * @see CdbDatabasePtr
00108     */
00109     const CdbDatabasePtr& parent( ) const;
00110 
00111   /// The name of an object
00112   /**
00113     * @return a non-0 pointer onto a string owned by the object.
00114     */
00115     const char* name( ) const;
00116 
00117   /// Obtain the creation time of the origin
00118   /**
00119     * This method is supposed to be implemented by the corresponding subclass.
00120     *
00121     * @return a string with the object's description
00122     */
00123     virtual BdbTime created( ) = 0;
00124 
00125   /// Obtain the origin description
00126   /**
00127     * This method is supposed to be implemented by the corresponding subclass.
00128     *
00129     * @return a string with the object's description
00130     */
00131     virtual std::string description( ) = 0;
00132 
00133   /// The identifier of an object
00134   /**
00135     * @return a value of the identifier.
00136     */
00137     unsigned short id( ) const;
00138 
00139   /// Check if this origin is the local one
00140   /**
00141     * The "local" origin is the one corresponding to the part of a distributed database setup
00142     * currently being used by a client application. This database also can be called the "local" one.
00143     * Depending on the origin's type "local" databases (=origins) may have persistent resources
00144     * modifiable by clients' applications. The actual set on those resources depends on
00145     * the origin's type.
00146     *
00147     * This method is supposed to be implementyed by subclasses.
00148     *
00149     * @return TRUE if this is the "local" origin
00150     */
00151     virtual bool isLocal( ) const = 0;
00152 
00153   /// Check if data corresponding to this origin are available in the local database
00154   /**
00155     * The positive answer means that the data from remote database have already been brought
00156     * into local database.
00157     *
00158     * This method is supposed to be implementyed by subclasses.
00159     *
00160     * @return TRUE if this is the "local" origin
00161     */
00162     virtual bool isInstantiated( ) const = 0;
00163 
00164   /// Check if this origin is the "master" one
00165   /**
00166     * The "master" origin is meant to describe the central database of a distributed database setup.
00167     * Certain database operations can only be performed in this central "master" database.
00168     *
00169     * This method is supposed to be implemented by subclasses.
00170     *
00171     * @return TRUE if this is the "master" origin
00172     */
00173     virtual bool isMaster( ) const = 0;
00174 
00175   /// Check if this origin is a "slave" one
00176   /**
00177     * The "slave" origin is meant to describe a database being a part of a distributed database setup.
00178     * The database of the "slave" origin is allowed to contribute data into the distrubuted
00179     * database so that these data can be seen and used by clients of other databases of the setup.
00180     * The "slave" origin is known to its central "master" database. The "master" may delegate certain
00181     * operations to its "slave"-s.
00182     *
00183     * This method is supposed to be implemented by subclasses.
00184     *
00185     * @return TRUE if this is the "slave" origin
00186     */
00187     virtual bool isSlave( ) const = 0;
00188 
00189   /// Check if this origin is a "test" one
00190   /**
00191     * The "test" origin is meant to describe a database NOT being a part of a distributed database setup.
00192     * The database of the "test" origin is NOT allowed to contribute data into the distrubuted
00193     * database in a way it's done by "slave" databases. However the "test" type databases are allowed
00194     * to produce their own local data to be consumed locally. It's allso allowed to import data from
00195     * the corresponding distributed database.
00196     *
00197     * This method is supposed to be implemented by subclasses.
00198     *
00199     * @return TRUE if this is the "test" origin
00200     */
00201     virtual bool isTest( ) const = 0;
00202 
00203   /// Set up an iterator of properties
00204   /**
00205     * Specific implementations of this origin class my supply technology- and 
00206     * implementation- specific properties.
00207     *
00208     * This method is supposed to be implemented by subclasses.
00209     *
00210     * @see CdbProperty
00211     *
00212     * @return CdbStatus::Success if the iterator is set up
00213     */
00214     virtual CdbStatus propertyIterator( CdbItr<CdbProperty>& theItr /**< the iterator to set up */
00215                                       ) = 0;
00216 
00217 private:
00218 
00219     CdbDatabasePtr _myParent;
00220     std::string    _myName;
00221     unsigned short _myId;
00222 };
00223 
00224 #endif  // CDB_ORIGIN_HH

Generated on Mon Dec 5 18:22:08 2005 for CDB by doxygen1.3-rc3