![]() |
ATLAS Offline Software
|
Generic base class for ElementLinks. More...
#include <GenericElementLinkBase.h>
Public Types | |
| typedef INDEXING_POLICY::index_type | index_type |
| The index type presented to and returned from the link. | |
| typedef INDEXING_POLICY::stored_index_type | stored_index_type |
| The type of the index as it is stored internally. | |
| typedef SG::DataProxyHolder::sgkey_t | sgkey_t |
| Type of hashed keys. | |
| typedef SG::DataProxyHolder::ID_type | ID_type |
| Type of string keys. | |
| typedef void * | castfn_t(SG::DataProxy *) |
Function casting from a SG::DataProxy to a pointer. | |
Public Member Functions | |
| bool | isDefaultIndex () const |
| Test the index validity. | |
| bool | hasCachedElement () const |
| Test to see if this link has a cached element pointer. | |
| bool | isDefault () const |
| Test to see if this link is in the default state. | |
| index_type | index () const |
| Return the index of the link. | |
| const ID_type & | dataID () const |
| Return the SG key that we reference, as a string. | |
| sgkey_t | key () const |
| Return the SG key that we reference, as a hash. | |
| IProxyDict * | source () const |
| Return the data source for this reference. | |
| const SG::DataProxy * | proxy () const |
| Return the SG proxy for the container holding this element. | |
| void | reset () |
| Reset the link to a null state. | |
| bool | toTransient (IProxyDict *sg=0) |
| Finish initialization after link has been read. | |
| bool | toPersistent () |
| Prepare this link for writing. | |
| bool | thin () |
| Adjust for thinning. | |
| bool | thin (const SG::ThinningCache *thinningCache) |
| Adjust for thinning. | |
Protected Member Functions | |
| GenericElementLinkBase () | |
| Default constructor. | |
| GenericElementLinkBase (const ID_type &dataID, CLID link_clid, const index_type &elemID, IProxyDict *sg) | |
| Construct a link from a string key and an index. | |
| GenericElementLinkBase (sgkey_t key, CLID link_clid, const index_type &elemID, IProxyDict *sg) | |
| Construct a link from a hashed key and an index. | |
| GenericElementLinkBase (const ID_type &dataID, CLID link_clid, const index_type &elemID, const ElementType &elt, IProxyDict *sg) | |
| Construct a link from a string key, index, AND pointer to element. | |
| GenericElementLinkBase (sgkey_t key, CLID link_clid, const index_type &elemID, const ElementType &elt, IProxyDict *sg) | |
| Construct a link from a hashed key, index, AND pointer to element. | |
| GenericElementLinkBase (const_pointer_t obj, CLID link_clid, const index_type &elemID, IProxyDict *sg) | |
| Construct a link from an index and pointer to the container. | |
| GenericElementLinkBase (const GenericElementLinkBase &other, const index_type &elemID) | |
| Construct a link from another link, changing the index. | |
| GenericElementLinkBase (const DataLinkBase &dlink, const index_type &index) | |
| Construct a link from a DataLink and an index. | |
| template<class OTHER_INDEXING_POLICY, class FROM_TRAITS, class TO_TRAITS> | |
| GenericElementLinkBase (const GenericElementLinkBase< OTHER_INDEXING_POLICY > &other, FROM_TRAITS *, TO_TRAITS *) | |
| Constructor from a link referencing a different type. | |
| GenericElementLinkBase (const GenericElementLinkBase &)=default | |
| GenericElementLinkBase & | operator= (const GenericElementLinkBase &)=default |
| void * | storableBase (castfn_t *castfn, const CLID &clid, bool isConst) const |
| Return a pointer to the currently-referenced container object. | |
| bool | setStorableObject (const_pointer_t data, CLID link_clid, bool replace, IProxyDict *sg) |
Set the container referenced by the link to data. | |
| bool | toIndexedElement (const_pointer_t obj, CLID link_clid, const index_type &elemID, IProxyDict *sg) |
| Set the to an element given by index and pointer to container. | |
| void | resetWithKeyAndIndex (const ID_type &dataID, CLID link_clid, const index_type &elemID, IProxyDict *sg) |
| Set the link to an element given by string key and index. | |
| void | resetWithKeyAndIndex (sgkey_t key, CLID link_clid, const index_type &elemID, IProxyDict *sg) |
| Set the link to an element given by string key and index. | |
| void | setIndex (const index_type &index) |
| Set the index part of the link. | |
| const stored_index_type & | storedIndex () const |
| Return the stored representation of the link index. | |
| void | setCachedElement (const ElementType &elt) const |
| Set the cached element stored in the link. | |
| void | storeCachedElement (const ElementType &elt) |
| Set the cached element stored in the link. | |
| bool | getCachedElement (ElementConstPointer &elt) const |
| Retrieve the cached element from the link. | |
| const SG::DataProxyHolder & | proxyHolder () const |
| Return the internal proxy holder object. | |
Private Types | |
| typedef INDEXING_POLICY::ElementType | ElementType |
| Generic pointer to an element. | |
| typedef INDEXING_POLICY::ElementConstPointer | ElementConstPointer |
| typedef SG::DataProxyHolder::const_pointer_t | const_pointer_t |
| Generic pointer to the container (storable). | |
| typedef ROOT::Meta::Selection::SG::GenericElementLinkBase< INDEXING_POLICY >::self | DictSel |
| Transient. | |
Private Member Functions | |
| template<class INDEX> requires (std::convertible_to<INDEX, size_t> && std::convertible_to<size_t, INDEX>) | |
| bool | thin1 (INDEX &persIndex, const SG::ThinningCache *thinningCache) |
| Adjust for thinning. | |
| template<class INDEX> requires (!(std::convertible_to<INDEX, size_t> && std::convertible_to<size_t, INDEX>)) | |
| bool | thin1 (INDEX &persIndex, const SG::ThinningCache *thinningCache) |
| Adjust for thinning. | |
Private Attributes | |
| SG::sgkey_t | m_key |
| The hashed key for this link. | |
| stored_index_type | m_index |
| The index of the element within the container for this link. | |
| SG::DataProxyHolder | m_proxy |
| SG proxy for this link. | |
| CxxUtils::CachedValue< ElementType > | m_element |
| Transient. | |
Friends | |
| template<class OTHER_POLICY> | |
| class | GenericElementLinkBase |
| template<class POLICY> | |
| class | ::ElementLinkBaseT_test |
| For regression testing. | |
Generic base class for ElementLinks.
The part of ElementLink that doesn't directly depend on the particular container class is factored out here. We do, however, need to know both the index and element types. We get these from the indexing policy (so we do have an indirect dependence on the container type).
This class holds all the state of the ElementLink. The persistent part is the hashed SG key of the container and the index of the element within the container. We also store a transient DataProxyHolder, which encapsulates the pointer to the DataProxy and factors out code shared with DataLink. Further, we store a (transient and mutable) copy of the element to which this link refers, as well as a flag to tell if the cached element is valid.
The main reason for breaking out the base class like this is that for the common case where the container has vector-like indexing and the element is a pointer type we actually use the non-templated class ElementLinkBase instead of this one. ElementLinkBase is essentially the same as this, but specialized for the case of the index being an unsigned int and the element being a pointer. This factorization makes direct ROOT persistency easier for this common case.
See ElementLinkTraits.h for a summary of the requirements for these base classes.
Definition at line 76 of file GenericElementLinkBase.h.
| typedef void * SG::GenericElementLinkBase< INDEXING_POLICY >::castfn_t(SG::DataProxy *) |
Function casting from a SG::DataProxy to a pointer.
Definition at line 101 of file GenericElementLinkBase.h.
|
private |
Generic pointer to the container (storable).
Definition at line 84 of file GenericElementLinkBase.h.
|
private |
|
private |
Definition at line 81 of file GenericElementLinkBase.h.
|
private |
Generic pointer to an element.
Definition at line 80 of file GenericElementLinkBase.h.
| typedef SG::DataProxyHolder::ID_type SG::GenericElementLinkBase< INDEXING_POLICY >::ID_type |
Type of string keys.
Definition at line 98 of file GenericElementLinkBase.h.
| typedef INDEXING_POLICY::index_type SG::GenericElementLinkBase< INDEXING_POLICY >::index_type |
The index type presented to and returned from the link.
Definition at line 89 of file GenericElementLinkBase.h.
| typedef SG::DataProxyHolder::sgkey_t SG::GenericElementLinkBase< INDEXING_POLICY >::sgkey_t |
Type of hashed keys.
Definition at line 95 of file GenericElementLinkBase.h.
| typedef INDEXING_POLICY::stored_index_type SG::GenericElementLinkBase< INDEXING_POLICY >::stored_index_type |
The type of the index as it is stored internally.
Definition at line 92 of file GenericElementLinkBase.h.
|
protected |
Default constructor.
Makes a null link.
|
protected |
Construct a link from a string key and an index.
| dataID | Key of the object. |
| link_clid | CLID of the link being set. |
| elemID | The index of the element within the container. |
| sg | Associated store. |
If sg is 0, we take the global default.
|
protected |
Construct a link from a hashed key and an index.
| key | Hashed key of the object. |
| link_clid | CLID of the link being set. |
| elemID | The index of the element within the container. |
| sg | Associated store. |
If sg is 0, we take the global default.
|
protected |
Construct a link from a string key, index, AND pointer to element.
| dataID | Key of the object. |
| link_clid | CLID of the link being set. |
| elemID | The index of the element within the container. |
| elt | Pointer to the element. |
| sg | Associated store. |
USE CAREFULLY: no coherency checks, we just trust you!
If sg is 0, we take the global default.
|
protected |
Construct a link from a hashed key, index, AND pointer to element.
| key | Hashed key of the object. |
| link_clid | CLID of the link being set. |
| elemID | The index of the element within the container. |
| elt | Pointer to the element. |
| sg | Associated store. |
USE CAREFULLY: no coherency checks, we just trust you!
If sg is 0, we take the global default.
|
protected |
Construct a link from an index and pointer to the container.
| obj | Pointer to the container (storable). |
| link_clid | CLID of the link being set. |
| elemID | The index of the element within the container. |
| sg | Associated store. |
If sg is 0, we take the global default.
|
protected |
Construct a link from another link, changing the index.
| other | The source link. |
| elemID | The index for the new link. |
The index being constructed will reference the same container as other, but it will refer to element elemID.
|
protected |
Construct a link from a DataLink and an index.
| dlink | Link to the container. |
| index | The index of the element within the container. |
|
protected |
Constructor from a link referencing a different type.
| other | The object from which to copy. |
FROM_TRAITS is the ElementLinkTraits class for other; TO_TRAITS is the traits class for this object. The actual pointer values are not used, just the types are used. Default conversions for the storable pointer (i.e., derived->base) are allowed.
|
protecteddefault |
| const ID_type & SG::GenericElementLinkBase< INDEXING_POLICY >::dataID | ( | ) | const |
Return the SG key that we reference, as a string.
Returns a null string on failure.
|
protected |
Retrieve the cached element from the link.
| elt[out] | The cached element. |
elt is left unmodified if there is no cached element.
| bool SG::GenericElementLinkBase< INDEXING_POLICY >::hasCachedElement | ( | ) | const |
Test to see if this link has a cached element pointer.
| index_type SG::GenericElementLinkBase< INDEXING_POLICY >::index | ( | ) | const |
Return the index of the link.
| bool SG::GenericElementLinkBase< INDEXING_POLICY >::isDefault | ( | ) | const |
Test to see if this link is in the default state.
| bool SG::GenericElementLinkBase< INDEXING_POLICY >::isDefaultIndex | ( | ) | const |
Test the index validity.
| sgkey_t SG::GenericElementLinkBase< INDEXING_POLICY >::key | ( | ) | const |
Return the SG key that we reference, as a hash.
Returns 0 on failure.
|
protecteddefault |
| const SG::DataProxy * SG::GenericElementLinkBase< INDEXING_POLICY >::proxy | ( | ) | const |
Return the SG proxy for the container holding this element.
If this is a null link, we return 0. If we're directly referencing an object that's not in StoreGate, either return 0 or throw ExcPointerNotInSG, depending on nothrow. Otherwise, return the proxy for the object we're referencing.
|
protected |
Return the internal proxy holder object.
| void SG::GenericElementLinkBase< INDEXING_POLICY >::reset | ( | ) |
Reset the link to a null state.
|
protected |
Set the link to an element given by string key and index.
| dataID | Key of the object. |
| link_clid | CLID of the link being set. |
| elemID | The index of the element within the container. |
| sg | Associated store. |
If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.
|
protected |
Set the link to an element given by string key and index.
| key | Hashed key of the object. |
| link_clid | CLID of the link being set. |
| elemID | The index of the element within the container. |
| sg | Associated store. |
If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.
|
protected |
Set the cached element stored in the link.
| elt | New value for the cached element. |
|
protected |
Set the index part of the link.
| index | New index value. |
|
protected |
Set the container referenced by the link to data.
| data | Pointer to the new container. |
| link_clid | CLID of the link being set. |
| replace | True if we can change an existing link. |
| sg | Associated store. |
If the link is already set, this will return false and leave the link unchanged unless replace is set. The replace argument should be set if the element is now in a new storable container; e.g. element ptr has been put in a new view container.
If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.
| IProxyDict * SG::GenericElementLinkBase< INDEXING_POLICY >::source | ( | ) | const |
Return the data source for this reference.
|
protected |
Return a pointer to the currently-referenced container object.
| castfn | Function to do the cast from data proxy to object. If 0, use a dynamic cast. |
| clid | The CLID of the desired object. This is used to determine how the returned pointer is to be converted. |
| isConst | True if the returned object will be treated as const. |
|
protected |
Set the cached element stored in the link.
| elt | New value for the cached element. |
|
protected |
Return the stored representation of the link index.
| bool SG::GenericElementLinkBase< INDEXING_POLICY >::thin | ( | ) |
Adjust for thinning.
If this link points to a container that has been thinned, it will be adjusted accordingly.
Returns true if the link was changed; false otherwise.
| bool SG::GenericElementLinkBase< INDEXING_POLICY >::thin | ( | const SG::ThinningCache * | thinningCache | ) |
Adjust for thinning.
If this link points to a container that has been thinned, it will be adjusted accordingly.
| thinningCache | Thinning cache for the current stream (may be null). |
Returns true if the link was changed; false otherwise.
|
private |
Adjust for thinning.
If this link points to a container that has been thinned, it will be adjusted accordingly.
| Index | of the element. |
| thinningCache | Thinning cache for the current stream (may be null). |
Returns true if the link was changed; false otherwise.
This overload will be used for the case where thinning is supported: the index can be interconverted with size_t.
|
private |
Adjust for thinning.
If this link points to a container that has been thinned, it will be adjusted accordingly.
| Index | of the element. |
| thinningCache | Thinning cache for the current stream (may be null). |
Returns true if the link was changed; false otherwise.
This overload will be used for the case where thinning is not supported.
|
protected |
Set the to an element given by index and pointer to container.
| obj | Pointer to the container (storable). |
| link_clid | CLID of the link being set. |
| elemID | The index of the element within the container. |
| sg | Associated store. |
If the link is already set, this will return false and leave the link unchanged.
If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.
| bool SG::GenericElementLinkBase< INDEXING_POLICY >::toPersistent | ( | ) |
Prepare this link for writing.
This method should be called before trying to write the link with root. It will make sure the persistent fields of the link are valid. It will also perform remapping if needed.
Will return true on success. Will return false if either the container or the element index has not been specified. Will throw ExcPointerNotInSG if the link is referencing a container that is not in SG.
| bool SG::GenericElementLinkBase< INDEXING_POLICY >::toTransient | ( | IProxyDict * | sg = 0 | ) |
Finish initialization after link has been read.
| sg | Associated store. |
This should be called after a link has been read by root in order to set the proxy pointer. Returns true.
If sg is 0, then we use the global default store.
For regression testing.
Definition at line 532 of file GenericElementLinkBase.h.
|
friend |
Definition at line 528 of file GenericElementLinkBase.h.
|
private |
|
private |
The index of the element within the container for this link.
Definition at line 538 of file GenericElementLinkBase.h.
|
private |
The hashed key for this link.
Definition at line 535 of file GenericElementLinkBase.h.
|
private |
SG proxy for this link.
Definition at line 541 of file GenericElementLinkBase.h.