XORDE  v1.0
eXtensible Operational Robotic Development Environment
Public Member Functions | List of all members
ONBObject< T > Class Template Reference

Component-side ONB Object. More...

#include <onbobject.h>

Inheritance diagram for ONBObject< T >:
ObjectInfo

Public Member Functions

 ONBObject ()
 Default constructor. More...
 
ONBObject< T > & min (const T &value)
 Set the minimum value of the object. More...
 
ONBObject< T > & max (const T &value)
 Set the maximum value of the object. More...
 
ONBObject< T > & def (const T &value)
 Set the default value of the object. More...
 
ONBObject< T > & step (const T &value)
 Set the step value of the object. More...
 
ONBObject< T > & MMD (const T &minValue, const T &maxValue, const T &defValue)
 Set the minimum, maximum and default value of the object. More...
 
ONBObject< T > & mime (const QString &value)
 Set the mime-type of the object. More...
 
ONBObject< T > & hint (const QString &value)
 Set the human-readable description of the object. More...
 
ONBObject< T > & unit (const QString &value)
 Set the unit of the object. More...
 
ONBObject< T > & opt (const QString &value)
 Set the optional text associated to the object. More...
 
ONBObject< T > & sampling (std::chrono::milliseconds value)
 Set the default sampling interval of the object. More...
 
template<typename... Args>
ONBObject< T > & enumeration (QString s, Args...a)
 Specify the list of the enumeration object values. More...
 
template<typename... Args>
ONBObject< T > & enumeration (QStringList list)
 Specify the names of the enumeration object with given string list. More...
 
- Public Member Functions inherited from ObjectInfo
 ObjectInfo ()
 Common constructor. Initializes unbound object.
 
 ObjectInfo (const ObjectDescription &desc)
 Construct Object with given description. More...
 
 ObjectInfo (const ObjectInfo &other)=delete
 no copy allowed!!
 
const ObjectDescriptiondescription () const
 Get description of the object. More...
 
QString name () const
 Get name of the object. More...
 
Flags flags () const
 Get access flags.
 
int RMIP () const
 Get default sampling interval.
 
unsigned long timestamp () const
 Get timestamp of the last received value.
 
QJsonObject createJsonInfo () const
 Create JSON object with info about the ONB Object. More...
 
bool isVolatile () const
 Test an access flag.
 
bool isReadable () const
 Test an access flag.
 
bool isWritable () const
 Test an access flag.
 
bool isStorable () const
 Test an access flag.
 
bool isDual () const
 Test an access flag.
 
bool isHidden () const
 Test an access flag.
 
bool isFunction () const
 Test an access flag.
 
bool isArray () const
 Test an access flag.
 
bool hasMinimum () const
 Test a meta-value flag.
 
bool hasMaximum () const
 Test a meta-value flag.
 
bool hasDefault () const
 Test a meta-value flag.
 
bool hasStep () const
 Test a meta-value flag.
 
bool hasMimeType () const
 Test a meta-value flag.
 
bool hasHint () const
 Test a meta-value flag.
 
bool hasUnit () const
 Test a meta-value flag.
 
bool hasOptions () const
 Test a meta-value flag.
 
bool hasExtInfo () const
 Test a meta-value flag.
 
bool isEnum () const
 Test a meta-value flag.
 

Additional Inherited Members

- Public Types inherited from ObjectInfo
enum  Flags
 Access flags of the Object. More...
 
enum  Type
 Supported types of the object. More...
 

Detailed Description

template<typename T>
class ONBObject< T >

Component-side ONB Object.

It used for data exchange between components.

ONBObject contains variable binding and meta-information about it such as name, type, size, access flags and meta-values. Assigning meta-values is provided by methods min(), max() etc. that return a reference to the object, so you can write meta-description of the object in one line. All meta-values are optional.

To create ONB objects use convenient methods of ComponentBase class.

int foo = 0;
createSetting("foo", foo).min(-10).max(10).hint("The amount of foo");
See also
ComponentBase::createInput(), ComponentBase::createOutput(), ComponentBase::createSetting()

Constructor & Destructor Documentation

template<typename T>
ONBObject< T >::ONBObject ( )
inlineexplicit

Default constructor.

Sets ONB Object to contain ExtInfo since ONB protocol v2. You shouln't create ONBObject explicitly. Use more convenient methods of ComponentBase class instead.

See also
ComponentBase::createInput(), ComponentBase::createOutput(), ComponentBase::createSetting()

Member Function Documentation

template<typename T>
ONBObject<T>& ONBObject< T >::def ( const T &  value)
inline

Set the default value of the object.

Attention
This meta-value is only for information and does not apply to the variable.
Parameters
valueThe default value to be set.
Returns
reference to the object.
template<typename T>
template<typename... Args>
ONBObject<T>& ONBObject< T >::enumeration ( QString  s,
Args...  a 
)
inline

Specify the list of the enumeration object values.

The object can be bound to integer variable, the string or the native enumeration. If the object bound to integer variable, it defines the minimum and maximum values as 0 and (count-1) respectively. If the object bound to the string, the given names are the possible values of the string.

createSetting("Shape", shape).enumeration("Square", "Circle", "Triangle");
Parameters
sThe first string to be set.
aThe next strings, you can provide arbitrary argument count.
Returns
reference to the object.
See also
ComponentBase::createSetting()
template<typename T>
template<typename... Args>
ONBObject<T>& ONBObject< T >::enumeration ( QStringList  list)
inline

Specify the names of the enumeration object with given string list.

This is overloaded function.

Parameters
listThe string list to be set.
Returns
reference to the object.
See also
ONBObject::enumeration(QString s, Args... a)
template<typename T>
ONBObject<T>& ONBObject< T >::hint ( const QString &  value)
inline

Set the human-readable description of the object.

The description helps users to understand purpose of the object.
For example, if you'd develop some kind of PID controller you probably should write like this:

createSetting("Kp", Kp).hint("The coefficient for the proportional term");
Parameters
valueThe string containing description to be set.
Returns
reference to the object.
See also
ComponentBase::createSetting()
template<typename T>
ONBObject<T>& ONBObject< T >::max ( const T &  value)
inline

Set the maximum value of the object.

Attention
This meta-value is only for information and does not apply to the variable.
Parameters
valueThe maximum value to be set.
Returns
reference to the object.
template<typename T>
ONBObject<T>& ONBObject< T >::mime ( const QString &  value)
inline

Set the mime-type of the object.

Mime-type is arbitrary text used for specifying content of the object.
For example:

QByteArray frameBuffer;
createOutput("frame", frameBuffer).mime("image/png");
Parameters
valueThe string containing mime-type to be set.
Returns
reference to the object.
See also
ComponentBase::createOutput()
template<typename T>
ONBObject<T>& ONBObject< T >::min ( const T &  value)
inline

Set the minimum value of the object.

Attention
This meta-value is only for information and does not apply to the variable.
Parameters
valueThe minimum value to be set.
Returns
reference to the object.
template<typename T>
ONBObject<T>& ONBObject< T >::MMD ( const T &  minValue,
const T &  maxValue,
const T &  defValue 
)
inline

Set the minimum, maximum and default value of the object.

The method is implemented as consequent call to min(), max() and def() and can be used to simplify the code.

Parameters
minValueThe minimum value to be set.
maxValueThe maximum value to be set.
defValueThe default value to be set.
Returns
reference to the object.
See also
min(), max(), def().
template<typename T>
ONBObject<T>& ONBObject< T >::opt ( const QString &  value)
inline

Set the optional text associated to the object.

Can contain arbitrary text, but some special words are used for UI enhancement.

Parameters
valueThe string of optional text to be set.
Returns
reference to the object.
template<typename T>
ONBObject<T>& ONBObject< T >::sampling ( std::chrono::milliseconds  value)
inline

Set the default sampling interval of the object.

It is applicable to inputs or outputs and denotes the recommended time interval to request or send the value of the object. If the sampling interval is set, the object will include timestamp. and can be used in real-time dataflow.

Parameters
valueThe sampling interval. If the special value of zero is set, the object will be sent as soon as it is touched.
Returns
reference to the object.
See also
ComponentBase::touchOutput().
template<typename T>
ONBObject<T>& ONBObject< T >::step ( const T &  value)
inline

Set the step value of the object.

Step is used commonly for changing the value in discrete steps.

Attention
This meta-value is only for information and does not apply to the variable.
Parameters
valueThe step value to be set.
Returns
reference to the object.
template<typename T>
ONBObject<T>& ONBObject< T >::unit ( const QString &  value)
inline

Set the unit of the object.

Unit is arbitrary text used for specifying measure of the value of the object.

createInput("frequency", freq).unit("Hz");
Parameters
valueThe string containing unit to be set.
Returns
reference to the object.
See also
ComponentBase::createInput()