| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# DataObject.cpp

Go to the documentation of this file.

    00001 // $Id: DataObject.cpp,v 1.11 2008/11/13 15:30:27 marcocle Exp $
    00002
    00003 // Experiment specific include files
    00004 #include "GaudiKernel/StreamBuffer.h"
    00005 #include "GaudiKernel/LinkManager.h"
    00006 #include "GaudiKernel/DataObject.h"
    00007 #include "GaudiKernel/IInspector.h"
    00008 #include "GaudiKernel/IRegistry.h"
    00009 #include <vector>
    00010 #include <memory>
    00011
    00012 static std::string _sDataObjectCppNotRegistered("NotRegistered");
    00013
    00015 DataObject::DataObject()
    00016  : m_refCount(0),
    00017    m_version(0),
    00018    m_pRegistry(0)
    00019 {
    00020   m_pLinkMgr = LinkManager::newInstance();
    00021 }
    00022
    00024 DataObject::DataObject(const DataObject&)
    00025  : m_refCount(0),
    00026    m_version(0),
    00027    m_pRegistry(0)
    00028 {
    00029   m_pLinkMgr = LinkManager::newInstance();
    00030 }
    00031
    00033 DataObject::~DataObject()   {
    00034   // Issue a warning if the object is being deleted and the reference
    00035   // count is non-zero.
    00036   if ( m_refCount > 0 ) {
    00037     // Insert warning here
    00038   }
    00039   if ( m_pLinkMgr ) delete m_pLinkMgr;
    00040   m_pLinkMgr = 0;
    00041 }
    00042
    00044 unsigned long DataObject::release()  {
    00045   unsigned long cnt = --m_refCount;
    00046   if ( 0 == m_refCount )   {
    00047     delete this;
    00048   }
    00049   return cnt;
    00050 }
    00051
    00053 unsigned long DataObject::addRef()  {
    00054   return ++m_refCount;
    00055 }
    00056
    00058 const CLID& DataObject::clID() const   {
    00059   return CLID_DataObject;
    00060 }
    00061
    00063 const CLID& DataObject::classID()    {
    00064   return CLID_DataObject;
    00065 }
    00066
    00068 const std::string& DataObject::name() const {
    00069   if( m_pRegistry != 0) {
    00070     return m_pRegistry->name();
    00071   }
    00072   else {
    00073     return _sDataObjectCppNotRegistered;
    00074   }
    00075 }
    00076
    00078 StatusCode DataObject::update() {
    00079   return StatusCode::SUCCESS;
    00080 }
    00081
    00082 static DataObject*       s_objPtr = 0;
    00083 static DataObject**      s_currObj = &s_objPtr;
    00084
    00085 static std::vector<DataObject**>& objectStack() {
    00086   static std::auto_ptr<std::vector<DataObject**> > s_current;
    00087   if ( 0 == s_current.get() )  {
    00088     s_current = std::auto_ptr<std::vector<DataObject**> >(new std::vector<DataObject**>());
    00089   }
    00090   return *(s_current.get());
    00091 }
    00092
    00093 DataObject* Gaudi::getCurrentDataObject() {
    00094   return *s_currObj;
    00095 }
    00096
    00097 void Gaudi::pushCurrentDataObject(DataObject** pobjAddr) {
    00098   static std::vector<DataObject**>& c = objectStack();
    00099   c.push_back(pobjAddr);
    00100   s_currObj = pobjAddr ? pobjAddr : &s_objPtr;
    00101 }
    00102
    00103
    00104 void Gaudi::popCurrentDataObject() {
    00105   static std::vector<DataObject**>& c = objectStack();
    00106   switch(c.size())  {
    00107   case 0:
    00108     s_currObj = c.back();
    00109     c.pop_back();
    00110     break;
    00111   default:
    00112     s_currObj = &s_objPtr;
    00113     break;
    00114   }
    00115 }

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines