ATLAS Offline Software
Loading...
Searching...
No Matches
ElementLinkTraits.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2/*
3 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4*/
36
37
38#ifndef ATHLINKS_ELEMENTLINKTRAITS_H
39#define ATHLINKS_ELEMENTLINKTRAITS_H
40
41
42#include "AthLinks/ElementLinkBase.h"
47
48
49namespace SG {
50
51
52// This is the interface that must be supplied by the ElementLink base class.
53// typedef index_type --- The type of the index supplied to and returned
54// from ElementLink.
55// typedef sgkey_t --- Type of hashed keys.
56// typedef ID_type --- Type of string keys.
57// typedef casefn_t --- Function casting from DataProxy to pointer.
58//
59// Should have a valid copy constructor and assignment operator.
60//
61// bool isDefaultIndex() const
62// Test the index validity.
63// bool hasCachedElement() const
64// Test to see if this link has a cached element pointer.
65// bool isDefault() const
66// Test to see if this link is in the default state.
67// index_type index() const
68// Return the index of the link.
69// ID_type dataID() const
70// Return the SG key that we reference, as a string.
71// sgkey_t key() const
72// Return the SG key that we reference, as a hash.
73// IProxyDict* source() const
74// Return the data source for the reference.
75// void reset()
76// Reset the link to a null state.
77// bool toTransient (IProxyDict*)
78// Finish initialization after link has been read.
79// bool doPersistent()
80// Prepare this link for writing.
81//
82// protected:
83// Base()
84// Makes a null link.
85// Base(const ID_type&, CLID, index_type, IProxyDict*)
86// Make link from string key and index.
87// Base(sgkey_t, CLID, index_type, IProxyDict*)
88// Make link from hashed key and index.
89// Base(const ID_type&, CLID, index_type, const void*, IProxyDict*)
90// Make link from string key, index, and element pointer.
91// Base(sgkey_t, CLID, index_type, const void*, IProxyDict*)
92// Make link from hashed key, index, and element pointer.
93// Base(const_pointer_t, CLID, index_type, IProxyDict*)
94// Make link from an index and a pointer to the container.
95// Base(const ElementLink<OTHER>&, FROM_TRAITS*, TO_TRAITS*)
96// Derived->base link conversion.
97// Base(const Base& other, const index_type& elemID);
98// Base(const DataLinkBase& other, const index_type& elemID);
99// SG::DataProxy* proxy() const
100// Return the SG proxy for the container holding the element.
101// void* storableBase(castfn_t*, CLID)
102// Return a pointer to the currently-referenced container object.
103// bool setStorableObject (const_pointer_t, CLID, bool, IProxyDict*)
104// Set the container referenced by the link to a pointer.
105// bool toIndexedElement (const_pointer_t, CLID, index_type,IProxyDict*)
106// Set the to an element given by index and pointer to container.
107// resetWithKeyAndIndex (const ID_type&, CLID, index_type, IProxyDict*)
108// Set the link to an element given by string key and index.
109// resetWithKeyAndIndex (sgkey_t, CLID, index_type, IProxyDict*)
110// Set the link to an element given by string key and index.
111// void setIndex(index_type)
112// Set the index part of the link.
113// const stored_index_type& storedIndex() const
114// Return the stored representation of the link index.
115// void setCachedElement(element_t)
116// Set the cached element stored in the link.
117// bool getCachedElement (const T* &) const
118// Retrieve the cached element from the link.
119// const SG::DataProxyHolder& proxyHolder() const
120// Return a reference to the internal proxy holder object.
121
122
123
124// This is the interface that must be supplied by an indexing policy.
125// All methods are static; instances of this class are never
126// actually created.
127// typedef ElementType --- The type returned when the link is dereferenced.
128// typedef ElementConstReference --- Derived from ElementType.
129// typedef ElementConstPointer --- Derived from ElementType.
130// typedef index_type --- The type of the index supplied to and returned
131// from ElementLink.
132// typedef stored_index_type --- The type of the index actually stored
133// within the ElementLink. Should
134// be implicitly convertable to index_type
135// (if not identical).
136// static bool isValid (stored_index_type index);
137// Test to see if an index has been set.
138// static index_type storedToExternal (stored_index_type index)
139// Convert from stored to external index.
140// static void reset (stored_index_type& index);
141// Reset an index to an invalid state.
142// static ElementType lookup (index_type index, const CONT& data);
143// Return the element identified by INDEX in DATA.
144// May throw an exception if the index is not valid.
145// static void reverseLookup(const CONT& data,
146// ElementConstReference element,
147// index_type& index);
148// Find the (first) index for ELEMENT in DATA.
149// Throw SG::ExcElementNotFound if the element is not in the container.
150//
151
152
153
157template <class STORABLE,
158 class VALUE_TYPE = typename STORABLE::value_type,
159 bool IS_SEQUENCE = IsSTLSequence<STORABLE>::value>
167
168
173template <class STORABLE, class BASE_VALUE_TYPE>
174class ElementLinkTraits1<STORABLE, BASE_VALUE_TYPE*, true>
175{
176public:
177 typedef STORABLE Storable;
180};
181
182
183
190template <class STORABLE>
192 : public ElementLinkTraits1<STORABLE>
193{
194public:
195 typedef STORABLE Storable;
198};
199
200
201} // namespace SG
202
203
204
215#define ELEMENTLINK_FWD(TYPE, VALUE_TYPE) \
216namespace SG { \
217template<> \
218class ElementLinkTraits<TYPE> \
219{ \
220public: \
221 typedef TYPE Storable; \
222 typedef ElementLinkBase Base; \
223 typedef ForwardIndexingPolicy<TYPE, VALUE_TYPE*> IndexingPolicy; \
224}; \
225} \
226class elementlink_fwd_dummy
227
228
229
230#endif // not ATHLINKS_ELEMENTLINKTRAITS_H
Indexing policy for a vector-like container.
Generic base class for ElementLinks.
Base class for ElementLinks to vectors of pointers.
ElementLink classes for the generic case.
SG::GenerateIndexingPolicy< STORABLE >::type IndexingPolicy
SG::GenericElementLinkBase< IndexingPolicy > Base
ElementLinkTraits class to specialize.
ElementLinkTraits1< STORABLE >::IndexingPolicy IndexingPolicy
ElementLinkTraits1< STORABLE >::Base Base
Indexing policy for a vector-like container.
Generic base class for ElementLinks.
Forward declaration.
std::conditional< m_isSTLSequence, ForwardIndexingPolicy< CONTAINER >, typenameDefaultIndexingPolicy< CONTAINER >::type >::type type
static const bool value