Tango Core Classes Reference
9.3.4
|
Fundamental type for sending and receiving data from device commands. More...
#include "tango.h"
Public Member Functions | |
Constructors | |
DeviceData () | |
Create a DeviceData object. More... | |
Exception and error related methods methods | |
void | exceptions (bitset< numFlags > fl) |
Set exception flag. More... | |
bitset< numFlags > | exceptions () |
Get exception flag. More... | |
void | reset_exceptions (except_flags fl) |
Reset one exception flag. More... | |
void | set_exceptions (except_flags fl) |
Set one exception flag. More... | |
bitset< numFlags > | state () |
Get instance extraction state. More... | |
Inserters and Extractors | |
void | operator<< (bool datum) |
The insert operators. More... | |
void | insert (vector< DevLong > &vl, vector< string > &vs) |
Insert data into a DeviceData for the DevVarLongStringArray data type. More... | |
void | insert (vector< double > &vd, vector< string > &vs) |
Insert data into a DeviceData for the DevVarDoubleStringArray data type. More... | |
void | insert (const string &str, vector< unsigned char > &buffer) |
Insert data into a DeviceData for the DevEncoded data type. More... | |
bool | operator>> (bool &datum) |
The extract operators. More... | |
bool | extract (vector< DevLong > &vl, vector< string > &vs) |
Extract data from a DeviceData for the DevVarLongStringArray data type. More... | |
bool | extract (vector< double > &vd, vector< string > &vs) |
Extract data from a DeviceData for the DevVarDoubleStringArray data type. More... | |
bool | extract (const char *&str, const unsigned char *&data, unsigned int &length) |
Extract data from a DeviceData for the DevEncoded data type. More... | |
miscellaneous methods | |
bool | is_empty () |
Check if the DeviceData instance is empty. More... | |
int | get_type () |
Get Tango data type of the included data. More... | |
Fundamental type for sending and receiving data from device commands.
This is the fundamental type for sending and receiving data from device commands. The values can be inserted and extracted using the operators << and >> respectively and insert() for mixed data types. A status flag indicates if there is data in the DbDatum object or not. An additional flag allows the user to activate exceptions.
Insertion by pointers takes full ownership of the pointed to memory. The insertion copy the data in the DeviceData object and delete the pointed to memory. Therefore, the memory is not more usable after the insertion.
When using extraction by pointers, the pointed to memory is inside the DeviceData object and its lifetime is the same than the DeviceData object lifetime.
DeviceData::DeviceData | ( | ) |
Create a DeviceData object.
Default constructor. The instance is empty
|
inline |
Get exception flag.
Returns the whole exception flags. The following is an example of how to use these exceptions related methods
|
inline |
Set exception flag.
It's a method which allows the user to switch on/off exception throwing when trying to extract data from a DeviceData object. The following flags are supported :
[in] | fl | The exception flag |
Referenced by Tango::GroupCmdReply::operator>>().
bool DeviceData::extract | ( | const char *& | str, |
const unsigned char *& | data, | ||
unsigned int & | length | ||
) |
Extract data from a DeviceData for the DevEncoded data type.
Extract command data when the command data type is DevEncoded Similar method with following signature also exist
[out] | str | The DevEncoded string |
[out] | data | The DevEncoded data pointer |
[out] | length | The DevEncoded data length |
WrongData | if requested |
bool DeviceData::extract | ( | vector< DevLong > & | vl, |
vector< string > & | vs | ||
) |
Extract data from a DeviceData for the DevVarLongStringArray data type.
Extract data from a DeviceData for the DevVarLongStringArray data type
[out] | vl | The long vector which will be inialized |
[out] | vs | The string vector to be initialized |
WrongData | if requested |
bool DeviceData::extract | ( | vector< double > & | vd, |
vector< string > & | vs | ||
) |
Extract data from a DeviceData for the DevVarDoubleStringArray data type.
Extract data from a DeviceData for the DevVarDoubleStringArray data type
[out] | vd | The double vector to be initialized |
[out] | vs | The string vector to be initialized |
WrongData | if requested |
int DeviceData::get_type | ( | ) |
Get Tango data type of the included data.
This method returns the Tango data type of the data inside the DeviceData object
void DeviceData::insert | ( | const string & | str, |
vector< unsigned char > & | buffer | ||
) |
Insert data into a DeviceData for the DevEncoded data type.
Insert data into a DeviceData for the DevEncoded data type
Similar methods with different parameters data type exist for inserting data for a DevEncoded data type
These three methods do not take ownership of the memory used for the data buffer.
[in] | str | The string part of the DevEncoded instance |
[in] | buffer | The data part of the DevEncoded instance |
WrongData | if requested |
void DeviceData::insert | ( | vector< DevLong > & | vl, |
vector< string > & | vs | ||
) |
Insert data into a DeviceData for the DevVarLongStringArray data type.
Insert data into a DeviceData for the DevVarLongStringArray data type
[in] | vl | The long vector to be inserted |
[in] | vs | The string vector to be inserted |
WrongData | if requested |
void DeviceData::insert | ( | vector< double > & | vd, |
vector< string > & | vs | ||
) |
Insert data into a DeviceData for the DevVarDoubleStringArray data type.
Insert data into a DeviceData for the DevVarDoubleStringArray data type
[in] | vd | The double vector to be inserted |
[in] | vs | The string vector to be inserted |
WrongData | if requested |
bool DeviceData::is_empty | ( | ) |
Check if the DeviceData instance is empty.
is_empty() is a boolean method which returns true or false depending on whether the DeviceData object contains data or not. It can be used to test whether the DeviceData has been initialized or not but you have first to disable exception throwing in case of empty object e.g.
|
inline |
The insert operators.
The insert operators are specified for the following C++ types :
Operators exist for inserting the native TANGO CORBA sequence types. These can be useful for programmers who want to use the TANGO api internally in their device servers and do not want to convert from CORBA to C++ types. Insert and extract operators exist for the following types :
Insertion by pointers takes full ownership of the pointed to memory. The insertion copy the data in the DeviceData object and delete the pointed to memory. Therefore, the memory is not more usable after the insertion.
Operators also exist for inserting TANGO CORBA sequence type by reference. The insertion copy the data into the DeviceData object. Insert operator exist for the following types :
Special care has been taken to avoid memory copy between the network layer and the user application. Nevertheless, C++ vector types are not the CORBA native type and one copy is unavoidable when using vectors. Using the native TANGO CORBA sequence types avoid any copy. When using these TANGO CORBA sequence types, insertion into the DeviceData object consumes the memory pointed to by the pointer. After the insertion, it is not necessary to delete the memory. It will be done by the destruction of the DeviceData object. For extraction, the pointer used for the extraction points into memory inside the DeviceData object and you should not delete it Here is an example of creating, inserting and extracting some data type from/into DeviceData object :
[in] | datum | The data to be inserted |
WrongData | if requested |
bool DeviceData::operator>> | ( | bool & | datum | ) |
The extract operators.
The extract operators are specified for the following C++ types :
Operators exist for extracting the native TANGO CORBA sequence types. These can be useful for programmers who want to use the TANGO api internally in their device servers and do not want to convert from CORBA to C++ types. Insert and extract operators exist for the following types :
Note that when using extraction by pointers, the pointed to memory is inside the DeviceData object and its lifetime is the same than the DeviceData object lifetime.
Special care has been taken to avoid memory copy between the network layer and the user application. Nevertheless, C++ vector types are not the CORBA native type and one copy is unavoidable when using vectors. Using the native TANGO CORBA sequence types avoid any copy. When using these TANGO CORBA sequence types, for extraction, the pointer used for the extraction points into memory inside the DeviceData object and you should not delete it See DeviceData::operator<< for inserters and extractors usage example
[out] | datum | The variable which will be initalized |
WrongData | if requested |
|
inline |
Reset one exception flag.
Resets one exception flag
[in] | fl | The exception flag |
|
inline |
Set one exception flag.
Sets one exception flag. See DeviceData::exceptions() for a usage example.
[in] | fl | The exception flag |
|
inline |
Get instance extraction state.
Allow the user to find out what was the reason of extraction from DeviceData failure. This method has to be used when exceptions are disabled. Here is an example of how method state() could be used