Skip to content

Configurator

template <class BaseClass> class Configurator

@brief The Configurator provides for creating and configuring factorized classes.

Functions

Name Description
registerClass Register a base class with standard Hash configuration constructor into the factory classId : identifying the class in the factory
registerClass Register a class having constructor with additional A1 type parameter (besides the standard Hash configuration) into the factory classId : identifying the class in the factory
registerSchemaFunction Register the schema decription function for classId in the factory classId : identifying the class in the factory
registerSchemaFunctions Register the schema decription functions for classId in the factory The parameter pack 'A' typically is the list of all the classes in the inheritance chain of 'classId', including itself at the end.
setDefault Set the default class id of the factory classId :
getSchema Get the schema defining a factorized class classId : identifying the class in the factory rules : defining how to assembly the returned Schema Return :
createDefault Create an Object of the default class of this factory validate : Return : a pointer to the created object
create Create an object as described by configuration from the factory configuration : where the root-nodes key identifies the classId validate : if true, validate the configuration against the classes Schema. Raises an exception if validation fails Return : a pointer to the created object
create Create an object of classId from the factory, assign default values as given by the class Schema configuration : Hash containing the configuration validate : if true, validate the configuration against the classes Schema. Raises an exception if validation fails Return : a pointer to the created object
create Create an object as described by configuration from the factory configuration : where the root-nodes key identifies the classId arbitrary : type parameter to be passed to the constructor validate : if true, validate the configuration against the classes Schema. Raises an exception if validation fails Return : a pointer to the base class of created object
create Create an object of classId as described by configuration from the factory configuration : Hash containing the configuration arbitrary : type parameter to be passed to the constructor validate : if true, validate the configuration against the classes Schema. Raises an exception if validation fails Return : a pointer to the base class of created object
createNode Use this function to create a configurable object as part of a parent one (aggregation).
createNode Use this function to create a configurable object of class template type as part of a parent one (aggregation).
createChoice Create object from a choice of factorized classes as defined by choiceName from input configuration choiceName : input : validate : Return :
createList Create a list of factorized classes as defined by input configuration.
getRegisteredClasses Return a vector of classIds registered in this Configurator Return :
validateConfiguration Trigger a validation of class BaseClass (or a derivative) against the Schema as provided by the static expectedParameters function NOTE: During regular factory construction validation already is done (if validate==true) * classId : The factory key of the to be created object (must inherit the BaseClass template) configuration : A hash that is checked against the expectedParameters requirements validated : The resultant validated hash (has defaults injected)

Function Details

create

inline static typename BaseClass::Pointer create(const karabo::data::Hash& configuration, const bool validate = true)

Create an object as described by configuration from the factory

configuration : where the root-nodes key identifies the classId

validate : if true, validate the configuration against the classes Schema. Raises an exception if validation fails

Return : a pointer to the created object

inline static typename BaseClass::Pointer create(const std::string& classId, const karabo::data::Hash& configuration = Hash(), const bool validate = true)

Create an object of classId from the factory, assign default values as given by the class Schema

configuration : Hash containing the configuration

validate : if true, validate the configuration against the classes Schema. Raises an exception if validation fails

Return : a pointer to the created object

template <typename A1> inline static typename BaseClass::Pointer create(const karabo::data::Hash& configuration, const A1& a1, const bool validate = true)

Create an object as described by configuration from the factory

configuration : where the root-nodes key identifies the classId

arbitrary : type parameter to be passed to the constructor

validate : if true, validate the configuration against the classes Schema. Raises an exception if validation fails

Return : a pointer to the base class of created object

template <typename A1> inline static typename BaseClass::Pointer create(const std::string& classId, const karabo::data::Hash& configuration, const A1& a1, const bool validate = true)

Create an object of classId as described by configuration from the factory

configuration : Hash containing the configuration

arbitrary : type parameter to be passed to the constructor

validate : if true, validate the configuration against the classes Schema. Raises an exception if validation fails

Return : a pointer to the base class of created object

createChoice

inline static typename BaseClass::Pointer createChoice(const std::string& choiceName, const karabo::data::Hash& input, const bool validate = true)

Create object from a choice of factorized classes as defined by choiceName from input configuration

choiceName :

input :

validate :

Return :

createDefault

inline static typename BaseClass::Pointer createDefault(const bool validate = true)

Create an Object of the default class of this factory

validate :

Return : a pointer to the created object

createList

inline static std::vector<typename BaseClass::Pointer> createList(const std::string& listName, const karabo::data::Hash& input, const bool validate = true)

Create a list of factorized classes as defined by input configuration. Classes need to be of the same Base class

choiceName :

input :

validate :

Return :

createNode

inline static typename BaseClass::Pointer createNode(const std::string& nodeName, const std::string& classId, const karabo::data::Hash& input, const bool validate = true)

Use this function to create a configurable object as part of a parent one (aggregation).

The input configuration may contain regular Hash parameters under the key nodeName or an already instantiated object of type BaseClass::Pointer.

This signature of this function allows to specify a classId in case the Aggregate itself is a derivative of BaseClass.

nodeName : The key name of the NODE_ELEMENT as defined by the parent class

classId : The factory key of the to be created object (must inherit the BaseClass template)

input : The input configuration of the parent class

validate : Whether to validate or not

Return : Shared pointer of the created object

inline static typename BaseClass::Pointer createNode(const std::string& nodeName, const karabo::data::Hash& input, const bool validate = true)

Use this function to create a configurable object of class template type as part of a parent one (aggregation).

The input configuration may contain regular Hash parameters under the key nodeName or an already instantiated object of type BaseClass::Pointer.

nodeName : The key name of the NODE_ELEMENT as defined by the parent class

input : The input configuration of the parent class

validate : Whether to validate or not

Return : Shared pointer of the created object

getRegisteredClasses

static std::vector<std::string> getRegisteredClasses()

Return a vector of classIds registered in this Configurator

Return :

getSchema

static Schema getSchema(const std::string& classId, const Schema::AssemblyRules& rules = Schema::AssemblyRules())

Get the schema defining a factorized class

classId : identifying the class in the factory

rules : defining how to assembly the returned Schema

Return :

registerClass

template <class DerivedClass> static void registerClass(const std::string& classId)

Register a base class with standard Hash configuration constructor into the factory

classId : identifying the class in the factory

template <class DerivedClass, typename A1> static void registerClass(const std::string& classId)

Register a class having constructor with additional A1 type parameter (besides the standard Hash configuration) into the factory

classId : identifying the class in the factory

registerSchemaFunction

template <class T> static void registerSchemaFunction(const std::string& classId)

Register the schema decription function for classId in the factory

classId : identifying the class in the factory

registerSchemaFunctions

template <class... A> static void registerSchemaFunctions(const std::string& classId)

Register the schema decription functions for classId in the factory

The parameter pack 'A' typically is the list of all the classes in the inheritance chain of 'classId', including itself at the end.

classId : identifying the class in the factory

setDefault

static void setDefault(const std::string& classId)

Set the default class id of the factory

classId :

validateConfiguration

static void validateConfiguration(const std::string& classId, const Hash& configuration, Hash& validated)

Trigger a validation of class BaseClass (or a derivative) against the Schema as provided by the static expectedParameters function

NOTE: During regular factory construction validation already is done (if validate==true) *

classId : The factory key of the to be created object (must inherit the BaseClass template)

configuration : A hash that is checked against the expectedParameters requirements

validated : The resultant validated hash (has defaults injected)