#ifndef HEPOBJ_H #define HEPOBJ_H // ---------------------------------------------------------------------- // // HepObj.h - class declaring the very basic properties of Hep objects // // HepObj provides very basic methods for obtaining very basic // information (e.g., name, title, id#, directory) about a Hep object. // HepObj objects will be instantiated only as part of more // comprehensive Hep objects. // // The classes derived from this one are intended to cooperate with a // a manager class, a derivative of HepFileManager. // // // History: // ??-???-19?? Bob Jacobsen Initial draft, based on ideas in // HepTuple and the SLT histogram classes of Joe Boudreau // 05-May-1997 Walter Brown Initial design & draft of Hist class // 22-May-1997 Walter Brown Merged Hist into HepHist // 30-May-1997 Walter Brown Added cloning functions // 29-May-1997 Jason Luther Added comments // 04-Jun-1997 Jason Luther Reconciled comments to match design // 27-Jun-1997 Walter Brown Replaced HepString by standard string // 28-Jul-1997 Walter Brown Factored out from HepHist.h & HepNtuple.h; // added mayDelete() for convenience // 31-Mar-1998 Philippe Canal Add isCreated to avoid writing an object // before its actual creation. // 30-Jul-1998 Philippe Canal Added typeId // 17-Nov-1998 Philippe Canal Start using HepID // // ---------------------------------------------------------------------- #ifndef ZMENVIRONMENT_H #include "ZMutility/ZMenvironment.h" #endif #include "HepTuple/HepID.h" class HepFileManager; class HepDir; ZM_BEGIN_NAMESPACE( zmht ) /* namespace zmht { */ class HepObj { friend class HepFileManager; friend class HepRootFileManager; friend class HepDir; protected: HepObj( // constructor HepFileManager * mgr , const std::string& title , const int id = 0 ); HepObj( // constructor HepFileManager * mgr , const std::string& title , const std::string& stringId ); HepObj( // constructor HepFileManager * mgr , const std::string& title , const std::string& stringId , const int id ); public: virtual ~HepObj(); // destructor virtual void release(); // conclude user's use of object void operator delete( void * me ); // control time of freeing HepFileManager * manager() const; // retrieve object's file manager std::string title() const; // retrieve object's title const HepID& id() const; // retrieve object's identification std::string dir() const; // retrieve object's directory bool isValid() const; // if false the object in Not usable char type() const; // retrieve object type identification // Make copy of the current object virtual HepObj & makeClone( const std::string& title, const int id = 0 ) const; virtual HepObj & makeClone( HepFileManager *manager, const std::string& title, const int id = 0 ) const; virtual HepObj & makeEmpty( const std::string& title, const int id = 0 ) const; virtual HepObj & makeEmpty( HepFileManager *manager, const std::string& title, const int id = 0 ) const; protected: HepFileManager * mgr_; // pointer to desired manager std::string * title_; // object's title HepID * id_; // optional unique object ident std::string * dir_; // object's directory char type_; // object type identification mutable bool userHas_; // is object in use by user? mutable bool dirty_; // has object been updated by user? mutable bool isValid_; // Nothing will be done if this is false mutable bool created_; // has the object been created in the manager? void isNowUnmanaged(); // make manager inaccessible void isValid ( // set the validity flag bool newStatus ); bool isInUse() const; // get user access status void isInUse( // set user access status bool newStatus ); bool isDirty() const; // get update status void isDirty( // set update status bool newStatus ); bool isCreated() const; // get creation status void isCreated( // set creation status bool newStatus ); bool mayUse() const; // is it safe to make use of this object? bool mayDelete() const; // is it safe to delete() this object? // Used for dummy construction ... // the object is then not valid ... HepObj( ); // default constructor private: // forbidden operations, hence private HepObj( const HepObj & ); // copy constructor HepObj & operator=( const HepObj & );// assignment }; // HepObj ZM_END_NAMESPACE( zmht ) /* } // namespace zmht */ #include "HepTuple/HepObj.icc" #endif // HEPOBJ_H