ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthLinks
AthLinks
tools
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"
43
#include "
AthLinks/tools/IsSTLSequence.h
"
44
#include "
AthLinks/tools/ForwardIndexingPolicy.h
"
45
#include "
AthLinks/tools/GenerateIndexingPolicy.h
"
46
#include "
AthLinks/GenericElementLinkBase.h
"
47
48
49
namespace
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
157
template
<
class
STORABLE,
158
class
VALUE_TYPE =
typename
STORABLE::value_type,
159
bool
IS_SEQUENCE =
IsSTLSequence<STORABLE>::value
>
160
class
ElementLinkTraits1
161
{
162
public
:
163
typedef
STORABLE
Storable
;
164
typedef
typename
SG::GenerateIndexingPolicy<STORABLE>::type
IndexingPolicy
;
165
typedef
typename
SG::GenericElementLinkBase<IndexingPolicy>
Base
;
166
};
167
168
173
template
<
class
STORABLE,
class
BASE_VALUE_TYPE>
174
class
ElementLinkTraits1
<STORABLE, BASE_VALUE_TYPE*,
true
>
175
{
176
public
:
177
typedef
STORABLE
Storable
;
178
typedef
ElementLinkBase
Base
;
179
typedef
ForwardIndexingPolicy<STORABLE>
IndexingPolicy
;
180
};
181
182
183
190
template
<
class
STORABLE>
191
class
ElementLinkTraits
192
:
public
ElementLinkTraits1
<STORABLE>
193
{
194
public
:
195
typedef
STORABLE
Storable
;
196
typedef
typename
ElementLinkTraits1<STORABLE>::Base
Base
;
197
typedef
typename
ElementLinkTraits1<STORABLE>::IndexingPolicy
IndexingPolicy
;
198
};
199
200
201
}
// namespace SG
202
203
204
215
#define ELEMENTLINK_FWD(TYPE, VALUE_TYPE) \
216
namespace SG { \
217
template<> \
218
class ElementLinkTraits<TYPE> \
219
{ \
220
public: \
221
typedef TYPE Storable; \
222
typedef ElementLinkBase Base; \
223
typedef ForwardIndexingPolicy<TYPE, VALUE_TYPE*> IndexingPolicy; \
224
}; \
225
} \
226
class elementlink_fwd_dummy
227
228
229
230
#endif
// not ATHLINKS_ELEMENTLINKTRAITS_H
ForwardIndexingPolicy.h
Indexing policy for a vector-like container.
GenerateIndexingPolicy.h
GenericElementLinkBase.h
Generic base class for ElementLinks.
IsSTLSequence.h
ElementLinkBase
Base class for ElementLinks to vectors of pointers.
Definition
AthLinks/ElementLinkBase.h:59
SG::ElementLinkTraits1< STORABLE, BASE_VALUE_TYPE *, true >::Storable
STORABLE Storable
Definition
ElementLinkTraits.h:177
SG::ElementLinkTraits1< STORABLE, BASE_VALUE_TYPE *, true >::Base
ElementLinkBase Base
Definition
ElementLinkTraits.h:178
SG::ElementLinkTraits1< STORABLE, BASE_VALUE_TYPE *, true >::IndexingPolicy
ForwardIndexingPolicy< STORABLE > IndexingPolicy
Definition
ElementLinkTraits.h:179
SG::ElementLinkTraits1
ElementLink classes for the generic case.
Definition
ElementLinkTraits.h:161
SG::ElementLinkTraits1::IndexingPolicy
SG::GenerateIndexingPolicy< STORABLE >::type IndexingPolicy
Definition
ElementLinkTraits.h:164
SG::ElementLinkTraits1::Base
SG::GenericElementLinkBase< IndexingPolicy > Base
Definition
ElementLinkTraits.h:165
SG::ElementLinkTraits1::Storable
STORABLE Storable
Definition
ElementLinkTraits.h:163
SG::ElementLinkTraits
ElementLinkTraits class to specialize.
Definition
ElementLinkTraits.h:193
SG::ElementLinkTraits::IndexingPolicy
ElementLinkTraits1< STORABLE >::IndexingPolicy IndexingPolicy
Definition
ElementLinkTraits.h:197
SG::ElementLinkTraits::Base
ElementLinkTraits1< STORABLE >::Base Base
Definition
ElementLinkTraits.h:196
SG::ElementLinkTraits::Storable
STORABLE Storable
Definition
ElementLinkTraits.h:195
SG::ForwardIndexingPolicy
Indexing policy for a vector-like container.
Definition
ForwardIndexingPolicy.h:40
SG::GenericElementLinkBase
Generic base class for ElementLinks.
Definition
GenericElementLinkBase.h:77
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::GenerateIndexingPolicy::type
std::conditional< m_isSTLSequence, ForwardIndexingPolicy< CONTAINER >, typenameDefaultIndexingPolicy< CONTAINER >::type >::type type
Definition
GenerateIndexingPolicy.h:33
SG::IsSTLSequence::value
static const bool value
Definition
IsSTLSequence.h:64
Generated on
for ATLAS Offline Software by
1.17.0