//----------------------------------------------------------------------------- // // File and Version Information: // $Id: BdbConfigObject.ddl,v 1.7 1998/01/29 11:11:08 yury Exp $ // // Description: // Class BdbConfigObject. This is the base class for objects in the // configuration database. Derives from BdbObject, and in addition to // the time (which for configuration database mean time of creation), // contains a 32-bit Dataflow key. // The key is unique for a given database container and is assigned // in BdbConfigDatabase::store(). Hence, the constructors set the key // to the default value (0). // // Environment: // Software developed for the BaBar Detector at the SLAC B-Factory. // // Author List: // Yury Kolomensky // // Copyright Information: // Copyright (C) 1997 Caltech // //----------------------------------------------------------------------------- #ifndef BDBCONFIGOBJECT_HH #define BDBCONFIGOBJECT_HH #include "BaBar/BaBar.hh" //--------------------------------------------------------- // Macro for creating am object in a temporary container -- //--------------------------------------------------------- #define BdbConfigNew(DB) new(DB->getScratchContH()) //---------------------- // Base Class Headers -- //---------------------- #include "BdbCond/BdbObject.hh" //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "BdbConfig/BdbConfigKey.hh" #include "BdbConfig/BdbConfigInfo.hh" //------------------------------------ // Collaborating Class Declarations -- //------------------------------------ class BdbAbsIndex; class BdbConfigContObj; class ostream; // --------------------- // -- Class Interface -- // --------------------- class BdbConfigObject : public BdbObject { //-------------------- // Instance Members -- //-------------------- public: // Constructors BdbConfigObject( const char* theDescription = 0 ); BdbConfigObject( const BdbConfigObject& ); // Destructor virtual ~BdbConfigObject( ); // operators // Selectors virtual const char* getMyClassName( ) const = 0; const BdbConfigKey& getConfigKey ( ) const; // accessor to creation info const BdbConfigInfo& getInfo() const; // copy method is needed for composite objects since ooRefHandle::copy // does only shallow copy. // this method has to be provided by sub-classes. virtual BdbStatus copy(const BdbHandle(BdbConfigContObj)& containerH, BdbHandle(BdbConfigObject)& newObjectH) = 0; // this method is for convenience if you have cycles to spare on // passing objects by value BdbRef(BdbConfigObject) copy(const BdbHandle(BdbConfigContObj)& containerH); // // the following method need to be overridden if // the objects are to be indexed // // returns non-zero owned pointer if the object is to be indexed // See BdbAbsIndex.hh virtual BdbAbsIndex* getIndex() const {return 0;} // print method virtual void print(ostream& os) const; protected: // Helper methods // This method can be used by copy() IFF the object contains no references // or associations BdbStatus shallow_copy(const BdbHandle(BdbConfigContObj)& containerH, BdbHandle(BdbConfigObject)& newObjectH); private: // Data members BdbConfigKey _key; BdbConfigInfo _info; //modifiers void setConfigKey(const BdbConfigKey& theKey); // friends friend class BdbConfigContObj; // allowed to set the key //disallowed BdbConfigObject& operator = (const BdbConfigObject& ); }; #endif