Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
Sacado::TemplateContainer< TypeSeq, ObjectT > Class Template Reference

Container class to manager template instantiations of a template class. More...

#include <Sacado_TemplateContainer.hpp>

Classes

struct  BuildObject
 Helper class for building objects in container. More...
 
struct  DefaultBuilderOp
 The default builder class for building objects for each ScalarT. More...
 

Public Types

typedef TypeSeq types
 Type sequence containing template types. More...
 

Public Member Functions

 TemplateContainer ()
 Default constructor. More...
 
 ~TemplateContainer ()
 Destructor. More...
 
template<typename T >
Sacado::mpl::apply< ObjectT, T >
::type & 
get ()
 Get object corrensponding ObjectT<T> More...
 
template<typename T >
const Sacado::mpl::apply
< ObjectT, T >::type & 
get () const
 Get object corrensponding ObjectT<T> More...
 
template<typename BuilderOpT = DefaultBuilderOp>
void build (const BuilderOpT &builder)
 Build objects for each type T. More...
 

Private Types

typedef Impl::TupleSeq
< TypeSeq, ObjectT > 
tuple_type
 Our container for storing each object. More...
 

Private Attributes

tuple_type objects
 Stores type of objects of each type. More...
 

Detailed Description

template<typename TypeSeq, typename ObjectT>
class Sacado::TemplateContainer< TypeSeq, ObjectT >

Container class to manager template instantiations of a template class.

This class provides a generic container class for managing multiple instantiations of a class ObjectT<T> with the values of T specified through a type sequence. Objects of type ObjectT<T> must have value semantics, be default constructable and copyable/assignable (for objects that don't satisfy these requirements, one would typically wrap them in a (smart) pointer. Methods are provided to access the object of type ObjectT<T> for a given type T, as well as initialize them. One would typically operate on the contained objects using mpl::for_each(), e.g.,

template <class t>=""> class MyClass; typedef mpl::vector< double, Fad::DFad<double> > MyTypes; typedef TemplateContainer< MyTypes, MyClass<_> > MyObjects; MyObjects myObjects; mpl::for_each<MyObjects>([](auto x) { typedef decltype(x) T; myObjects.get<T>() = T; });

(Note: This requires generalized lambda's introduced in C++14. For C++11, provide a functor that implements the lambda body).

Definition at line 96 of file Sacado_TemplateContainer.hpp.

Member Typedef Documentation

template<typename TypeSeq, typename ObjectT>
typedef Impl::TupleSeq<TypeSeq, ObjectT> Sacado::TemplateContainer< TypeSeq, ObjectT >::tuple_type
private

Our container for storing each object.

Definition at line 99 of file Sacado_TemplateContainer.hpp.

template<typename TypeSeq, typename ObjectT>
typedef TypeSeq Sacado::TemplateContainer< TypeSeq, ObjectT >::types

Type sequence containing template types.

Definition at line 117 of file Sacado_TemplateContainer.hpp.

Constructor & Destructor Documentation

template<typename TypeSeq, typename ObjectT>
Sacado::TemplateContainer< TypeSeq, ObjectT >::TemplateContainer ( )
inline

Default constructor.

Definition at line 131 of file Sacado_TemplateContainer.hpp.

template<typename TypeSeq, typename ObjectT>
Sacado::TemplateContainer< TypeSeq, ObjectT >::~TemplateContainer ( )
inline

Destructor.

Definition at line 134 of file Sacado_TemplateContainer.hpp.

Member Function Documentation

template<typename TypeSeq, typename ObjectT>
template<typename T >
Sacado::mpl::apply<ObjectT,T>::type& Sacado::TemplateContainer< TypeSeq, ObjectT >::get ( )
inline

Get object corrensponding ObjectT<T>

Definition at line 138 of file Sacado_TemplateContainer.hpp.

template<typename TypeSeq, typename ObjectT>
template<typename T >
const Sacado::mpl::apply<ObjectT,T>::type& Sacado::TemplateContainer< TypeSeq, ObjectT >::get ( ) const
inline

Get object corrensponding ObjectT<T>

Definition at line 144 of file Sacado_TemplateContainer.hpp.

template<typename TypeSeq, typename ObjectT>
template<typename BuilderOpT = DefaultBuilderOp>
void Sacado::TemplateContainer< TypeSeq, ObjectT >::build ( const BuilderOpT &  builder)
inline

Build objects for each type T.

Definition at line 150 of file Sacado_TemplateContainer.hpp.

Member Data Documentation

template<typename TypeSeq, typename ObjectT>
tuple_type Sacado::TemplateContainer< TypeSeq, ObjectT >::objects
private

Stores type of objects of each type.

Definition at line 158 of file Sacado_TemplateContainer.hpp.


The documentation for this class was generated from the following file: