dune-typetree  3.0-dev
Classes | Public Types | Static Public Member Functions | Static Public Attributes | List of all members
Dune::TypeTree::PowerNode< T, k > Class Template Reference

Collect k instances of type T within a dune-typetree. More...

#include <dune/typetree/powernode.hh>

Classes

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

Public Types

typedef PowerNodeTag NodeTag
 The type tag that describes a PowerNode. More...
 
typedef T ChildType
 The type of each child. More...
 
typedef shared_ptr< T > ChildStorageType
 The storage type of each child. More...
 
typedef shared_ptr< const T > ChildConstStorageType
 The const version of the storage type of each child. More...
 
typedef std::array< ChildStorageType, k > NodeStorage
 The type used for storing the children. More...
 

Public Member Functions

Child Access (templated methods)
template<std::size_t i>
T & child (index_constant< i >={})
 Returns the i-th child. More...
 
template<std::size_t i>
const T & child (index_constant< i >={}) const
 Returns the i-th child (const version). More...
 
template<std::size_t i>
ChildStorageType childStorage (index_constant< i >={})
 Returns the storage of the i-th child. More...
 
template<std::size_t i>
ChildConstStorageType childStorage (index_constant< i >={}) const
 Returns the storage of the i-th child (const version). More...
 
template<std::size_t i>
void setChild (T &t, index_constant< i >={})
 Sets the i-th child to the passed-in value. More...
 
template<std::size_t i>
void setChild (T &&t, index_constant< i >={})
 Store the passed value in i-th child. More...
 
template<std::size_t i>
void setChild (ChildStorageType st, index_constant< i >={})
 Sets the stored value representing the i-th child to the passed-in value. More...
 
Child Access (Dynamic methods)
T & child (std::size_t i)
 Returns the i-th child. More...
 
const T & child (std::size_t i) const
 Returns the i-th child (const version). More...
 
ChildStorageType childStorage (std::size_t i)
 Returns the storage of the i-th child. More...
 
ChildConstStorageType childStorage (std::size_t i) const
 Returns the storage of the i-th child (const version). More...
 
void setChild (std::size_t i, T &t)
 Sets the i-th child to the passed-in value. More...
 
void setChild (std::size_t i, T &&t)
 Store the passed value in i-th child. More...
 
void setChild (std::size_t i, ChildStorageType st)
 Sets the stored value representing 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 = true
 Mark this class as a power in the dune-typetree. More...
 
static const bool isComposite = false
 Mark this class as a non composite in the dune-typetree. More...
 
static const std::size_t CHILDREN = k
 The number of children. More...
 

Protected Member Functions

Constructors
 PowerNode ()
 Default constructor. More...
 
 PowerNode (const NodeStorage &children)
 Initialize the PowerNode with a copy of the passed-in storage type. More...
 
 PowerNode (T &t, bool distinct_objects=true)
 Initialize all children with copies of a storage object constructed from the parameter t. More...
 
 PowerNode (T &t1, T &t2,...)
 Initialize all children with the passed-in objects. More...
 

Detailed Description

template<typename T, std::size_t k>
class Dune::TypeTree::PowerNode< T, k >

Collect k instances of type T within a dune-typetree.

Template Parameters
TThe base type
kThe number of instances this node should collect

Member Typedef Documentation

◆ ChildConstStorageType

template<typename T , std::size_t k>
typedef shared_ptr<const T> Dune::TypeTree::PowerNode< T, k >::ChildConstStorageType

The const version of the storage type of each child.

◆ ChildStorageType

template<typename T , std::size_t k>
typedef shared_ptr<T> Dune::TypeTree::PowerNode< T, k >::ChildStorageType

The storage type of each child.

◆ ChildType

template<typename T , std::size_t k>
typedef T Dune::TypeTree::PowerNode< T, k >::ChildType

The type of each child.

◆ NodeStorage

template<typename T , std::size_t k>
typedef std::array<ChildStorageType,k> Dune::TypeTree::PowerNode< T, k >::NodeStorage

The type used for storing the children.

◆ NodeTag

template<typename T , std::size_t k>
typedef PowerNodeTag Dune::TypeTree::PowerNode< T, k >::NodeTag

The type tag that describes a PowerNode.

Constructor & Destructor Documentation

◆ PowerNode() [1/4]

template<typename T , std::size_t k>
Dune::TypeTree::PowerNode< T, k >::PowerNode ( )
inlineprotected

Default constructor.

The default constructor is protected, as PowerNode is a utility class that needs to be filled with meaning by subclassing it and adding useful functionality to the subclass.

Warning
When using the default constructor, make sure to set ALL children by means of the setChild() methods!

◆ PowerNode() [2/4]

template<typename T , std::size_t k>
Dune::TypeTree::PowerNode< T, k >::PowerNode ( const NodeStorage children)
inlineexplicitprotected

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

◆ PowerNode() [3/4]

template<typename T , std::size_t k>
Dune::TypeTree::PowerNode< T, k >::PowerNode ( T &  t,
bool  distinct_objects = true 
)
inlineexplicitprotected

Initialize all children with copies of a storage object constructed from the parameter t.

◆ PowerNode() [4/4]

template<typename T , std::size_t k>
Dune::TypeTree::PowerNode< T, k >::PowerNode ( T &  t1,
T &  t2,
  ... 
)
inlineprotected

Initialize all children with the passed-in objects.

The availability of this constructor depends on the number of children and compiler support for C++0x: For 1 <= k <= 10, it is always present, but for k > 10, it requires C++0x support in the compiler. If your compiler doesn't, use PowerNode(const Storage& children) instead.

Moreover, the C++0x-based version also supports passing in temporary objects and will move those objects into the node. Attempting to do so with the legacy version will result in a compile error.

Member Function Documentation

◆ child() [1/6]

template<typename T , std::size_t k>
template<std::size_t i>
T& Dune::TypeTree::PowerNode< T, k >::child ( index_constant< i >  = {})
inline

Returns the i-th child.

Returns
a reference to the i-th child.

◆ child() [2/6]

template<typename T , std::size_t k>
template<std::size_t i>
const T& Dune::TypeTree::PowerNode< T, k >::child ( index_constant< i >  = {}) const
inline

Returns the i-th child (const version).

Returns
a const reference to the i-th child.

◆ child() [3/6]

template<typename T , std::size_t k>
template<typename... Indices>
ImplementationDefined& Dune::TypeTree::PowerNode< T, k >::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/6]

template<typename T , std::size_t k>
template<typename... Indices>
const ImplementationDefined& Dune::TypeTree::PowerNode< T, k >::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() [5/6]

template<typename T , std::size_t k>
T& Dune::TypeTree::PowerNode< T, k >::child ( std::size_t  i)
inline

Returns the i-th child.

Returns
a reference to the i-th child.

◆ child() [6/6]

template<typename T , std::size_t k>
const T& Dune::TypeTree::PowerNode< T, k >::child ( std::size_t  i) const
inline

Returns the i-th child (const version).

Returns
a const reference to the i-th child.

◆ childStorage() [1/4]

template<typename T , std::size_t k>
template<std::size_t i>
ChildStorageType Dune::TypeTree::PowerNode< T, k >::childStorage ( index_constant< i >  = {})
inline

Returns the storage of the i-th child.

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

◆ childStorage() [2/4]

template<typename T , std::size_t k>
template<std::size_t i>
ChildConstStorageType Dune::TypeTree::PowerNode< T, k >::childStorage ( index_constant< i >  = {}) 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.

◆ childStorage() [3/4]

template<typename T , std::size_t k>
ChildStorageType Dune::TypeTree::PowerNode< T, k >::childStorage ( std::size_t  i)
inline

Returns the storage of the i-th child.

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

◆ childStorage() [4/4]

template<typename T , std::size_t k>
ChildConstStorageType Dune::TypeTree::PowerNode< T, k >::childStorage ( std::size_t  i) 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 T , std::size_t k>
static constexpr std::size_t Dune::TypeTree::PowerNode< T, k >::degree ( )
inlinestaticconstexpr

◆ nodeStorage()

template<typename T , std::size_t k>
const NodeStorage& Dune::TypeTree::PowerNode< T, k >::nodeStorage ( ) const
inline

◆ setChild() [1/6]

template<typename T , std::size_t k>
template<std::size_t i>
void Dune::TypeTree::PowerNode< T, k >::setChild ( ChildStorageType  st,
index_constant< i >  = {} 
)
inline

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

◆ setChild() [2/6]

template<typename T , std::size_t k>
void Dune::TypeTree::PowerNode< T, k >::setChild ( std::size_t  i,
ChildStorageType  st 
)
inline

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

◆ setChild() [3/6]

template<typename T , std::size_t k>
void Dune::TypeTree::PowerNode< T, k >::setChild ( std::size_t  i,
T &&  t 
)
inline

Store the passed value in i-th child.

◆ setChild() [4/6]

template<typename T , std::size_t k>
void Dune::TypeTree::PowerNode< T, k >::setChild ( std::size_t  i,
T &  t 
)
inline

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

◆ setChild() [5/6]

template<typename T , std::size_t k>
template<std::size_t i>
void Dune::TypeTree::PowerNode< T, k >::setChild ( T &&  t,
index_constant< i >  = {} 
)
inline

Store the passed value in i-th child.

◆ setChild() [6/6]

template<typename T , std::size_t k>
template<std::size_t i>
void Dune::TypeTree::PowerNode< T, k >::setChild ( T &  t,
index_constant< i >  = {} 
)
inline

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

Member Data Documentation

◆ CHILDREN

template<typename T , std::size_t k>
const std::size_t Dune::TypeTree::PowerNode< T, k >::CHILDREN = k
static

The number of children.

◆ isComposite

template<typename T , std::size_t k>
const bool Dune::TypeTree::PowerNode< T, k >::isComposite = false
static

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

◆ isLeaf

template<typename T , std::size_t k>
const bool Dune::TypeTree::PowerNode< T, k >::isLeaf = false
static

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

◆ isPower

template<typename T , std::size_t k>
const bool Dune::TypeTree::PowerNode< T, k >::isPower = true
static

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


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