dune-typetree  2.5-dev
Classes | Public Types | Static Public Member Functions | Static Public Attributes | List of all members
Dune::TypeTree::CompositeNode< Children > Class Template Reference

Base class for composite nodes based on variadic templates. More...

#include <dune/typetree/compositenode.hh>

Classes

struct  Child
 Access to the type and storage type of the i-th child. More...
 

Public Types

typedef CompositeNodeTag NodeTag
 The type tag that describes a CompositeNode. More...
 
typedef std::tuple< std::shared_ptr< Children >... > NodeStorage
 The type used for storing the children. More...
 
typedef std::tuple< Children... > ChildTypes
 A tuple storing the types of all children. More...
 

Public Member Functions

Child Access
template<std::size_t k>
Child< k >::Type & child (index_constant< k >={})
 Returns the i-th child. More...
 
template<std::size_t k>
const Child< k >::Type & child (index_constant< k >={}) const
 Returns the i-th child (const version). More...
 
template<std::size_t k>
Child< k >::Storage childStorage (index_constant< k >={})
 Returns the storage of the i-th child. More...
 
template<std::size_t k>
Child< k >::ConstStorage childStorage (index_constant< k >={}) const
 Returns the storage of the i-th child (const version). More...
 
template<std::size_t k>
void setChild (typename Child< k >::Type &child, index_constant< k >={})
 Sets the i-th child to the passed-in value. More...
 
template<std::size_t k>
void setChild (typename Child< k >::Type &&child, index_constant< k >={})
 Store the passed value in k-th child. More...
 
template<std::size_t k>
void setChild (typename Child< k >::Storage child, index_constant< k >={})
 Sets the storage of the i-th child to the passed-in value. More...
 
const NodeStoragenodeStorage () const
 
Nested Child Access
template<typename... Indices>
ImplementationDefined & child (Indices... indices)
 Returns the child given by the list of indices. More...
 
template<typename... Indices>
const ImplementationDefined & child (Indices... indices)
 Returns the child given by the list of indices. More...
 

Static Public Member Functions

static constexpr std::size_t degree ()
 

Static Public Attributes

static const bool isLeaf = false
 Mark this class as non leaf in the dune-typetree. More...
 
static const bool isPower = false
 Mark this class as a non power in the dune-typetree. More...
 
static const bool isComposite = true
 Mark this class as a composite in the dune-typetree. More...
 
static const std::size_t CHILDREN = sizeof...(Children)
 The number of children. More...
 

Protected Member Functions

Constructors
 CompositeNode ()
 Default constructor. More...
 
template<typename... Args, typename = typename std::enable_if<(sizeof...(Args) == CHILDREN)>::type>
 CompositeNode (Args &&... args)
 Initialize all children with the passed-in objects. More...
 
 CompositeNode (std::shared_ptr< Children >... children)
 Initialize the CompositeNode with copies of the passed in Storage objects. More...
 
 CompositeNode (const NodeStorage &children)
 Initialize the CompositeNode with a copy of the passed-in storage type. More...
 

Detailed Description

template<typename... Children>
class Dune::TypeTree::CompositeNode< Children >

Base class for composite nodes based on variadic templates.

Member Typedef Documentation

§ ChildTypes

template<typename... Children>
typedef std::tuple<Children...> Dune::TypeTree::CompositeNode< Children >::ChildTypes

A tuple storing the types of all children.

§ NodeStorage

template<typename... Children>
typedef std::tuple<std::shared_ptr<Children>... > Dune::TypeTree::CompositeNode< Children >::NodeStorage

The type used for storing the children.

§ NodeTag

template<typename... Children>
typedef CompositeNodeTag Dune::TypeTree::CompositeNode< Children >::NodeTag

The type tag that describes a CompositeNode.

Constructor & Destructor Documentation

§ CompositeNode() [1/4]

template<typename... Children>
Dune::TypeTree::CompositeNode< Children >::CompositeNode ( )
inlineprotected

Default constructor.

This constructor requires the storage type to be default constructible.

Warning
If the storage type is a pointer, the resulting object will not be usable before its children are set using any of the setChild(...) methods!

§ CompositeNode() [2/4]

template<typename... Children>
template<typename... Args, typename = typename std::enable_if<(sizeof...(Args) == CHILDREN)>::type>
Dune::TypeTree::CompositeNode< Children >::CompositeNode ( Args &&...  args)
inlineprotected

Initialize all children with the passed-in objects.

§ CompositeNode() [3/4]

template<typename... Children>
Dune::TypeTree::CompositeNode< Children >::CompositeNode ( std::shared_ptr< Children >...  children)
inlineprotected

Initialize the CompositeNode with copies of the passed in Storage objects.

§ CompositeNode() [4/4]

template<typename... Children>
Dune::TypeTree::CompositeNode< Children >::CompositeNode ( const NodeStorage children)
inlineprotected

Initialize the CompositeNode with a copy of the passed-in storage type.

Member Function Documentation

§ child() [1/4]

template<typename... Children>
template<std::size_t k>
Child<k>::Type& Dune::TypeTree::CompositeNode< Children >::child ( index_constant< k >  = {})
inline

Returns the i-th child.

Returns
a reference to the i-th child.

§ child() [2/4]

template<typename... Children>
template<std::size_t k>
const Child<k>::Type& Dune::TypeTree::CompositeNode< Children >::child ( index_constant< k >  = {}) const
inline

Returns the i-th child (const version).

Returns
a const reference to the i-th child.

§ child() [3/4]

template<typename... Children>
template<typename... Indices>
ImplementationDefined& Dune::TypeTree::CompositeNode< Children >::child ( Indices...  indices)
inline

Returns the child given by the list of indices.

This method simply forwards to the freestanding function child(). See that function for further information.

§ child() [4/4]

template<typename... Children>
template<typename... Indices>
const ImplementationDefined& Dune::TypeTree::CompositeNode< Children >::child ( Indices...  indices)
inline

Returns the child given by the list of indices.

This method simply forwards to the freestanding function child(). See that function for further information.

§ childStorage() [1/2]

template<typename... Children>
template<std::size_t k>
Child<k>::Storage Dune::TypeTree::CompositeNode< Children >::childStorage ( index_constant< k >  = {})
inline

Returns the storage of the i-th child.

Returns
a copy of the object storing the i-th child.

§ childStorage() [2/2]

template<typename... Children>
template<std::size_t k>
Child<k>::ConstStorage Dune::TypeTree::CompositeNode< Children >::childStorage ( index_constant< k >  = {}) const
inline

Returns the storage of the i-th child (const version).

This method is only important if the child is stored as some kind of pointer, as this allows the pointee type to become const.

Returns
a copy of the object storing the i-th child.

§ degree()

template<typename... Children>
static constexpr std::size_t Dune::TypeTree::CompositeNode< Children >::degree ( )
inlinestatic

§ nodeStorage()

template<typename... Children>
const NodeStorage& Dune::TypeTree::CompositeNode< Children >::nodeStorage ( ) const
inline

§ setChild() [1/3]

template<typename... Children>
template<std::size_t k>
void Dune::TypeTree::CompositeNode< Children >::setChild ( typename Child< k >::Type &  child,
index_constant< k >  = {} 
)
inline

Sets the i-th child to the passed-in value.

§ setChild() [2/3]

template<typename... Children>
template<std::size_t k>
void Dune::TypeTree::CompositeNode< Children >::setChild ( typename Child< k >::Type &&  child,
index_constant< k >  = {} 
)
inline

Store the passed value in k-th child.

§ setChild() [3/3]

template<typename... Children>
template<std::size_t k>
void Dune::TypeTree::CompositeNode< Children >::setChild ( typename Child< k >::Storage  child,
index_constant< k >  = {} 
)
inline

Sets the storage of the i-th child to the passed-in value.

Member Data Documentation

§ CHILDREN

template<typename... Children>
const std::size_t Dune::TypeTree::CompositeNode< Children >::CHILDREN = sizeof...(Children)
static

The number of children.

§ isComposite

template<typename... Children>
const bool Dune::TypeTree::CompositeNode< Children >::isComposite = true
static

Mark this class as a composite in the dune-typetree.

§ isLeaf

template<typename... Children>
const bool Dune::TypeTree::CompositeNode< Children >::isLeaf = false
static

Mark this class as non leaf in the dune-typetree.

§ isPower

template<typename... Children>
const bool Dune::TypeTree::CompositeNode< Children >::isPower = false
static

Mark this class as a non power in the dune-typetree.


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