Tango Core Classes Reference  9.3.4
DevicePipeBlob Class Reference

A device pipe blob. More...

#include "tango.h"

Public Member Functions

Constructors
 DevicePipeBlob ()
 Create a DevicePipeBlob object. More...
 
 DevicePipeBlob (const string &blob_name)
 Create a DevicePipeBlob object with name. More...
 
Get/Set methods
void set_name (const string &blob_name)
 Set blob name. More...
 
const string & get_name ()
 Get blob name. More...
 
Inserting data into a DevicePipeBlob
DevicePipeBloboperator<< (short &datum)
 Insert data into a data blob. More...
 
void set_data_elt_nb (size_t nb)
 Set blob data element number. More...
 
void set_data_elt_names (vector< string > &names)
 Set blob data element number and names. More...
 
Extracting data from a DevicePipeBlob
DevicePipeBloboperator>> (short &datum)
 Extract data from a data blob. More...
 
size_t get_data_elt_nb ()
 Get blob data element number. More...
 
vector< string > get_data_elt_names ()
 Get blob data elements name. More...
 
string get_data_elt_name (size_t ind)
 Get blob data element name. More...
 
int get_data_elt_type (size_t ind)
 Get blob data element value type. 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...
 
bool has_failed ()
 Check insertion/extraction success. More...
 
bitset< numFlags > state ()
 Get instance insertion/extraction state. More...
 

Detailed Description

A device pipe blob.

A device pipe blob. A blob is used to pack data to be sent through device pipe

$Author$ $Revision$

Constructor & Destructor Documentation

◆ DevicePipeBlob() [1/2]

DevicePipeBlob::DevicePipeBlob ( )

Create a DevicePipeBlob object.

Default constructor.

◆ DevicePipeBlob() [2/2]

DevicePipeBlob::DevicePipeBlob ( const string &  blob_name)

Create a DevicePipeBlob object with name.

Create one instance of the DevicePipeBlob class and set its name

Parameters
[in]blob_nameThe blob name

Member Function Documentation

◆ exceptions() [1/2]

bitset<numFlags> DevicePipeBlob::exceptions ( )
inline

Get exception flag.

Returns the whole exception flags. The following is an example of how to use these exceptions related methods

bitset<DevicePipeBlob::numFlags> bs = dpb.exceptions();
cout << "bs = " << bs << endl;
dpb.set_exceptions(DevicePipeBlob::wrongtype_flag);
bs = dpb.exceptions();
cout << "bs = " << bs << endl;
Returns
The exception flag

◆ exceptions() [2/2]

void DevicePipeBlob::exceptions ( bitset< numFlags >  fl)
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 DevicePipeBlob object. The following flags are supported :

  • isempty_flag - throw a WrongData exception (reason = API_EmptyDataElement) if user tries to extract data from one empty blob data element. By default, this flag is set
  • wrongtype_flag - throw a WrongData exception (reason = API_IncompatibleArgumentType) if user tries to extract data with a type different than the type used for insertion. By default, this flag is set
  • notenoughde_flag - throw a WrongData exception (reason = API_PipeWrongArg) if user tries to extract data from a DevicePipeBlob for a data element which does not exist. By default, this flag is set
  • blobdenamenotset_flag - Throw a WrongData exception (reason = API_PipeNoDataElement) if user tries to insert data into the blob while the name or number of data element has not been set with methods set_data_elt_nb() or set_data_elt_names()
  • mixing_flag - Throw a WrongData exception (reason = API_NotSupportedFeature) if user tries to mix insertion/extraction method (<< or >>) with operator[]
Parameters
[in]flThe exception flag

Referenced by Tango::Pipe::exceptions().

◆ get_data_elt_name()

string DevicePipeBlob::get_data_elt_name ( size_t  ind)

Get blob data element name.

Get the blob data element name for a single data element

Parameters
[in]indThe data element index within the blob
Returns
The blob data element name

Referenced by Tango::WPipe::get_data_elt_name().

◆ get_data_elt_names()

vector<string> DevicePipeBlob::get_data_elt_names ( )

Get blob data elements name.

Get the blob data elements name

Returns
The blob data elements name

Referenced by Tango::WPipe::get_data_elt_names().

◆ get_data_elt_nb()

size_t DevicePipeBlob::get_data_elt_nb ( )

Get blob data element number.

Get the blob data element number

Returns
The blob data element number

Referenced by Tango::Pipe::get_data_elt_nb(), and Tango::WPipe::get_data_elt_nb().

◆ get_data_elt_type()

int DevicePipeBlob::get_data_elt_type ( size_t  ind)

Get blob data element value type.

Get the blob data element value type for a single data element

Parameters
[in]indThe data element index within the blob
Returns
The blob data element value type

Referenced by Tango::WPipe::get_data_elt_type().

◆ get_name()

const string& DevicePipeBlob::get_name ( )
inline

Get blob name.

Get the blob name

Returns
The blob name

Referenced by Tango::Pipe::get_root_blob_name(), and Tango::WPipe::get_root_blob_name().

◆ has_failed()

bool DevicePipeBlob::has_failed ( )

Check insertion/extraction success.

Allow the user to check if insertion/extraction into/from DevicePipeBlob instance was successfull. This method has to be used when exceptions are disabled.

Returns
True if insertion/extraction has failed

Referenced by Tango::Pipe::has_failed().

◆ operator<<()

DevicePipeBlob& DevicePipeBlob::operator<< ( short &  datum)

Insert data into a data blob.

According to the data to be inserted into the blob data element, several kinds of insetor methods have been implemented. You can insert data from:

  • Scalar data type
  • vector
  • TANGO CORBA sequence types (by reference)
  • TANGO CORBA sequence types (by pointer)
  • DataElement<T> with T being scalar data type
  • DataElement<T> with T being vector
  • DataElement<T> with T being TANGO CORBA sequence type (by reference)
  • DataElement<T> with T being TANGO CORBA sequence type (by pointer)

When inserting data using a DataElement<T> instance, the data element name is also set. For insertion from TANGO CORBA sequence type pointer, the insertion method consumes the memory allocated to store the data and it will be freed by the Tango layer.

Insert operators for the following scalar C++ types (and DataElement<T>)

  • bool
  • short
  • DevLong
  • DevLong64
  • float
  • double
  • unsigned char
  • unsigned short
  • DevULong
  • DevULong64
  • DevString
  • string
  • DevState
  • DevEncoded

Insert operators for the following C++ vector types (and DataElement<T>)

  • vector<bool>
  • vector<short>
  • vector<DevLong>
  • vector<DevLong64>
  • vector<float>
  • vector<double>
  • vector<unsigned char>
  • vector<unsigned short>
  • vector<DevULong>
  • vector<DevULong64>
  • vector<DevSstring>
  • vector<string>
  • vector<DevState>

Insert operators for the following CORBA sequence types (and DataElement<T>):

  • DevVarBooleanArray &
  • DevVarShortArray &
  • DevVarLongArray &
  • DevVarLong64Array &
  • DevVarFloatArray &
  • DevVarDoubleArray &
  • DevVarUCharArray &
  • DevVarUShortArray &
  • DevVarULongArray &
  • DevVarULong64Array &
  • DevVarStringArray &
  • DevVarStateArray &

Insert operators for the following CORBA sequence types with memory consumption (and DataElement<T>):

  • DevVarBooleanArray *
  • DevVarShortArray *
  • DevVarLongArray *
  • DevVarLong64Array *
  • DevVarFloatArray *
  • DevVarDoubleArray *
  • DevVarUCharArray *
  • DevVarUShortArray *
  • DevVarULongArray *
  • DevVarULong64Array *
  • DevVarStringArray *
  • DevVarStateArray *

Here is an example of inserting data into a DevicePipeBlob instance. We insert 3 data element into the pipe blob with a DevLong, a vector of doubles and finally an array of 100 unsigned short

DevicePipeBlob dpb("MyBlob");
vector<string> de_names = {"FirstDE","SecondDE","ThirdDE"};
dpb.set_data_elt_names(de_names);
DevLong dl = 666;
vector<double> v_db = {1.11,2.22};
unsigned short *array = new unsigned short [100]; // The array is populated by a way or another
DevVarUShortArray *dvush = create_DevVarUShortArray(array,100);
try
{
dpb << dl << v_db << dvush;
}
catch (DevFailed &e)
{
cout << "DevicePipeBlob insertion failed" << endl;
....
}

The same example of inserting data into a DevicePipeBlob instance when we want to set the data element name.

DevicePipeBlob dpb("MyBlob");
DataElement<DevLong> de_dl("FirstDE",666);
vector<double> v_db = {1.11,2.22};
DataElement<vector<double> > de_v_db("SecondDE",v_db);
unsigned short *array = new unsigned short [100]; // The array is populated by a way or another
DevVarUShortArray *dvush = create_DevVarUShortArray(array,100);
DataElement<DevVarUShortArray *> de_dvush("ThirdDE",array);
try
{
dpb << de_dl << de_v_db << de_dvush;
}
catch (DevFailed &e)
{
cout << "DevicePipeBlob insertion failed" << endl;
....
}
...

It is also possible to do the insertion in a third way

DevicePipeBlob dpb("MyBlob");
vector<string> de_names{"FirstDE","SecondDE","ThirdDE"};
dpb.set_data_elt_names(de_names);
DevLong dl = 666;
vector<double> v_db = {1.11,2.22};
unsigned short *array = new unsigned short [100]; // The array is populated by a way or another
DevVarUShortArray *dvush = create_DevVarUShortArray(array,100);
dpb["FirstDE"] << dl;
dpb["SecondDE"] << v_db;
dpb["ThirdDE"] << dvush;
Parameters
[in]datumThe data to be inserted into the DevicePipeBlob
Exceptions
WrongDataif requested

◆ operator>>()

DevicePipeBlob& DevicePipeBlob::operator>> ( short &  datum)

Extract data from a data blob.

According to the data inside blob data element, several kinds of extractor methods have been implemented. You can extract data into:

  • Scalar data type
  • vector
  • TANGO CORBA sequence types
  • DataElement<T> with T being scalar data type
  • DataElement<T> with T being vector
  • DataElement<T> with T being TANGO CORBA sequence type

When extracting data using a DataElement<T> instance, the data element name is also returned. For extraction into C++ vector, data are copied into the vector. It is not the case for extraction into TANGO CORBA sequence type. For extraction into TANGO CORBA sequence types, the extraction method consumes the memory allocated to store the data and it is the caller responsibility to delete this memory.

Extract operators for the following scalar C++ types (and DataElement<T>)

  • bool
  • short
  • DevLong
  • DevLong64
  • float
  • double
  • unsigned char
  • unsigned short
  • DevULong
  • DevULong64
  • string
  • DevState
  • DevEncoded

Extract operators for the following C++ vector types (and DataElement<T>)

  • vector<bool>
  • vector<short>
  • vector<DevLong>
  • vector<DevLong64>
  • vector<float>
  • vector<double>
  • vector<unsigned char>
  • vector<unsigned short>
  • vector<DevULong>
  • vector<DevULong64>
  • vector<string>
  • vector<DevState>

Extract operators for the following CORBA sequence types with memory consumption (and DataElement<T>):

  • DevVarBooleanArray *
  • DevVarShortArray *
  • DevVarLongArray *
  • DevVarLong64Array *
  • DevVarFloatArray *
  • DevVarDoubleArray *
  • DevVarUCharArray *
  • DevVarUShortArray *
  • DevVarULongArray *
  • DevVarULong64Array *
  • DevVarStringArray *
  • DevVarStateArray *

Here is an example of extracting data from a DevicePipeBlob instance. We know that the DevicePipeBlob contains 3 data element with a DevLong, an array of doubles and finally an array of unsigned short

DevicePipeBlob dpb = .....
DevLong dl;
vector<double> v_db;
DevVarUShortArray *dvush = new DevVarUShortArray();
try
{
dpb >> dl >> v_db >> dvush;
}
catch (DevFailed &e)
{
cout << "DevicePipeBlob extraction failed" << endl;
....
}
delete dvush;

The same example of extracting data from a DevicePipeBlob instance when we want to retrieve the data element name.

DevicePipeBlob dpb = .....
DataElement<DevLong> de_dl;
DataElement<DevVarUShortArray *> de_dvush(new DevVarUShortArray());
try
{
dpb >> de_dl >> de_v_db >> de_dvush;
}
catch (DevFailed &e)
{
cout << "DevicePipeBlob extraction failed" << endl;
....
}
cout << "Data element name = " << de_dl.name << " - Value = " << de_dl.value << endl;
...
delete de_dvush.value;

It is also possible to do the extraction in a generic way

DevicePipeBlob dpb = .....
size_t nb_de = dpb.get_data_elt_nb();
for (size_t loop = 0;loop < nb;loop++)
{
int data_type = dpb.get_data_elt_type(loop);
string de_name = dpb.get_data_elt_name(loop);
switch(data_type)
{
case DEV_LONG:
{
DevLong lg;
dpb >> lg;
}
break;
case DEVVAR_DOUBLEARRAY:
{
vector<double> v_db;
dpb >> v_db;
}
break;
....
}
...
}

Note that instead of using DevLong and vector<double> data, the extraction can be done using DataElement<T> instances. In this case, the call to the get_data_elt_name() method becomes useless.

Parameters
[out]datumThe blob data
Exceptions
WrongDataif requested

◆ reset_exceptions()

void DevicePipeBlob::reset_exceptions ( except_flags  fl)
inline

Reset one exception flag.

Resets one exception flag

Parameters
[in]flThe exception flag

Referenced by Tango::Pipe::reset_exceptions().

◆ set_data_elt_names()

void DevicePipeBlob::set_data_elt_names ( vector< string > &  names)

Set blob data element number and names.

Set the blob data element number and names. The data element number is the number of names in the input parameter.

Parameters
[in]namesThe blob data element names

Referenced by Tango::Pipe::set_data_elt_names().

◆ set_data_elt_nb()

void DevicePipeBlob::set_data_elt_nb ( size_t  nb)

Set blob data element number.

Set the blob data element number

Parameters
[in]nbThe blob data element number

Referenced by Tango::Pipe::set_data_elt_nb().

◆ set_exceptions()

void DevicePipeBlob::set_exceptions ( except_flags  fl)
inline

Set one exception flag.

Sets one exception flag. See DevicePipeBlob::exceptions() for a usage example.

Parameters
[in]flThe exception flag

Referenced by Tango::Pipe::set_exceptions().

◆ set_name()

void DevicePipeBlob::set_name ( const string &  blob_name)
inline

Set blob name.

Set the blob name

Parameters
[in]blob_nameThe blob name

Referenced by Tango::Pipe::set_root_blob_name().

◆ state()

bitset<numFlags> DevicePipeBlob::state ( )
inline

Get instance insertion/extraction state.

Allow the user to find out what was the reason of insertion/extraction into/from DevicePipeBlob failure. This method has to be used when exceptions are disabled. Here is an example of how methods has_failed() and state() could be used

DevicePipeBlob dpb = ....
bitset<DevicePipeBlob::numFlags> bs;
bs.reset();
dpb.exceptions(bs);
DevLong dl;
dpb >> dl;
if (dpb.has_failed() == true)
{
bitset<DevicePipeBlob::numFlags> bs_err = dpb.state();
if (bs_err.test(DevicePipeBlob::isempty_flag) == true)
.....
}
Returns
The error bit set.

Referenced by Tango::Pipe::state().


The documentation for this class was generated from the following file:
DevicePipeBlob::state
bitset< numFlags > state()
Get instance insertion/extraction state.
Definition: DevicePipe.h:614
DevicePipeBlob
A device pipe blob.
Definition: DevicePipe.h:112
DevicePipeBlob::set_exceptions
void set_exceptions(except_flags fl)
Set one exception flag.
Definition: DevicePipe.h:578
DataElement::name
string name
The data element name.
Definition: DevicePipe.h:75
DevicePipeBlob::exceptions
void exceptions(bitset< numFlags > fl)
Set exception flag.
Definition: DevicePipe.h:542
DevicePipeBlob::get_data_elt_name
string get_data_elt_name(size_t ind)
Get blob data element name.
DevicePipeBlob::get_data_elt_nb
size_t get_data_elt_nb()
Get blob data element number.
DevicePipeBlob::get_data_elt_type
int get_data_elt_type(size_t ind)
Get blob data element value type.
DevicePipeBlob::has_failed
bool has_failed()
Check insertion/extraction success.
DataElement
Fundamental type for extracting data from a device pipe blob.
Definition: DevicePipe.h:45
DevicePipeBlob::set_data_elt_names
void set_data_elt_names(vector< string > &names)
Set blob data element number and names.