ATLAS Offline Software
Public Types | Static Public Member Functions | List of all members
SG::DataBucketTrait< T, U > Struct Template Reference

Metafunction to find the proper DataBucket class for T. More...

#include <DataBucketTraitFwd.h>

Collaboration diagram for SG::DataBucketTrait< T, U >:

Public Types

typedef SG::BaseType< typename SG::Bases< T >::bases::Base1 >::type base1
 
typedef std::is_same< base1, SG::NoBase >::type has_base
 
typedef boost::mpl::identity< SG::DataBucket< U > > deflt
 
typedef DataBucketTrait< base1, U > recurse
 
typedef boost::mpl::eval_if< has_base, deflt, recurse >::type type
 

Static Public Member Functions

static void init ()
 Initialization hook. A no-op by default. More...
 

Detailed Description

template<class T, class U>
struct SG::DataBucketTrait< T, U >

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.

Member Typedef Documentation

◆ base1

template<class T , class U >
typedef SG::BaseType<typename SG::Bases<T>::bases::Base1>::type SG::DataBucketTrait< T, U >::base1

Definition at line 135 of file StorableConversions.h.

◆ deflt

template<class T , class U >
typedef boost::mpl::identity<SG::DataBucket<U> > SG::DataBucketTrait< T, U >::deflt

Definition at line 141 of file StorableConversions.h.

◆ has_base

template<class T , class U >
typedef std::is_same<base1, SG::NoBase>::type SG::DataBucketTrait< T, U >::has_base

Definition at line 138 of file StorableConversions.h.

◆ recurse

template<class T , class U >
typedef DataBucketTrait<base1, U> SG::DataBucketTrait< T, U >::recurse

Definition at line 144 of file StorableConversions.h.

◆ type

template<class T , class U >
typedef boost::mpl::eval_if<has_base, deflt, recurse>::type SG::DataBucketTrait< T, U >::type

Definition at line 149 of file StorableConversions.h.

Member Function Documentation

◆ init()

template<class T , class U >
static void SG::DataBucketTrait< T, U >::init ( )
inlinestatic

Initialization hook. A no-op by default.

Definition at line 152 of file StorableConversions.h.

152 {}

The documentation for this struct was generated from the following files: