Kanzi Connect  3.9.8
Kanzi Connect C++ API
kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum > Class Template Reference

Template class that can be used to specialize standard types. More...

#include <runtimedataobject.hpp>

Inheritance diagram for kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >:
kanzi::connect::RuntimeDataObject

Public Member Functions

virtual RuntimeDataObjectSharedPtr clone () override
 Clone the object. More...
 
virtual bool copyValueFrom (RuntimeDataObjectSharedPtr other) override
 Copies a value from passed object. More...
 
virtual bool equals (RuntimeDataObjectSharedPtr object) override
 Comparison overload. More...
 
DataType getDefaultValue () const
 Retrieve the default value for this object. More...
 
virtual string getDefaultValueStr () const override
 Virtual function which exists in this base class but should never be used. This is overridden in classes where its appropriate. More...
 
string getSerializedValue () const override
 Get the runtimedata object value in serialized format. More...
 
virtual Type getType () const override
 Retrieves the type of this data object. More...
 
DataType getValue () const
 Retrieves the value that is represented by this data object. More...
 
 RuntimeDataObjectTyped (ConnectDomainSharedPtr domain, const string &name, const DataType &value, const string &nameOverride="")
 Constructor that initializes a typed data object from name and value. More...
 
 RuntimeDataObjectTyped (ConnectDomainSharedPtr domain, const string &path, const string &name, const DataType &value, const string &nameOverride, Persistence persistenceDefinition, const persistence::SettingFactory *settingFactory)
 Constructor that initializes a typed data object from name and value. More...
 
bool setValue (const DataType &value)
 Sets the value of this data object. More...
 
- Public Member Functions inherited from kanzi::connect::RuntimeDataObject
void addChild (const RuntimeDataObjectSharedPtr &child)
 Adds data object as child of this object. More...
 
ModifiedSubscriptionToken addModifiedNotificationHandler (ModifiedFunction callback)
 Allows to subscribe to modifications in this data context. More...
 
ChildConstIterator beginChildren () const
 Returns iterator to start of the child container. More...
 
template<typename _ToClass >
shared_ptr< _ToClass > castTo ()
 Cast this object to specific type. More...
 
void copyDataFrom (RuntimeDataObject &from)
 Copies basic data from provided object. More...
 
bool createChild (const string &name, const RuntimeDataObject::Type dataType, const string &serializedDefaultValue, const bool persistent, const int flags, const persistence::SettingFactory *settingFactory)
 Create a child under this runtime data object. More...
 
bool createChildRecursive (const string &path, RuntimeDataObject::Type dataType, const string &serializedDefaultValue, const bool persistent, const int flags, const persistence::SettingFactory *settingFactory)
 Create a child data object in the correct place in hierarchy specified by path. More...
 
RuntimeDataObjectSharedPtr createPathObjects (const string &path, const persistence::SettingFactory *settingFactory)
 Create objects enough to have the given path in the runtime data and return the leaf object All created objects are of Type::Object. More...
 
ChildConstIterator endChildren () const
 Returns iterator in the end of the child container. More...
 
RuntimeDataObjectSharedPtr findChild (const string &name)
 Tries to find a child with given name. More...
 
RuntimeDataObjectSharedPtr findChild (uint32_t hash)
 Tries to find a child with given name hash code. More...
 
template<typename _T >
shared_ptr< _T > findChild (const string &name)
 Retrieve a typed children with specific name. More...
 
template<typename _T >
shared_ptr< _T > findChild (uint32_t hash)
 Retrieve a typed children with specific name hash code. More...
 
RuntimeDataObjectSharedPtr findChildRecursive (const string &path, bool passLists=true)
 Locates childs recursively. More...
 
template<typename _T >
shared_ptr< _T > findChildRecursive (const string &path, bool passLists=true)
 Locates childs recursively. More...
 
bool generatesGetter () const
 Retrieve getter generation status. More...
 
RuntimeDataObjectSharedPtr getChild (size_t index) const
 Retrieves a child object in given index. More...
 
template<typename _T >
shared_ptr< _T > getChild (size_t index) const
 
size_t getChildCount () const
 Retrieves the count of child objects in this data object. More...
 
size_t getChildIndex (const RuntimeDataObject &child) const
 Retrieves the index of a child data object. More...
 
void getFreeformProperties (vector< pair< string, string > > &output)
 Get list of the free form properties defined for the object output The freeform properties will be copied here,. More...
 
int getIntProperty (const string &name, int defaultValue=0) const
 Retrieve int property value. More...
 
string getName () const
 Allows to retrieve the name of the object. More...
 
virtual uint32_t getNameHash ()
 retrieve hash code for the name portion of node More...
 
string getNameOverride () const
 Retrieve the overriden name. More...
 
const string & getPath () const
 
string getStringProperty (const string &name, const string defaultValue="") const
 Retrieve string property value. More...
 
template<typename _ToClass >
shared_ptr< _ToClass > getUIDelegate ()
 Retrieve UI Delegate and cast it to approriate type. More...
 
ModifiedSubscriptionToken getUIDelegateModificationHandlerToken () const
 Retrieve UI Delegate specific modification handlers registration token. More...
 
bool getWritable () const
 Retrieve writable status. More...
 
bool hasChild (const RuntimeDataObject &child) const
 Checks whether or not the child exists. More...
 
bool hasProperty (const string &name)
 Checks whether there is a property with given name. More...
 
virtual void notifyModified (RuntimeDataObject *object=0)
 Triggers modification procedure in this data context, which invokes the subscriptions. More...
 
virtual void removeAllChildren ()
 Removes all children. More...
 
virtual void removeChild (const RuntimeDataObject &child)
 Removes a child object from list of childs. More...
 
virtual void removeChild (size_t index)
 Removes a child object in given index. More...
 
virtual bool removeChild (const string &name)
 Remove specified child of this object. More...
 
bool removeChildRecursive (const string &path)
 Remove specified child and all elements in the path that would become empty. More...
 
void removeModifiedNotificationHandler (ModifiedSubscriptionToken token)
 Allows to unsubscribe from modifications in this data context. More...
 
void removeProperty (const string &name)
 Removes a property with specific name. More...
 
 RuntimeDataObject (ConnectDomainSharedPtr domain, const string &name, const string nameOverride="")
 Standard constructor. More...
 
 RuntimeDataObject (ConnectDomainSharedPtr domain, const string &path, const string &name, const string nameOverride)
 Standard constructor. More...
 
bool sendsEvent () const
 Retrieve notifier event generation status. More...
 
void setGenerateGetter (bool creteGetter)
 Set generate getter flag. More...
 
void setName (const string &value)
 Sets the name of the object. More...
 
void setNameOverride (const string &value)
 Sets the overriden name of the object. More...
 
void setProperty (const string &name, const string &value)
 Sets a local property - this information is not serialized. More...
 
void setProperty (const string &name, int value)
 Sets a local property - this information is not serialized. More...
 
void setSendsEvent (bool createEventOnChange)
 Set generate notifier event flag. More...
 
bool setSerializedValue (const string &serializedValue)
 Set the value for this data object, if this is not typed or list type then this will fail. More...
 
void setUIDelegateModificationHandlerToken (ModifiedSubscriptionToken token)
 Store UI Delegate modification handler handle. More...
 
void setUIDelegete (shared_ptr< DataObject > deleg)
 Configures UI Delegate object for this content object. More...
 
void setWritable (bool writable)
 Set writable flag. More...
 
virtual ~RuntimeDataObject ()
 C++ destructor. More...
 

Additional Inherited Members

- Public Types inherited from kanzi::connect::RuntimeDataObject
typedef ChildContainer::const_iterator ChildConstIterator
 
typedef ChildContainer::const_reverse_iterator ChildConstReverseIterator
 
typedef vector< RuntimeDataObjectSharedPtrChildContainer
 Iterators for children. More...
 
typedef function< void(RuntimeDataObject *self)> ModifiedFunction
 Callback function type for change subscriptions. More...
 
typedef shared_ptr< void > ModifiedSubscriptionToken
 Token type that can be used to identify the change subscription. More...
 
enum  Persistence { Persistence::NON_PERSISTENT, Persistence::PERSISTENT }
 Is the runtime data object persistent or not. More...
 
enum  Type {
  Object = 0, Integer = 1, Real = 2, Bool = 3,
  String = 4, List = 6, Unknown = 100
}
 Type enumerations for different data object types. More...
 
- Static Public Member Functions inherited from kanzi::connect::RuntimeDataObject
static bool isFreeformProperty (const string &propertyName)
 Checks whether the named property is one of the defined properties or not. More...
 
static Type str2Type (const string &str)
 Convert a string to Type. More...
 
static string type2Str (const Type type)
 Convert the type enumeration value to human readable string. More...
 
- Protected Types inherited from kanzi::connect::RuntimeDataObject
typedef unordered_map< RuntimeDataObjectSharedPtr, ModifiedSubscriptionTokenChildrenSubscriptionContainer
 
enum  PrivateRuntimeFlags { NONE = 0x0, HAS_SETTER = 0x0001, HAS_NOTIFIER = 0x0010, HAS_GETTER = 0x0100 }
 
- Protected Attributes inherited from kanzi::connect::RuntimeDataObject
ChildContainer m_children
 Children of the data object. More...
 
ChildrenSubscriptionContainer m_childrenSubscriptionTokens
 
ConnectDomainSharedPtr m_domain
 The connect domain this dataobject is bound to. More...
 
int m_flags
 
string m_name
 Name of the object. More...
 
uint32_t m_nameHash
 Hash code of the name. More...
 
string m_nameOverride
 UI Override for the name. More...
 
string m_path
 Contains the full path of the object and its parents. More...
 
optional< unordered_map< string, string > > m_properties
 Free form properties set for the object. More...
 
Type m_type
 Possible type. More...
 
weak_ptr< DataObject > m_UIDelegate
 UI class, kept as unknown here, just a pointer. More...
 
ModifiedSubscriptionToken m_UIDelegateModificationToken
 Token for modification registrations of UI Delegate. More...
 

Detailed Description

template<class DataType, RuntimeDataObject::Type DataTypeEnum>
class kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >

Template class that can be used to specialize standard types.

Provide basic functions to host / set / get value of given type.

Constructor & Destructor Documentation

◆ RuntimeDataObjectTyped() [1/2]

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::RuntimeDataObjectTyped ( ConnectDomainSharedPtr  domain,
const string &  name,
const DataType &  value,
const string &  nameOverride = "" 
)
inlineexplicit

Constructor that initializes a typed data object from name and value.

Parameters
nameName of the data object.
valueInitial value of the contained data.

◆ RuntimeDataObjectTyped() [2/2]

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::RuntimeDataObjectTyped ( ConnectDomainSharedPtr  domain,
const string &  path,
const string &  name,
const DataType &  value,
const string &  nameOverride,
Persistence  persistenceDefinition,
const persistence::SettingFactory *  settingFactory 
)
inlineexplicit

Constructor that initializes a typed data object from name and value.

Parameters
pathPath that contains names of the parents separated with '.'
nameName of the data object.
valueInitial value of the contained data.
nameOverride
See also
RuntimeDataObject
Parameters
persistenceDefinitionDefines whether the runtime data object value is persisted or not

Member Function Documentation

◆ clone()

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
virtual RuntimeDataObjectSharedPtr kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::clone ( )
inlineoverridevirtual

Clone the object.

Returns
cloned object

Reimplemented from kanzi::connect::RuntimeDataObject.

◆ copyValueFrom()

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
virtual bool kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::copyValueFrom ( RuntimeDataObjectSharedPtr  other)
inlineoverridevirtual

Copies a value from passed object.

Parameters
otherthe object where-from to copy.
Returns
true if copied successfully.

Reimplemented from kanzi::connect::RuntimeDataObject.

◆ equals()

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
virtual bool kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::equals ( RuntimeDataObjectSharedPtr  object)
inlineoverridevirtual

Comparison overload.

Parameters
otherwhere to perform the comparison against.

Reimplemented from kanzi::connect::RuntimeDataObject.

◆ getDefaultValue()

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
DataType kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::getDefaultValue ( ) const
inline

Retrieve the default value for this object.

Returns
Default value stored to the object.

◆ getDefaultValueStr()

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
virtual string kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::getDefaultValueStr ( ) const
inlineoverridevirtual

Virtual function which exists in this base class but should never be used. This is overridden in classes where its appropriate.

Reimplemented from kanzi::connect::RuntimeDataObject.

◆ getSerializedValue()

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
string kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::getSerializedValue ( ) const
inlineoverridevirtual

Get the runtimedata object value in serialized format.

Returns
The value, empty string if object has no value

Reimplemented from kanzi::connect::RuntimeDataObject.

◆ getType()

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
virtual Type kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::getType ( ) const
inlineoverridevirtual

Retrieves the type of this data object.

Returns
Type enumeration of this data object.

Reimplemented from kanzi::connect::RuntimeDataObject.

◆ getValue()

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
DataType kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::getValue ( ) const
inline

Retrieves the value that is represented by this data object.

Returns
Value within this data object.

◆ setValue()

template<class DataType , RuntimeDataObject::Type DataTypeEnum>
bool kanzi::connect::RuntimeDataObjectTyped< DataType, DataTypeEnum >::setValue ( const DataType &  value)
inline

Sets the value of this data object.

Parameters
valueNew value that is assigned to this data object.
Returns
true if value actually got changed.

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