ATLAS Offline Software
|
Metafunction to find the proper DataBucket
class for T
.
More...
#include <DataBucketTraitFwd.h>
Public Types | |
using | base1 = SG::BaseType_t< typename SG::Bases< T >::bases::Base1 > |
using | deflt = std::type_identity< SG::DataBucket< U > > |
using | recurse = DataBucketTrait< base1, U > |
using | type = typename std::conditional_t< has_base, deflt, recurse >::type |
Static Public Member Functions | |
static void | init () |
Initialization hook. A no-op by default. More... | |
Static Public Attributes | |
static constexpr bool | has_base = std::is_same_v<base1, SG::NoBase> |
Metafunction to find the proper DataBucket
class for T
.
See in Storable_conversions.h for full documentation.
Here's what we're trying to do.
The default DataBucket
class for T
is SG::DataBucket<T>
.
However, if T
is a DataVector
or DataList
, then we want to use instead SG::DVLDataBucket<T>
.
Further, if T
derives from DataVector
or DataList
(as declared by SG_BASES
), then we also want to use SG::DVLDataBucket<T>
.
Further, we don't want this code to depend on DataVector
or SG::DVLDataBucket
. That behavior is enabled only by including the appropriate DataVector/
.DataList
headers
So, we handle this with the following metafunction. (By saying that this is a ‘metafunction’, it means that the result is given by the nested type type
.) The T
argument is the type we're testing, and U
is the top-level type that was given to the original invocation of DataBucketTrait
. If T
has no bases (according to SG::Bases
), we return SG::DataBucket<U>
. Otherwise, we apply ourselves recursively to the first base class.
Other packages can then specialize this to change the behavior.
We don't really try to handle multiple bases. In principle, we could loop over them. But it seems that that's not really needed, so i don't want to pull in the extra overhead unnecessarily.
This class also defines a real static function init(). This is called from fromStorable
. It can be used to force instantiation of reflection information.
Definition at line 30 of file DataBucketTraitFwd.h.
using SG::DataBucketTrait< T, U >::base1 = SG::BaseType_t<typename SG::Bases<T>::bases::Base1> |
Definition at line 130 of file StorableConversions.h.
using SG::DataBucketTrait< T, U >::deflt = std::type_identity<SG::DataBucket<U> > |
Definition at line 136 of file StorableConversions.h.
using SG::DataBucketTrait< T, U >::recurse = DataBucketTrait<base1, U> |
Definition at line 139 of file StorableConversions.h.
using SG::DataBucketTrait< T, U >::type = typename std::conditional_t<has_base, deflt, recurse>::type |
Definition at line 142 of file StorableConversions.h.
|
inlinestatic |
Initialization hook. A no-op by default.
Definition at line 145 of file StorableConversions.h.
|
staticconstexpr |
Definition at line 133 of file StorableConversions.h.