Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v36r11 (bdb84f5f)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DataObject.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 // Experiment specific include files
12 #include "GaudiKernel/DataObject.h"
13 #include "GaudiKernel/IInspector.h"
14 #include "GaudiKernel/IRegistry.h"
17 #include <memory>
18 #include <vector>
19 
20 static std::string _sDataObjectCppNotRegistered( "NotRegistered" );
21 
24 
27  : m_version{ rhs.m_version }, m_pLinkMgr{ LinkManager::newInstance() } {}
28 
31  m_version = rhs.m_version;
33  return *this;
34 }
35 
38  : m_version{ std::move( rhs.m_version ) }, m_pLinkMgr{ std::move( rhs.m_pLinkMgr ) } {}
39 
42  m_version = std::move( rhs.m_version );
43  m_pLinkMgr = std::move( rhs.m_pLinkMgr );
44  return *this;
45 }
46 
49  // Issue a warning if the object is being deleted and the reference
50  // count is non-zero.
51  if ( m_refCount > 0 ) {
52  // Insert warning here
53  }
54 }
55 
57 unsigned long DataObject::release() {
58  unsigned long cnt = --m_refCount;
59  if ( 0 == cnt ) delete this;
60  return cnt;
61 }
62 
64 unsigned long DataObject::addRef() { return ++m_refCount; }
65 
67 const CLID& DataObject::clID() const { return CLID_DataObject; }
68 
70 const CLID& DataObject::classID() { return CLID_DataObject; }
71 
73 const std::string& DataObject::name() const { return m_pRegistry ? m_pRegistry->name() : _sDataObjectCppNotRegistered; }
74 
77 
78 static DataObject* s_objPtr = nullptr;
79 static DataObject** s_currObj = &s_objPtr;
80 
81 static std::vector<DataObject**>& objectStack() {
83  return *s_current;
84 }
85 
86 DataObject* Gaudi::getCurrentDataObject() { return *s_currObj; }
87 
88 void Gaudi::pushCurrentDataObject( DataObject** pobjAddr ) {
89  static std::vector<DataObject**>& c = objectStack();
90  c.push_back( pobjAddr );
91  s_currObj = pobjAddr ? pobjAddr : &s_objPtr;
92 }
93 
95  static std::vector<DataObject**>& c = objectStack();
96  if ( !c.empty() ) {
97  s_currObj = c.back();
98  c.pop_back();
99  } else {
100  s_currObj = &s_objPtr;
101  }
102 }
DataObject::name
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:73
std::string
STL class.
std::move
T move(T... args)
DataObject::m_refCount
unsigned long m_refCount
Reference count.
Definition: DataObject.h:43
DataObject::m_pLinkMgr
std::unique_ptr< LinkManager > m_pLinkMgr
Store of symbolic links.
Definition: DataObject.h:49
std::vector
STL class.
DataObject::release
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:57
DataObject::m_version
unsigned char m_version
Version number.
Definition: DataObject.h:45
Gaudi::popCurrentDataObject
GAUDI_API void popCurrentDataObject()
DataObject::~DataObject
virtual ~DataObject()
Standard Destructor.
Definition: DataObject.cpp:48
gaudirun.c
c
Definition: gaudirun.py:525
DataObject::m_pRegistry
IRegistry * m_pRegistry
Pointer to the Registry Object.
Definition: DataObject.h:47
DataObject::operator=
DataObject & operator=(const DataObject &rhs)
Assignment Operator.
Definition: DataObject.cpp:30
StreamBuffer.h
Gaudi::getCurrentDataObject
GAUDI_API DataObject * getCurrentDataObject()
std::unique_ptr::reset
T reset(T... args)
IRegistry::name
virtual const name_type & name() const =0
Name of the directory (or key)
StatusCode
Definition: StatusCode.h:65
DataObject::update
virtual StatusCode update()
Provide empty placeholder for internal object reconfiguration callback.
Definition: DataObject.cpp:76
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
IRegistry.h
Gaudi::pushCurrentDataObject
GAUDI_API void pushCurrentDataObject(DataObject **pobjAddr)
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
DataObject.h
DataObject
Definition: DataObject.h:40
DataObject::DataObject
DataObject()
Standard Constructor.
Definition: DataObject.cpp:23
IInspector.h
DataObject::classID
static const CLID & classID()
Retrieve reference to class definition structure (static access)
Definition: DataObject.cpp:70
DataObject::clID
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:67
std::unique_ptr
STL class.
DataObject::addRef
virtual unsigned long addRef()
Add reference to object.
Definition: DataObject.cpp:64