1 #ifndef GAUDIKERNEL_REFTABLE_H
2 #define GAUDIKERNEL_REFTABLE_H 1
6 #include "GaudiKernel/Kernel.h"
7 #include "GaudiKernel/DataObject.h"
8 #include "GaudiKernel/StreamBuffer.h"
9 #include "GaudiKernel/SmartRefVector.h"
10 #include "GaudiKernel/SmartRef.h"
11 #include "GaudiKernel/HashMap.h"
14 static const CLID CLID_RefTable1to1 = 300;
15 static const CLID CLID_RefTable1toN = 301;
75 return m_table.insert( from, to );
79 auto i = m_table.find( from );
80 return i != 0 ? &(
i->second) :
nullptr;
83 const EntryType*
i_reference(
const KeyType* from)
const {
84 auto i = m_table.find( from );
85 return i != m_table.end() ? &(
i->second) :
nullptr;
95 virtual void clear() {
100 return m_table.begin();
103 const_iterator
begin()
const {
104 return m_table.begin();
108 return m_table.end();
111 const_iterator
end()
const {
112 return m_table.end();
116 return m_table.size();
120 m_table.reserve(len);
124 DataObject::serialize(s) << m_table.
size();
136 DataObject::serialize(s) >> siz;
165 bool insert (
const FROM* from, TO* to ) {
169 bool insert (
const FROM* from,
const EntryType& to) {
179 return (0 == e) ? 0 : (*e);
183 const TO*
reference(
const FROM* from)
const {
185 return e ? *e :
nullptr;
189 bool isReferenced(
const FROM* from,
const TO* to )
const {
191 return e && ( *e == to );
194 bool isReferenced(
const FROM* from,
const EntryType& to ) {
196 return assoc && (*e!=to) && (e->target()==to.target());
215 bool insert (
const FROM* from, TO* to) {
220 if ( !( 0 == newEntry) ) {
235 if ( !(0 == newEntry) ) {
236 newEntry->push_back( to );
241 entry->push_back( to );
245 bool insert (
const FROM* from,
const EntryType& to) {
250 static EntryType empty;
252 return e ? *e : empty;
255 const EntryType&
reference(
const FROM* from)
const {
256 static const EntryType empty;
258 return e ? *e : empty;
261 bool isReferenced(
const FROM* from,
const EntryType& to ) {
263 return e && ( *e == to );
272 return assoc && std::find(e->begin(), e->end(), to) != e->end();
277 #endif // GAUDIKERNEL_REFTABLE_H
CLID m_clid
Class id of the reference table.
RefTableBase< FROM, EntryType > BaseType
iterator begin()
Start of direct access iterator.
The stream buffer is a small object collecting object data.
~RefTable1toN() override=default
Standard Destructor.
GaudiUtils::HashMap< const void *, EntryType > TableType
Define Reference map.
TableType::const_iterator const_iterator
Definition of map iterator (CONST)
SmartRef< KeyType > m_fromRef
This is a completely useless entry, but the compiler wants it to be instantiated before the serialize...
TO * reference(const FROM *from)
Find Reference from it's source entry.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Kernel objects: SmartRefVector.
EntryType * i_reference(const KeyType *from)
Find Reference from it's source entry.
void reserve(long len)
Reserve buffer space; Default: 16 k buffer size.
void reserve(int len)
Size of References.
long size() const
Size of References.
TableType::iterator iterator
Definition of map iterator.
iterator end()
End of direct access iterator.
RefTableBase(const CLID &clid, int len)
Constructors.
RefTable1toN(const CLID &clid, int len=16)
Standard Constructor.
map_type::const_iterator const_iterator
unsigned int CLID
Class ID definition.
virtual void clear()
Clear Reference map.
virtual StreamBuffer & serialize(StreamBuffer &s) const
Serialize the object for writing.
TableType m_table
Reference map.
map_type::iterator iterator
~RefTable1to1() override=default
Standard Destructor.
RefTable1to1(const CLID &clid, int len=16)
Standard Constructor.
bool insert(const FROM *from, TO *to)
Insert new Entry into Reference container.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
bool insertMapElement(const KeyType *from, EntryType &to)
Insert new Entry into Reference container.
EntryType & reference(const FROM *from)
Find Reference from it's source entry.
A DataObject is the base class of any identifiable object on any data store.
long size() const
Total buffer size.
bool isReferenced(const FROM *from, const TO *to) const
Check if two entries are associated to each other.
virtual ~RefTableBase()=default
Destructor.
bool isReferenced(const FROM *from, const EntryType &to)
Check if two entries are Referenced to each other.
bool insert(const FROM *from, TO *to)
Insert new Entry into Reference container.