MinimalDataObjectHandle Class Reference

#include </tmp/marcocle/lhcb-release/1122/GAUDI/GAUDI_v27r0/InstallArea/x86_64-slc6-gcc49-opt/include/GaudiKernel/MinimalDataObjectHandle.h>

Inheritance diagram for MinimalDataObjectHandle:
Collaboration diagram for MinimalDataObjectHandle:

Public Types

enum  AccessType {
  READ, WRITE, UPDATE, READ,
  WRITE, UPDATE
}
 The type of the access. More...
 
enum  AccessType {
  READ, WRITE, UPDATE, READ,
  WRITE, UPDATE
}
 The type of the access. More...
 

Public Member Functions

 MinimalDataObjectHandle ()
 
 MinimalDataObjectHandle (DataObjectDescriptor &descriptor)
 Constructor initialises the members and registers products in SchedSvc the MinimalDataObjectHandle takes over the ownership of the descriptor. More...
 
virtual ~MinimalDataObjectHandle ()
 
virtual StatusCode initialize ()
 Initialize. More...
 
virtual StatusCode finalize ()
 Finalize. More...
 
virtual StatusCode reinitialize ()
 Reinitialize -> may be overwritten in derived class. More...
 
bool isOptional () const
 Check if the data object declared is optional for the algorithm. More...
 
void setOptional (bool optional=true)
 
size_t dataProductIndex () const
 Return the product index. More...
 
const std::string & dataProductName () const
 Return the product name. More...
 
const std::vector< std::string > & alternativeDataProductNames () const
 
StatusCode setDataProductName (const std::string &address)
 Update address of data product if possible -> not if was written. More...
 
StatusCode setAlternativeDataProductNames (const std::vector< std::string > &alternativeAddresses)
 
StatusCode setDataProductNames (const std::vector< std::string > &addresses)
 
AccessType accessType () const
 Access type. More...
 
bool wasRead () const
 Check if operation was performed. More...
 
bool wasWritten () const
 Check if operation was performed. More...
 
bool isValid () const
 
bool initialized () const
 
void lock ()
 
void unlock ()
 
 MinimalDataObjectHandle ()
 
 MinimalDataObjectHandle (DataObjectDescriptor &descriptor)
 Constructor initialises the members and registers products in SchedSvc the MinimalDataObjectHandle takes over the ownership of the descriptor. More...
 
virtual ~MinimalDataObjectHandle ()
 
virtual StatusCode initialize ()
 Initialize. More...
 
virtual StatusCode finalize ()
 Finalize. More...
 
virtual StatusCode reinitialize ()
 Reinitialize -> may be overwritten in derived class. More...
 
bool isOptional () const
 Check if the data object declared is optional for the algorithm. More...
 
void setOptional (bool optional=true)
 
size_t dataProductIndex () const
 Return the product index. More...
 
const std::string & dataProductName () const
 Return the product name. More...
 
const std::vector< std::string > & alternativeDataProductNames () const
 
StatusCode setDataProductName (const std::string &address)
 Update address of data product if possible -> not if was written. More...
 
StatusCode setAlternativeDataProductNames (const std::vector< std::string > &alternativeAddresses)
 
StatusCode setDataProductNames (const std::vector< std::string > &addresses)
 
AccessType accessType () const
 Access type. More...
 
bool wasRead () const
 Check if operation was performed. More...
 
bool wasWritten () const
 Check if operation was performed. More...
 
bool isValid () const
 
bool initialized () const
 
void lock ()
 
void unlock ()
 

Protected Member Functions

void setRead (bool wasRead=true)
 
void setWritten (bool wasWritten=true)
 
DataObjectDescriptordescriptor ()
 
void setRead (bool wasRead=true)
 
void setWritten (bool wasWritten=true)
 
DataObjectDescriptordescriptor ()
 

Protected Attributes

DataObjectDescriptorm_descriptor
 

Private Member Functions

size_t updateDataProductIndex ()
 
 MinimalDataObjectHandle (const MinimalDataObjectHandle &)
 
MinimalDataObjectHandleoperator= (const MinimalDataObjectHandle &)
 
size_t updateDataProductIndex ()
 
 MinimalDataObjectHandle (const MinimalDataObjectHandle &)
 
MinimalDataObjectHandleoperator= (const MinimalDataObjectHandle &)
 

Private Attributes

unsigned int m_dataProductIndex
 
bool m_wasRead
 
bool m_wasWritten
 
bool m_initialized
 

Static Private Attributes

static std::unordered_map< std::string, size_t > m_dataProductIndexMap
 
static std::map< size_t, std::map< size_t, tbb::spin_mutex > > m_locks
 
static const uint CLEANUP_THRESHOLD = 20
 

Friends

class Algorithm
 
class AlgTool
 
class DataObjectDescriptorCollection
 

Detailed Description

Definition at line 21 of file MinimalDataObjectHandle.h.

Member Enumeration Documentation

The type of the access.

Enumerator
READ 

Read only access to the data object.

WRITE 

Data object is produced.

UPDATE 

Update of data object is allowed.

READ 

Read only access to the data object.

WRITE 

Data object is produced.

UPDATE 

Update of data object is allowed.

Definition at line 26 of file MinimalDataObjectHandle.h.

26  {
28  READ,
30  WRITE,
32  UPDATE
33  };
Read only access to the data object.
Update of data object is allowed.

The type of the access.

Enumerator
READ 

Read only access to the data object.

WRITE 

Data object is produced.

UPDATE 

Update of data object is allowed.

READ 

Read only access to the data object.

WRITE 

Data object is produced.

UPDATE 

Update of data object is allowed.

Definition at line 26 of file MinimalDataObjectHandle.h.

26  {
28  READ,
30  WRITE,
32  UPDATE
33  };
Read only access to the data object.
Update of data object is allowed.

Constructor & Destructor Documentation

MinimalDataObjectHandle::MinimalDataObjectHandle ( )
MinimalDataObjectHandle::MinimalDataObjectHandle ( DataObjectDescriptor descriptor)

Constructor initialises the members and registers products in SchedSvc the MinimalDataObjectHandle takes over the ownership of the descriptor.

Definition at line 17 of file MinimalDataObjectHandle.cpp.

MinimalDataObjectHandle::~MinimalDataObjectHandle ( )
virtual

Definition at line 25 of file MinimalDataObjectHandle.cpp.

25  {
26  delete m_descriptor;
27 }
DataObjectDescriptor * m_descriptor
MinimalDataObjectHandle::MinimalDataObjectHandle ( const MinimalDataObjectHandle )
private
MinimalDataObjectHandle::MinimalDataObjectHandle ( )
MinimalDataObjectHandle::MinimalDataObjectHandle ( DataObjectDescriptor descriptor)

Constructor initialises the members and registers products in SchedSvc the MinimalDataObjectHandle takes over the ownership of the descriptor.

virtual MinimalDataObjectHandle::~MinimalDataObjectHandle ( )
virtual
MinimalDataObjectHandle::MinimalDataObjectHandle ( const MinimalDataObjectHandle )
private

Member Function Documentation

auto MinimalDataObjectHandle::accessType ( ) const

Access type.

Definition at line 117 of file MinimalDataObjectHandle.cpp.

117  {
118  return m_descriptor->accessType();
119 }
MinimalDataObjectHandle::AccessType accessType() const
DataObjectDescriptor * m_descriptor
AccessType MinimalDataObjectHandle::accessType ( ) const

Access type.

const std::vector< std::string > & MinimalDataObjectHandle::alternativeDataProductNames ( ) const

Definition at line 75 of file MinimalDataObjectHandle.cpp.

75  {
77 }
DataObjectDescriptor * m_descriptor
const std::vector< std::string > & alternativeAddresses() const
const std::vector<std::string>& MinimalDataObjectHandle::alternativeDataProductNames ( ) const
size_t MinimalDataObjectHandle::dataProductIndex ( ) const

Return the product index.

Definition at line 65 of file MinimalDataObjectHandle.cpp.

65  {
66  return m_dataProductIndex;
67 }
size_t MinimalDataObjectHandle::dataProductIndex ( ) const

Return the product index.

const std::string & MinimalDataObjectHandle::dataProductName ( ) const

Return the product name.

Definition at line 71 of file MinimalDataObjectHandle.cpp.

71  {
72  return m_descriptor->address();
73 }
const std::string & address() const
DataObjectDescriptor * m_descriptor
const std::string& MinimalDataObjectHandle::dataProductName ( ) const

Return the product name.

DataObjectDescriptor * MinimalDataObjectHandle::descriptor ( )
protected

Definition at line 149 of file MinimalDataObjectHandle.cpp.

149 {return m_descriptor;}
DataObjectDescriptor * m_descriptor
DataObjectDescriptor* MinimalDataObjectHandle::descriptor ( )
protected
virtual StatusCode MinimalDataObjectHandle::finalize ( )
virtual
StatusCode MinimalDataObjectHandle::finalize ( )
virtual
StatusCode MinimalDataObjectHandle::initialize ( )
virtual

Initialize.

Reimplemented in DataObjectHandle< T >, DataObjectHandle< T >, DataObjectHandle< DataObject >, and DataObjectHandle< DataObject >.

Definition at line 31 of file MinimalDataObjectHandle.cpp.

31  {
32  setRead(false);
33  setWritten(false);
34 
35  m_initialized = true;
36  return StatusCode::SUCCESS;
37 }
void setRead(bool wasRead=true)
void setWritten(bool wasWritten=true)
virtual StatusCode MinimalDataObjectHandle::initialize ( )
virtual
bool MinimalDataObjectHandle::initialized ( ) const
inline

Definition at line 86 of file MinimalDataObjectHandle.h.

bool MinimalDataObjectHandle::initialized ( ) const
inline

Definition at line 86 of file MinimalDataObjectHandle.h.

bool MinimalDataObjectHandle::isOptional ( ) const

Check if the data object declared is optional for the algorithm.

Definition at line 55 of file MinimalDataObjectHandle.cpp.

55  {
56  return m_descriptor->optional();
57 }
DataObjectDescriptor * m_descriptor
bool MinimalDataObjectHandle::isOptional ( ) const

Check if the data object declared is optional for the algorithm.

bool MinimalDataObjectHandle::isValid ( ) const
bool MinimalDataObjectHandle::isValid ( ) const

Definition at line 129 of file MinimalDataObjectHandle.cpp.

129  {
130  return m_descriptor->valid();
131 }
DataObjectDescriptor * m_descriptor
void MinimalDataObjectHandle::lock ( )

Definition at line 178 of file MinimalDataObjectHandle.cpp.

178  {
180 }
static std::map< size_t, std::map< size_t, tbb::spin_mutex > > m_locks
GAUDI_API ContextIdType currentContextId()
Return the current context id.
size_t dataProductIndex() const
Return the product index.
void MinimalDataObjectHandle::lock ( )
MinimalDataObjectHandle& MinimalDataObjectHandle::operator= ( const MinimalDataObjectHandle )
private
MinimalDataObjectHandle& MinimalDataObjectHandle::operator= ( const MinimalDataObjectHandle )
private
StatusCode MinimalDataObjectHandle::reinitialize ( )
virtual

Reinitialize -> may be overwritten in derived class.

Reimplemented in DataObjectHandle< T >, DataObjectHandle< T >, DataObjectHandle< DataObject >, and DataObjectHandle< DataObject >.

Definition at line 41 of file MinimalDataObjectHandle.cpp.

41  {
42  setRead(false);
43  setWritten(false);
44  return StatusCode::SUCCESS;
45 }
void setRead(bool wasRead=true)
void setWritten(bool wasWritten=true)
virtual StatusCode MinimalDataObjectHandle::reinitialize ( )
virtual

Reinitialize -> may be overwritten in derived class.

Reimplemented in DataObjectHandle< T >, DataObjectHandle< T >, DataObjectHandle< DataObject >, and DataObjectHandle< DataObject >.

StatusCode MinimalDataObjectHandle::setAlternativeDataProductNames ( const std::vector< std::string > &  alternativeAddresses)
StatusCode MinimalDataObjectHandle::setAlternativeDataProductNames ( const std::vector< std::string > &  alternativeAddresses)

Definition at line 91 of file MinimalDataObjectHandle.cpp.

91  {
92  //only allowed if not initialized yet
93  if(m_initialized)
94  return StatusCode::FAILURE;
95 
96  m_descriptor->setAltAddresses(alternativeAddresses);
97 
99 
100  return StatusCode::SUCCESS;
101 }
void setAltAddresses(const std::vector< std::string > &addresses)
DataObjectDescriptor * m_descriptor
StatusCode MinimalDataObjectHandle::setDataProductName ( const std::string &  address)

Update address of data product if possible -> not if was written.

StatusCode MinimalDataObjectHandle::setDataProductName ( const std::string &  address)

Update address of data product if possible -> not if was written.

Definition at line 79 of file MinimalDataObjectHandle.cpp.

79  {
80  //only allowed if not initialized yet
81  if(m_initialized)
82  return StatusCode::FAILURE;
83 
84  m_descriptor->setAddress(address);
85 
87 
88  return StatusCode::SUCCESS;
89 }
void setAddress(const std::string &address)
DataObjectDescriptor * m_descriptor
StatusCode MinimalDataObjectHandle::setDataProductNames ( const std::vector< std::string > &  addresses)

Definition at line 103 of file MinimalDataObjectHandle.cpp.

103  {
104  //only allowed if not initialized yet
105  if(m_initialized)
106  return StatusCode::FAILURE;
107 
108  m_descriptor->setAddresses(addresses);
109 
111 
112  return StatusCode::SUCCESS;
113 }
void setAddresses(const std::vector< std::string > &address)
DataObjectDescriptor * m_descriptor
StatusCode MinimalDataObjectHandle::setDataProductNames ( const std::vector< std::string > &  addresses)
void MinimalDataObjectHandle::setOptional ( bool  optional = true)

Definition at line 59 of file MinimalDataObjectHandle.cpp.

59  {
60  m_descriptor->setOptional(optional);
61 }
DataObjectDescriptor * m_descriptor
void setOptional(bool optional)
void MinimalDataObjectHandle::setOptional ( bool  optional = true)
void MinimalDataObjectHandle::setRead ( bool  wasRead = true)
protected

Definition at line 141 of file MinimalDataObjectHandle.cpp.

bool wasRead() const
Check if operation was performed.
void MinimalDataObjectHandle::setRead ( bool  wasRead = true)
protected
void MinimalDataObjectHandle::setWritten ( bool  wasWritten = true)
protected

Definition at line 145 of file MinimalDataObjectHandle.cpp.

bool wasWritten() const
Check if operation was performed.
void MinimalDataObjectHandle::setWritten ( bool  wasWritten = true)
protected
void MinimalDataObjectHandle::unlock ( )

Definition at line 182 of file MinimalDataObjectHandle.cpp.

182  {
184 
186  for(auto & lock : m_locks[Gaudi::Hive::currentContextId()]){
187  //non-blocking call to try_lock
188  //if we can get the lock, then it wasn't set before -- delete it
189  if(lock.second.try_lock()){
191  }
192  }
193 
194  }
195 }
static std::map< size_t, std::map< size_t, tbb::spin_mutex > > m_locks
GAUDI_API ContextIdType currentContextId()
Return the current context id.
size_t dataProductIndex() const
Return the product index.
void MinimalDataObjectHandle::unlock ( )
size_t MinimalDataObjectHandle::updateDataProductIndex ( )
private

Definition at line 156 of file MinimalDataObjectHandle.cpp.

156  {
158  m_dataProductIndex = -1;
159  else {
160  auto idx = m_dataProductIndexMap.find(dataProductName());
161  if(idx != m_dataProductIndexMap.end())
162  m_dataProductIndex = idx->second;
163  else{
164  auto res = m_dataProductIndexMap.emplace(dataProductName(), m_dataProductIndexMap.size());
165  m_dataProductIndex = res.first->second;
166  }
167  }
168 
169  return m_dataProductIndex;
170 }
const std::string & dataProductName() const
Return the product name.
static const std::string NULL_
static std::unordered_map< std::string, size_t > m_dataProductIndexMap
size_t MinimalDataObjectHandle::updateDataProductIndex ( )
private
bool MinimalDataObjectHandle::wasRead ( ) const

Check if operation was performed.

Definition at line 123 of file MinimalDataObjectHandle.cpp.

123  {
124  return m_wasRead;
125 }
bool MinimalDataObjectHandle::wasRead ( ) const

Check if operation was performed.

bool MinimalDataObjectHandle::wasWritten ( ) const

Check if operation was performed.

bool MinimalDataObjectHandle::wasWritten ( ) const

Check if operation was performed.

Definition at line 135 of file MinimalDataObjectHandle.cpp.

135  {
136  return m_wasWritten;
137 }

Friends And Related Function Documentation

Algorithm
friend

Definition at line 35 of file MinimalDataObjectHandle.h.

AlgTool
friend

Definition at line 36 of file MinimalDataObjectHandle.h.

Definition at line 37 of file MinimalDataObjectHandle.h.

Member Data Documentation

static const uint MinimalDataObjectHandle::CLEANUP_THRESHOLD = 20
staticprivate

Definition at line 118 of file MinimalDataObjectHandle.h.

unsigned int MinimalDataObjectHandle::m_dataProductIndex
private

Definition at line 103 of file MinimalDataObjectHandle.h.

static std::unordered_map< std::string, size_t > MinimalDataObjectHandle::m_dataProductIndexMap
staticprivate

Definition at line 111 of file MinimalDataObjectHandle.h.

DataObjectDescriptor * MinimalDataObjectHandle::m_descriptor
protected

Definition at line 92 of file MinimalDataObjectHandle.h.

bool MinimalDataObjectHandle::m_initialized
private

Definition at line 106 of file MinimalDataObjectHandle.h.

static std::map< size_t, std::map< size_t, tbb::spin_mutex > > MinimalDataObjectHandle::m_locks
staticprivate

Definition at line 117 of file MinimalDataObjectHandle.h.

bool MinimalDataObjectHandle::m_wasRead
private

Definition at line 104 of file MinimalDataObjectHandle.h.

bool MinimalDataObjectHandle::m_wasWritten
private

Definition at line 105 of file MinimalDataObjectHandle.h.


The documentation for this class was generated from the following files: