ATLAS Offline Software
Loading...
Searching...
No Matches
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 >:

Classes

class  AssociationObjectIterator
 code only expands with the ASSOCIATIONMAP_CONTEXT More...
class  AssociationVectorIterator
 iterator for association vectors (internal use only) More...

Public Types

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

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
object_iterator beginObject () const
 begin iterator for objects
object_iterator endObject () const
 end iterator for objects
asso_iterator beginAssociation (const object_type *objectPointer) const
 begin iterator for associations
asso_iterator beginAssociation (const object_iterator &objectIter) const
asso_iterator endAssociation (const object_type *objectPointer) const
 end iterator for associations
asso_iterator endAssociation (const object_iterator &objectIter) const
const object_typegetObject (const object_iterator &objectIter) const
 get association iterators by object iterator
object_iterator findObject (const object_type *theObject) const
 finding an object with allocation
bool containsObject (const object_type *theObject) const
 testing if object is in store
size_t getNumberOfObjects () const
 retrieve number of objects in store
const asso_typegetAssociation (asso_iterator assoIter) const
 associations iterator access
asso_iterator findAssociation (const object_iterator &objectIter, const asso_type *assoPointer) const
 find association
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
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
bool getObjects (const asso_iterator &assoIter, object_list &theObjects) const
 get all objects for a given association
bool getAssociations (const object_type *objPointer, asso_list &assocs) const
 get all associations for a given object
bool getAssociations (const object_iterator &objIter, asso_list &assocs) const
 get all associations for a given object
size_t size ()
 get number of associations
size_t size () const
 get number of associations
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
bool addToStore (const object_link &objectLink, const asso_link &assoLink)
 internally used function to add links to store

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 165 of file AssociationMap.h.

templated base class for a look-up map for associations
bool containsAssociation(const object_iterator &objectIter, const asso_type *assoPointer) const
containment check

◆ 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 143 of file AssociationMap.h.

144 { return this->findObject(theObject) != this->endObject(); }
object_iterator endObject() const
end iterator for objects
object_iterator findObject(const object_type *theObject) const
finding an object with allocation

◆ 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 158 of file AssociationMap.h.

asso_iterator findAssociation(const object_iterator &objectIter, const asso_type *assoPointer) const
find association

◆ 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.

AssociationObjectIterator find(const object_type *objectPointer) const
find a given object in store
store_type m_associationMap
internal store
AssociationObjectIterator object_iterator
object iterator type

◆ 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 154 of file AssociationMap.h.

155 { 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 184 of file AssociationMap.h.

185 { return this->getAssociations(objIter.getObject(),assocs); }
const object_type * getObject(const object_iterator &objectIter) const
get association iterators by object iterator
bool getAssociations(const object_type *objPointer, asso_list &assocs) const
get all associations for a given object

◆ 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 201 of file AssociationMap.h.

202 { return this->size(objectIter); }
size_t size()
get number of associations

◆ getNumberOfAssociations() [2/2]

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

Definition at line 195 of file AssociationMap.h.

196 { 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 147 of file AssociationMap.h.

147{ 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 177 of file AssociationMap.h.

178 { return this->getObjects(*assoIter,theObjects); }
bool getObjects(const asso_type *assoPointer, object_list &theObjects) const
get all objects for a given association

◆ 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 210 of file AssociationMap.h.

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

◆ size() [1/4]

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

get number of associations

Definition at line 188 of file AssociationMap.h.

188{ 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 191 of file AssociationMap.h.

191{ 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 198 of file AssociationMap.h.

size_t getNumberOfAssociations(const object_type *objectPointer) const

◆ 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 207 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: