Skip to content

CustomNodeElement

template <class Derived, class Described> class CustomNodeElement

Helper class to construct custom NODE_ELEMENTs for schemas. Usage is best explained by example, say you coded a custom data class (by inheriting protected Hash) like:

class MyData : protected Hash {
    MyData(...) {
        setInternal(DataType()));
    }
    void setInternal(const SomeType& data) {
        set("internal", data);
    }
};
Then you need a class describing the content of your class

class MyDataDescription {
      public:
        // 2nd arg should match the classId of the class we describe (not of the describing class),
        // so that Schema::getCustomNodeClass(..) returns that one.
        KARABO_CLASSINFO(MyDataDescription, MyData::classInfo().getClassId(), "3.0");
        static void expectedParameters(const Schema& s) {
            // parameter definition [...]
        }
};
and you may generate a NODE_ELEMENT like this:

class MyDataElement : public CustomNodeElement<MyDataElement, MyDataDescription> {
    typedef karabo::data::CustomNodeElement<MyDataElement, MyDataDescription> ParentType;
    MyDataElement(karabo::data::Schema& s) : CustomNodeElement<MyDataElement, MyDataDescription>(s) {
    }

    // If you want to expose parameters for setting defaults do like:
    CustomNodeElement<ImageData>& setFoo(const std::string& bar) {
        return CustomNodeElement<ImageData >::setDefaultValue("foo", bar);
    }
};
typedef MyDataElement MYDATA_ELEMENT;

Note that it is possible to integrate the description into the custom data class, i.e. instead of providing MyDataDescription class, one can add the 'expectedParameters(..)' to 'MyData' and then use directly MyData as second template of the CustomNodeElement.

Functions

Name Description
key The key method serves for setting up a unique name for the element.
displayedName The displayedName method serves for setting up an user friendly name for the element to be used by GUI name : User friendly name for the element Return : reference to the Element (to allow method's chaining) Example: SOME_ELEMENT(expected) ... .displayedName("Connection Type") ... .commit();
description The description method serves for setting up a description of the element desc : Short description of the element Return : reference to the Element (to allow method's chaining) Example: SOME_ELEMENT(expected) ... .description("Decide whether the connection is used to implement a TCP Server or TCP Client") ... .commit();
init The init method serves for setting up an access type property that allows the element to be included in initial schema.
reconfigurable The reconfigurable method serves for setting up an access type property that allows the element to be included in initial, reconfiguration and monitoring schemas.
readOnly The readOnly method serves for setting up an access type property that allows the element to be included in monitoring schema only.
observerAccess The observerAccess method serves for setting up the required access level attribute to be OBSERVER.
operatorAccess The operatorAccess method serves for setting up the required access level attribute to be OPERATOR.
expertAccess The expertAccess method serves for setting up the required access level attribute to be EXPERT.
setAllowedActions Specify one or more actions that are allowed on this node.
skipValidation Skip this element during validation of configuration against a Schema Return :
setDefaultValue Set the default value for a subkey of the CustomNodeElement subKey : defaultValue : Return :
setMaxSize Set the maximum size of a subkey of the CustomNodeElement.
setUnit Set the unit for a subkey of the CustomNodeElement subKey : unit : Return :
setMetricPrefix Set the metric prefix for a subkey of the CustomNodeElement subKey : metricPrefix : Return :
commit Registers this element into the Schema

Function Details

commit

void commit()

Registers this element into the Schema

description

Derived& description(const std::string& desc)

The description method serves for setting up a description of the element

desc : Short description of the element

Return : reference to the Element (to allow method's chaining)

Example:

SOME_ELEMENT(expected)
        ...
        .description("Decide whether the connection is used to implement a TCP Server or TCP Client")
        ...
        .commit();

displayedName

Derived& displayedName(const std::string& name)

The displayedName method serves for setting up an user friendly name for the element to be used by GUI

name : User friendly name for the element

Return : reference to the Element (to allow method's chaining)

Example:

SOME_ELEMENT(expected)
        ...
        .displayedName("Connection Type")
        ...
        .commit();

expertAccess

Derived& expertAccess()

The expertAccess method serves for setting up the required access level attribute to be EXPERT.

Return : reference to the Element (to allow method's chaining)

init

Derived& init()

The init method serves for setting up an access type property that allows the element to be included in initial schema.

Return : reference to the Element (to allow method's chaining)

key

Derived& key(const std::string& key)

The key method serves for setting up a unique name for the element.

name : Unique name for the key

Return : reference to the Element (to allow method's chaining)

Example:

SOME_ELEMENT(expected)
        .key("type")
        ...
        .commit();

observerAccess

Derived& observerAccess()

The observerAccess method serves for setting up the required access level attribute to be OBSERVER.

Return : reference to the Element (to allow method's chaining)

operatorAccess

Derived& operatorAccess()

The operatorAccess method serves for setting up the required access level attribute to be OPERATOR.

Return : reference to the Element (to allow method's chaining)

readOnly

Derived& readOnly()

The readOnly method serves for setting up an access type property that allows the element to be included in monitoring schema only.

Return : reference to the Element (to allow method's chaining)

reconfigurable

Derived& reconfigurable()

The reconfigurable method serves for setting up an access type property that allows the element to be included in initial, reconfiguration and monitoring schemas.

Return : reference to the Element (to allow method's chaining)

setAllowedActions

Derived& setAllowedActions(const std::vector<std::string>& actions)

Specify one or more actions that are allowed on this node.

If a Karabo device specifies allowed actions for a node, that means that it offers a specific slot interface to operate on this node. Which allowed actions require which interface will be defined elsewhere.

Return : reference to the Element (to allow method's chaining)

setDefaultValue

template <class T> Derived& setDefaultValue(const std::string& subKey, const T& defaultValue)

Set the default value for a subkey of the CustomNodeElement

subKey :

defaultValue :

Return :

setMaxSize

Derived& setMaxSize(const std::string& subKey, const unsigned int maxSize)

Set the maximum size of a subkey of the CustomNodeElement. This is required by the DAQ for all vector attributes if its not assigned automatically or just to use a different value then the DAQ's default length of 1000.

subKey: : Key of the vector attribute (like "pixels.shape")

maxSize: : Number as the maximum size (like 3)

Return :

setMetricPrefix

Derived& setMetricPrefix(const std::string& subKey, const MetricPrefixType& metricPrefix)

Set the metric prefix for a subkey of the CustomNodeElement

subKey :

metricPrefix :

Return :

setUnit

Derived& setUnit(const std::string& subKey, const UnitType& unit)

Set the unit for a subkey of the CustomNodeElement

subKey :

unit :

Return :

skipValidation

Derived& skipValidation()

Skip this element during validation of configuration against a Schema

Return :