00001 #ifndef DYBKERNEL_OBJECTREG_H
00002 #define DYBKERNEL_OBJECTREG_H 1
00003
00004
00005 #include "GaudiKernel/DataObject.h"
00006 #include "GaudiKernel/IRegistry.h"
00007 #include "GaudiKernel/boost_allocator.h"
00008 #include <string>
00009 #include <ostream>
00010
00020 class ObjectReg
00021 {
00022 public:
00023
00025 ObjectReg(IRegistry* registry,
00026 DataObject* object,
00027 bool store);
00028
00030 ObjectReg(const ObjectReg& rhs);
00031
00033 ObjectReg() : m_registry(0),
00034 m_object(0),
00035 m_store(false) {}
00036
00038 virtual ~ObjectReg();
00039
00041 virtual std::ostream& fillStream(std::ostream& s) const;
00042
00044 const std::string& path() const;
00045
00047 const IRegistry* registry() const;
00048
00051 const DataObject* object() const;
00052
00054 DataObject* object();
00055
00058 bool store() const;
00059
00062 void setStore(bool value);
00063
00066 int entry() const;
00067 void setEntry(int entry);
00068
00069 ObjectReg& operator=(const ObjectReg& rhs);
00070
00071 #ifndef _WIN32
00073 static void* operator new ( size_t size )
00074 {
00075 return ( sizeof(ObjectReg) == size ?
00076 boost::singleton_pool<ObjectReg, sizeof(ObjectReg)>::malloc() :
00077 ::operator new(size) );
00078 }
00079
00083 static void* operator new ( size_t size, void* pObj )
00084 {
00085 return ::operator new (size,pObj);
00086 }
00087
00089 static void operator delete ( void* p )
00090 {
00091 boost::singleton_pool<ObjectReg, sizeof(ObjectReg)>::is_from(p) ?
00092 boost::singleton_pool<ObjectReg, sizeof(ObjectReg)>::free(p) :
00093 ::operator delete(p);
00094 }
00095
00098 static void operator delete ( void* p, void* pObj )
00099 {
00100 ::operator delete (p, pObj);
00101 }
00102 #endif
00103 protected:
00104
00105 private:
00107 void setRegistry(IRegistry* registry);
00108
00110 void setObject(DataObject* value);
00111
00112 IRegistry* m_registry;
00113 DataObject* m_object;
00114 bool m_store;
00115 mutable int m_entry;
00116
00117 };
00118
00119 inline std::ostream& operator<< (std::ostream& str, const ObjectReg& obj)
00120 {
00121 return obj.fillStream(str);
00122 }
00123
00124
00125
00126
00127
00128
00129
00130 inline std::ostream& ObjectReg::fillStream(std::ostream& s) const
00131 {
00132 char l_store = (m_store) ? 'T' : 'F';
00133 s << "{ " << "registry : " << m_registry << std::endl
00134 << "object : " << m_object << std::endl
00135 << "store : " << l_store << std::endl << " }";
00136 return s;
00137 }
00138
00139 #endif