ATLAS Offline Software
Classes | Namespaces | Macros
ElementLinkTraits.h File Reference

Determine dependent types for ElementLink classes. More...

#include "AthLinks/ElementLinkBase.h"
#include "AthLinks/tools/IsSTLSequence.h"
#include "AthLinks/tools/ForwardIndexingPolicy.h"
#include "AthLinks/tools/GenerateIndexingPolicy.h"
#include "AthLinks/GenericElementLinkBase.h"
Include dependency graph for ElementLinkTraits.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  SG::ElementLinkTraits1< STORABLE, VALUE_TYPE, IS_SEQUENCE >
 ElementLink classes for the generic case. More...
 
class  SG::ElementLinkTraits1< STORABLE, BASE_VALUE_TYPE *, true >
 ElementLink classes for the case of a vector-like container of pointers. More...
 
class  SG::ElementLinkTraits< STORABLE >
 ElementLinkTraits class to specialize. More...
 

Namespaces

 SG
 Forward declaration.
 

Macros

#define ELEMENTLINK_FWD(TYPE, VALUE_TYPE)
 Forward declaration helper for ElementLink. More...
 

Detailed Description

Determine dependent types for ElementLink classes.

Author
scott snyder snyde.nosp@m.r@bn.nosp@m.l.gov
Date
Dec, 2013 An ElementLink class needs to store the index of the referenced element; it also caches a copy of the element itself. In general, these can be arbitrary types, and so the data members for them must be in a templated class.

However, by far the most common use of ElementLink is to refer to an element in a vector-like container of pointers. In that case, we can get away with storing the persistent data in a non-templated class, and in fact that makes direct ROOT I/O much easier.

So, what we do is factor out all the state of ElementLink into a base class. For the generic case, we use the templated GenericElementLinkBase class. However, for the case of a vector of pointers, we use instead the non-templated class ElementLinkBase. The choice of which base class to use is made by the traits class defined here, ElementLinkTraits.

An ElementLink must also be associated with an indexing policy class. The traits class also provides the appropriate indexing policy; in general, this is generated by GenerateIndexingPolicy, but for the specialized case, we always use ForwardIndexingPolicy.

See below for the interfaces that must be supplied by the ElementLink base classes and by the indexing policy.

Definition in file ElementLinkTraits.h.

Macro Definition Documentation

◆ ELEMENTLINK_FWD

#define ELEMENTLINK_FWD (   TYPE,
  VALUE_TYPE 
)
Value:
namespace SG { \
template<> \
class ElementLinkTraits<TYPE> \
{ \
public: \
typedef TYPE Storable; \
typedef ElementLinkBase Base; \
typedef ForwardIndexingPolicy<TYPE, VALUE_TYPE*> IndexingPolicy; \
}; \
} \
class elementlink_fwd_dummy

Forward declaration helper for ElementLink.

This macro helps in declaring an ElementLink to a container with an incomplete definition (that has been forward declared). Restriction: The container must be a vector-like container of pointers. Must not be used inside a namespace.

See comments in ElementLink.h for a usage example.

Definition at line 216 of file ElementLinkTraits.h.

SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
ElementLinkBase
Base class for ElementLinks to vectors of pointers.
Definition: AthLinks/ElementLinkBase.h:59
Base
TYPE
#define TYPE(CODE, TYP, IOTYP)