ATLAS Offline Software
List of all members
AssociationMap< OBJCONT, ASSCONT > Class Template Reference

templated base class for a look-up map for associations More...

#include <AssociationMap.h>

Collaboration diagram for AssociationMap< OBJCONT, ASSCONT >:

Public Types

Store Iterator Types
typedef AssociationVectorIterator asso_iterator
 association iterator type More...
 
typedef AssociationObjectIterator object_iterator
 object iterator type More...
 

Public Member Functions

Constructors and Destructor
 AssociationMap ()
 
virtual ~AssociationMap ()
 
Add Associations
Parameters
objectContainer- pointer to the object container
objectIndex- index of object in container
objectPointer- pointer to object
assoContainer- container of potentially associated objects
assoIndex- index of associated object in container
assoPointer- pointer to associated object
void addAssociation (const object_container_type *objectContainer, const object_index_type &objectIndex, const asso_container_type *assoContainer, const asso_index_type &assoIndex)
 
void addAssociation (const object_container_type *objectContainer, const object_type *objectPointer, const asso_container_type *assoContainer, const asso_type *assoPointer)
 
void addAssociation (const object_link &objectLink, const asso_link &assoLink)
 

Argument and Internal Store Types

typedef OBJCONT object_container_type
 
typedef object_container_type::base_value_type object_type
 
typedef SG::GenerateIndexingPolicy< object_container_type >::type::index_type object_index_type
 
typedef ElementLink< object_container_typeobject_link
 
typedef std::list< const object_type * > object_list
 
typedef ASSCONT asso_container_type
 
typedef asso_container_type::base_value_type asso_type
 
typedef SG::GenerateIndexingPolicy< asso_container_type >::type::index_type asso_index_type
 
typedef std::list< const asso_type * > asso_list
 
typedef ElementLink< asso_container_typeasso_link
 
typedef ElementLinkVector< asso_container_typeasso_store
 
typedef asso_store::const_iterator asso_store_iterator
 
typedef std::map< object_link, asso_storestore_type
 
typedef store_type::iterator store_iterator_type
 
static const asso_store s_dum_asso_store
 

Object and Association Iterators

The association iterators are returned for a given object, which can either be referenced by its pointer or its iterator in the internal store.

Parameters
objectPointer- pointer to a given object
objectIter- iterator to a given object
store_type m_associationMap
 internal store More...
 
object_iterator beginObject () const
 begin iterator for objects More...
 
object_iterator endObject () const
 end iterator for objects More...
 
asso_iterator beginAssociation (const object_type *objectPointer) const
 begin iterator for associations More...
 
asso_iterator beginAssociation (const object_iterator &objectIter) const
 
asso_iterator endAssociation (const object_type *objectPointer) const
 end iterator for associations More...
 
asso_iterator endAssociation (const object_iterator &objectIter) const
 
const object_typegetObject (const object_iterator &objectIter) const
 get association iterators by object iterator More...
 
object_iterator findObject (const object_type *theObject) const
 finding an object with allocation More...
 
bool containsObject (const object_type *theObject) const
 testing if object is in store More...
 
size_t getNumberOfObjects () const
 retrieve number of objects in store More...
 
const asso_typegetAssociation (asso_iterator assoIter) const
 associations iterator access More...
 
asso_iterator findAssociation (const object_iterator &objectIter, const asso_type *assoPointer) const
 find association More...
 
asso_iterator findAssociation (const object_type *objectPointer, const asso_type *assoPointer) const
 
bool containsAssociation (const object_iterator &objectIter, const asso_type *assoPointer) const
 containment check More...
 
bool containsAssociation (const object_type *objectPointer, const asso_type *assoPointer) const
 
bool containsAssociation (const asso_type *assoPointer) const
 
bool getObjects (const asso_type *assoPointer, object_list &theObjects) const
 get all objects for a given association More...
 
bool getObjects (const asso_iterator &assoIter, object_list &theObjects) const
 get all objects for a given association More...
 
bool getAssociations (const object_type *objPointer, asso_list &assocs) const
 get all associations for a given object More...
 
bool getAssociations (const object_iterator &objIter, asso_list &assocs) const
 get all associations for a given object More...
 
size_t size ()
 get number of associations More...
 
size_t size () const
 get number of associations More...
 
size_t size (const object_type *objectPointer) const
 
size_t getNumberOfAssociations (const object_type *objectPointer) const
 
size_t size (const object_iterator &objectIter) const
 
size_t getNumberOfAssociations (const object_iterator &objectIter) const
 
store_iterator_type internalFind (const object_link &objectLink, const asso_link &assoLink)
 internally used find method More...
 
bool addToStore (const object_link &objectLink, const asso_link &assoLink)
 internally used function to add links to store More...
 

Detailed Description

template<class OBJCONT, class ASSCONT>
class AssociationMap< OBJCONT, ASSCONT >

templated base class for a look-up map for associations

The templated base class AssociationMap provides all functionality to support a mapped look-up between object of a given type and their associations, typically of a different type (many-to-many look-up). Concrete objects instantiated from implementation classes derived from AssociationMap are not automatically storable. The concrete class needs to either be DataObject itself, or the corresponding object needs to be collected into a storable DataVector.

The internal storage model is a matrix, where the rows are keyed by the object pointer and the columns are pointers to associations. The number of columns (= associations) typically varies row-by-row.

Author
Peter Loch loch@.nosp@m.phys.nosp@m.ics.a.nosp@m.rizo.nosp@m.na.ed.nosp@m.u
Date
June 1, 2004 - first implementation

Definition at line 38 of file AssociationMap.h.

Member Typedef Documentation

◆ asso_container_type

template<class OBJCONT , class ASSCONT >
typedef ASSCONT AssociationMap< OBJCONT, ASSCONT >::asso_container_type

Definition at line 53 of file AssociationMap.h.

◆ asso_index_type

template<class OBJCONT , class ASSCONT >
typedef SG::GenerateIndexingPolicy<asso_container_type>::type::index_type AssociationMap< OBJCONT, ASSCONT >::asso_index_type

Definition at line 58 of file AssociationMap.h.

◆ asso_iterator

template<class OBJCONT , class ASSCONT >
typedef AssociationVectorIterator AssociationMap< OBJCONT, ASSCONT >::asso_iterator

association iterator type

Definition at line 81 of file AssociationMap.h.

◆ asso_link

template<class OBJCONT , class ASSCONT >
typedef ElementLink<asso_container_type> AssociationMap< OBJCONT, ASSCONT >::asso_link

Definition at line 60 of file AssociationMap.h.

◆ asso_list

template<class OBJCONT , class ASSCONT >
typedef std::list<const asso_type*> AssociationMap< OBJCONT, ASSCONT >::asso_list

Definition at line 59 of file AssociationMap.h.

◆ asso_store

template<class OBJCONT , class ASSCONT >
typedef ElementLinkVector<asso_container_type> AssociationMap< OBJCONT, ASSCONT >::asso_store

Definition at line 61 of file AssociationMap.h.

◆ asso_store_iterator

template<class OBJCONT , class ASSCONT >
typedef asso_store::const_iterator AssociationMap< OBJCONT, ASSCONT >::asso_store_iterator

Definition at line 62 of file AssociationMap.h.

◆ asso_type

template<class OBJCONT , class ASSCONT >
typedef asso_container_type::base_value_type AssociationMap< OBJCONT, ASSCONT >::asso_type

Definition at line 54 of file AssociationMap.h.

◆ object_container_type

template<class OBJCONT , class ASSCONT >
typedef OBJCONT AssociationMap< OBJCONT, ASSCONT >::object_container_type

Definition at line 44 of file AssociationMap.h.

◆ object_index_type

template<class OBJCONT , class ASSCONT >
typedef SG::GenerateIndexingPolicy<object_container_type>::type::index_type AssociationMap< OBJCONT, ASSCONT >::object_index_type

Definition at line 49 of file AssociationMap.h.

◆ object_iterator

template<class OBJCONT , class ASSCONT >
typedef AssociationObjectIterator AssociationMap< OBJCONT, ASSCONT >::object_iterator

object iterator type

Definition at line 84 of file AssociationMap.h.

◆ object_link

template<class OBJCONT , class ASSCONT >
typedef ElementLink<object_container_type> AssociationMap< OBJCONT, ASSCONT >::object_link

Definition at line 50 of file AssociationMap.h.

◆ object_list

template<class OBJCONT , class ASSCONT >
typedef std::list<const object_type*> AssociationMap< OBJCONT, ASSCONT >::object_list

Definition at line 51 of file AssociationMap.h.

◆ object_type

template<class OBJCONT , class ASSCONT >
typedef object_container_type::base_value_type AssociationMap< OBJCONT, ASSCONT >::object_type

Definition at line 45 of file AssociationMap.h.

◆ store_iterator_type

template<class OBJCONT , class ASSCONT >
typedef store_type::iterator AssociationMap< OBJCONT, ASSCONT >::store_iterator_type

Definition at line 64 of file AssociationMap.h.

◆ store_type

template<class OBJCONT , class ASSCONT >
typedef std::map<object_link,asso_store> AssociationMap< OBJCONT, ASSCONT >::store_type

Definition at line 63 of file AssociationMap.h.

Constructor & Destructor Documentation

◆ AssociationMap()

template<class OBJCONT , class ASSCONT >
AssociationMap< OBJCONT, ASSCONT >::AssociationMap ( )

◆ ~AssociationMap()

template<class OBJCONT , class ASSCONT >
virtual AssociationMap< OBJCONT, ASSCONT >::~AssociationMap ( )
virtual

Member Function Documentation

◆ addAssociation() [1/3]

template<class OBJCONT , class ASSCONT >
void AssociationMap< OBJCONT, ASSCONT >::addAssociation ( const object_container_type objectContainer,
const object_index_type objectIndex,
const asso_container_type assoContainer,
const asso_index_type assoIndex 
)

◆ addAssociation() [2/3]

template<class OBJCONT , class ASSCONT >
void AssociationMap< OBJCONT, ASSCONT >::addAssociation ( const object_container_type objectContainer,
const object_type objectPointer,
const asso_container_type assoContainer,
const asso_type assoPointer 
)

◆ addAssociation() [3/3]

template<class OBJCONT , class ASSCONT >
void AssociationMap< OBJCONT, ASSCONT >::addAssociation ( const object_link objectLink,
const asso_link assoLink 
)

◆ addToStore()

template<class OBJCONT , class ASSCONT >
bool AssociationMap< OBJCONT, ASSCONT >::addToStore ( const object_link objectLink,
const asso_link assoLink 
)
protected

internally used function to add links to store

◆ beginAssociation() [1/2]

template<class OBJCONT , class ASSCONT >
asso_iterator AssociationMap< OBJCONT, ASSCONT >::beginAssociation ( const object_iterator objectIter) const

◆ beginAssociation() [2/2]

template<class OBJCONT , class ASSCONT >
asso_iterator AssociationMap< OBJCONT, ASSCONT >::beginAssociation ( const object_type objectPointer) const

begin iterator for associations

◆ beginObject()

template<class OBJCONT , class ASSCONT >
object_iterator AssociationMap< OBJCONT, ASSCONT >::beginObject ( ) const

begin iterator for objects

◆ containsAssociation() [1/3]

template<class OBJCONT , class ASSCONT >
bool AssociationMap< OBJCONT, ASSCONT >::containsAssociation ( const asso_type assoPointer) const

◆ containsAssociation() [2/3]

template<class OBJCONT , class ASSCONT >
bool AssociationMap< OBJCONT, ASSCONT >::containsAssociation ( const object_iterator objectIter,
const asso_type assoPointer 
) const
inline

containment check

Definition at line 166 of file AssociationMap.h.

168  { return objectIter.containsAssociation(assoPointer); }

◆ containsAssociation() [3/3]

template<class OBJCONT , class ASSCONT >
bool AssociationMap< OBJCONT, ASSCONT >::containsAssociation ( const object_type objectPointer,
const asso_type assoPointer 
) const

◆ containsObject()

template<class OBJCONT , class ASSCONT >
bool AssociationMap< OBJCONT, ASSCONT >::containsObject ( const object_type theObject) const
inline

testing if object is in store

Definition at line 144 of file AssociationMap.h.

145  { return this->findObject(theObject) != this->endObject(); }

◆ endAssociation() [1/2]

template<class OBJCONT , class ASSCONT >
asso_iterator AssociationMap< OBJCONT, ASSCONT >::endAssociation ( const object_iterator objectIter) const

◆ endAssociation() [2/2]

template<class OBJCONT , class ASSCONT >
asso_iterator AssociationMap< OBJCONT, ASSCONT >::endAssociation ( const object_type objectPointer) const

end iterator for associations

◆ endObject()

template<class OBJCONT , class ASSCONT >
object_iterator AssociationMap< OBJCONT, ASSCONT >::endObject ( ) const

end iterator for objects

◆ findAssociation() [1/2]

template<class OBJCONT , class ASSCONT >
asso_iterator AssociationMap< OBJCONT, ASSCONT >::findAssociation ( const object_iterator objectIter,
const asso_type assoPointer 
) const
inline

find association

Definition at line 159 of file AssociationMap.h.

161  { return objectIter.findAssociation(assoPointer); }

◆ findAssociation() [2/2]

template<class OBJCONT , class ASSCONT >
asso_iterator AssociationMap< OBJCONT, ASSCONT >::findAssociation ( const object_type objectPointer,
const asso_type assoPointer 
) const

◆ findObject()

template<class OBJCONT , class ASSCONT >
object_iterator AssociationMap< OBJCONT, ASSCONT >::findObject ( const object_type theObject) const
inline

finding an object with allocation

Definition at line 139 of file AssociationMap.h.

141  { return object_iterator(m_associationMap).find(theObject); }

◆ getAssociation()

template<class OBJCONT , class ASSCONT >
const asso_type* AssociationMap< OBJCONT, ASSCONT >::getAssociation ( asso_iterator  assoIter) const
inline

associations iterator access

The associations are accessed as function of the row key (the object).

Definition at line 155 of file AssociationMap.h.

156  { return *assoIter; }

◆ getAssociations() [1/2]

template<class OBJCONT , class ASSCONT >
bool AssociationMap< OBJCONT, ASSCONT >::getAssociations ( const object_iterator objIter,
asso_list assocs 
) const
inline

get all associations for a given object

Definition at line 185 of file AssociationMap.h.

186  { return this->getAssociations(objIter.getObject(),assocs); }

◆ getAssociations() [2/2]

template<class OBJCONT , class ASSCONT >
bool AssociationMap< OBJCONT, ASSCONT >::getAssociations ( const object_type objPointer,
asso_list assocs 
) const

get all associations for a given object

◆ getNumberOfAssociations() [1/2]

template<class OBJCONT , class ASSCONT >
size_t AssociationMap< OBJCONT, ASSCONT >::getNumberOfAssociations ( const object_iterator objectIter) const
inline

Definition at line 202 of file AssociationMap.h.

203  { return this->size(objectIter); }

◆ getNumberOfAssociations() [2/2]

template<class OBJCONT , class ASSCONT >
size_t AssociationMap< OBJCONT, ASSCONT >::getNumberOfAssociations ( const object_type objectPointer) const
inline

Definition at line 196 of file AssociationMap.h.

197  { return this->size(objectPointer); }

◆ getNumberOfObjects()

template<class OBJCONT , class ASSCONT >
size_t AssociationMap< OBJCONT, ASSCONT >::getNumberOfObjects ( ) const
inline

retrieve number of objects in store

Definition at line 148 of file AssociationMap.h.

148 { return this->size(); }

◆ getObject()

template<class OBJCONT , class ASSCONT >
const object_type* AssociationMap< OBJCONT, ASSCONT >::getObject ( const object_iterator objectIter) const
inline

get association iterators by object iterator

type-safe retrieval of object pointer from iterator

Definition at line 135 of file AssociationMap.h.

136  { return (*objectIter).getObject(); }

◆ getObjects() [1/2]

template<class OBJCONT , class ASSCONT >
bool AssociationMap< OBJCONT, ASSCONT >::getObjects ( const asso_iterator assoIter,
object_list theObjects 
) const
inline

get all objects for a given association

Definition at line 178 of file AssociationMap.h.

179  { return this->getObjects(*assoIter,theObjects); }

◆ getObjects() [2/2]

template<class OBJCONT , class ASSCONT >
bool AssociationMap< OBJCONT, ASSCONT >::getObjects ( const asso_type assoPointer,
object_list theObjects 
) const

get all objects for a given association

◆ internalFind()

template<class OBJCONT , class ASSCONT >
store_iterator_type AssociationMap< OBJCONT, ASSCONT >::internalFind ( const object_link objectLink,
const asso_link assoLink 
)
inlineprotected

internally used find method

Definition at line 211 of file AssociationMap.h.

213  {
214  // check key
215  store_iterator_type mapEnd = m_associationMap.end();
216  store_iterator_type foundIter = mapEnd;
217  for ( store_iterator_type iMap = m_associationMap.begin();
218  iMap != mapEnd;
219  ++iMap ) {
220  // look for the address of the pointed-at object
221  // must dereference the ElementLink pointer
222  if ( iMap->first.cptr() == objectLink.cptr() ) {
223  foundIter = iMap;
224  break;
225  }
226  }
227 
228  if ( foundIter == m_associationMap.end() ) { return foundIter; }
229  // check data
230  if ( std::find((foundIter->second).begin(),
231  (foundIter->second).end(),
232  assoLink) !=
233  (foundIter->second).end() )
234  { return foundIter; }
235  // not found at all
236  return m_associationMap.end();
237  }

◆ size() [1/4]

template<class OBJCONT , class ASSCONT >
size_t AssociationMap< OBJCONT, ASSCONT >::size ( )
inline

get number of associations

Definition at line 189 of file AssociationMap.h.

189 { return m_associationMap.size(); }

◆ size() [2/4]

template<class OBJCONT , class ASSCONT >
size_t AssociationMap< OBJCONT, ASSCONT >::size ( ) const
inline

get number of associations

Definition at line 192 of file AssociationMap.h.

192 { return m_associationMap.size(); }

◆ size() [3/4]

template<class OBJCONT , class ASSCONT >
size_t AssociationMap< OBJCONT, ASSCONT >::size ( const object_iterator objectIter) const
inline

Definition at line 199 of file AssociationMap.h.

200  { return objectIter.getNumberOfAssociations(); }

◆ size() [4/4]

template<class OBJCONT , class ASSCONT >
size_t AssociationMap< OBJCONT, ASSCONT >::size ( const object_type objectPointer) const

Member Data Documentation

◆ m_associationMap

template<class OBJCONT , class ASSCONT >
store_type AssociationMap< OBJCONT, ASSCONT >::m_associationMap
protected

internal store

Definition at line 208 of file AssociationMap.h.

◆ s_dum_asso_store

template<class OBJCONT , class ASSCONT >
const asso_store AssociationMap< OBJCONT, ASSCONT >::s_dum_asso_store
static

Definition at line 68 of file AssociationMap.h.


The documentation for this class was generated from the following file:
AssociationMap::store_iterator_type
store_type::iterator store_iterator_type
Definition: AssociationMap.h:64
AssociationMap::getAssociations
bool getAssociations(const object_type *objPointer, asso_list &assocs) const
get all associations for a given object
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
AssociationMap::object_iterator
AssociationObjectIterator object_iterator
object iterator type
Definition: AssociationMap.h:84
AssociationMap::endObject
object_iterator endObject() const
end iterator for objects
AssociationMap::size
size_t size()
get number of associations
Definition: AssociationMap.h:189
AssociationMap::findObject
object_iterator findObject(const object_type *theObject) const
finding an object with allocation
Definition: AssociationMap.h:139
AssociationMap::getObjects
bool getObjects(const asso_type *assoPointer, object_list &theObjects) const
get all objects for a given association
AssociationMap::m_associationMap
store_type m_associationMap
internal store
Definition: AssociationMap.h:208