Loading...
Searching...
No Matches
Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT > Class Template Reference

`#include <dune/common/parameterizedobject.hh>`

Inheritance diagram for Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >:

## Public Types

typedef KeyT | Key
| The typ of the keys.
using | Type = TypeT
| The type of objects created by the factory.

## Public Member Functions

Type | create (Key const &key, Args ... args) const
| Creates an object identified by a key from given parameters.
template<class Impl>
void | define (Key const &key)
| Registers a new type with a key.
template<class F, typename std::enable_if< has_proper_signature< F >(PriorityTag< 42 >()), int >::type = 0>
void | define (Key const &key, F &&f)
| Registers a new creator with a key.
template<class Impl, typename std::enable_if< std::is_convertible< Impl, Type >::value and not std::is_convertible< Impl, Creator >::value, int >::type = 0>
void | define (Key const &key, Impl &&t)
| Registers a new type with a key.
bool | contains (Key const &key) const

## Protected Types

using | Creator = std::function<Type(Args...)>

## Static Protected Member Functions

template<class F>
static constexpr auto | has_proper_signature (Dune::PriorityTag< 1 >) -> decltype(std::declval< F >()(std::declval< Args >()...), std::true_type())
template<class F>
static constexpr std::false_type | has_proper_signature (Dune::PriorityTag< 0 >)

## Member Typedef Documentation

## Creator

template<typename TypeT, typename KeyT, typename... Args>

using Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >::Creator = std::function<Type(Args...)>

protected

## Key

template<typename TypeT, typename KeyT, typename... Args>

typedef KeyT Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >::Key

The typ of the keys.

## Type

template<typename TypeT, typename KeyT, typename... Args>

using Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >::Type = TypeT

The type of objects created by the factory.

## Member Function Documentation

## contains()

template<typename TypeT, typename KeyT, typename... Args>

bool Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >::contains | ( | Key const & | key | ) | const

inline

## create()

template<typename TypeT, typename KeyT, typename... Args>

Type Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >::create | ( | Key const & | key,
|  | Args ... | args ) const

inline

Creates an object identified by a key from given parameters.

Parameters

  key | The key the object is registered with

See also
  define.

Parameters

  args | The parameters used for the construction.

Returns
  The object wrapped as Type

## define() [1/3]

template<typename TypeT, typename KeyT, typename... Args>
template<class Impl>

void Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >::define | ( | Key const & | key | ) |

inline

Registers a new type with a key.

After registration objects of this type can be constructed with the specified key using a matching default creation function. If Type is a unique_ptr or shared_ptr, the object is created via make_unique or make_shared, respectively. Otherwise a constructor of Impl is called.

Template Parameters

  Impl | The type of objects to create.

Parameters

  key | The key associated with this type.

## define() [2/3]

template<typename TypeT, typename KeyT, typename... Args>
template<class F, typename std::enable_if< has_proper_signature< F >(PriorityTag< 42 >()), int >::type = 0>

void Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >::define | ( | Key const & | key,
|  | F && | f )

inline

Registers a new creator with a key.

After registration objects can be constructed using the given creator function.

Template Parameters

  F | Type of creator function. This must be callable with Args... .

Parameters

  key | The key associated with this type.
  f | Function for creation of objects of type Impl

Todo
  Replace has_proper_signature by concept check

## define() [3/3]

template<typename TypeT, typename KeyT, typename... Args>
template<class Impl, typename std::enable_if< std::is_convertible< Impl, Type >::value and not std::is_convertible< Impl, Creator >::value, int >::type = 0>

void Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >::define | ( | Key const & | key,
|  | Impl && | t )

inline

Registers a new type with a key.

After registration objects of this type can be created. This method will store a copy of the given object and create will hand out a copy to this.

Template Parameters

  Impl | The type of objects to create.

Parameters

  key | The key associated with this type.
  t | reference object, "create" will call the copy-constructor

note, this does not work fundamental types

## has_proper_signature() [1/2]

template<typename TypeT, typename KeyT, typename... Args>
template<class F>

constexpr std::false_type Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >::has_proper_signature | ( | Dune::PriorityTag< 0 > |  | ) |

inline static constexpr protected

## has_proper_signature() [2/2]

template<typename TypeT, typename KeyT, typename... Args>
template<class F>

constexpr auto Dune::ParameterizedObjectFactory< TypeT(Args...), KeyT >::has_proper_signature | ( | Dune::PriorityTag< 1 > |  | ) | ->decltype(std::declval< F >()(std::declval< Args >()...), std::true_type())

inline static constexpr protected

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

- parameterizedobject.hh