Tango Core Classes Reference  9.3.4
Tango::DbDatum Class Reference

A database value. More...

#include "tango.h"

Public Member Functions

Constructors
 DbDatum (string name)
 Create a DbDatum object. More...
 
 DbDatum (const char *name)
 Create a DbDatum object. More...
 
Operators overloading
void operator<< (bool val)
 Inserters operators. More...
 
bool operator>> (bool &val)
 Extractors operators. More...
 
Exception related methods methods
void exceptions (bitset< DbDatum::numFlags > fl)
 Set exception flag. More...
 
bitset< DbDatum::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...
 

Miscellaneous methods

bool is_empty ()
 Test if instance is empty. More...
 

Detailed Description

A database value.

A single database value which has a name, type, address and value and methods for inserting and extracting C++ native types. This is the fundamental type for specifying database properties. Every property has a name and has one or more values associated with it. The values can be inserted and extracted using the operators << and >> respectively. A status flag indicates if there is data in the DbDatum object or not. An additional flag allows the user to activate exceptions.

Constructor & Destructor Documentation

◆ DbDatum() [1/2]

Tango::DbDatum::DbDatum ( string  name)

Create a DbDatum object.

Create an instance of the DbDatum class with name set to the specified parameter

Parameters
[in]nameThe CORBA ORB pointer. Default value is fine for 99 % of cases

◆ DbDatum() [2/2]

Tango::DbDatum::DbDatum ( const char *  name)

Create a DbDatum object.

Create an instance of the DbDatum class with name set to the specified parameter

Parameters
[in]nameThe CORBA ORB pointer. Default value is fine for 99 % of cases

Member Function Documentation

◆ exceptions() [1/2]

bitset<DbDatum::numFlags> Tango::DbDatum::exceptions ( )
inline

Get exception flag.

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

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

◆ exceptions() [2/2]

void Tango::DbDatum::exceptions ( bitset< DbDatum::numFlags >  fl)
inline

Set exception flag.

Is a method which allows the user to switch on/off exception throwing for trying to extract data from an empty DbDatum object. The default is to not throw exception. The following flags are supported :

  • isempty_flag - throw a WrongData exception (reason = API_EmptyDbDatum) if user tries to extract data from an empty DbDatum object
  • 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
Parameters
[in]flThe exception flag

◆ is_empty()

bool Tango::DbDatum::is_empty ( )

Test if instance is empty.

is_empty() is a boolean method which returns true or false depending on whether the DbDatum object contains data or not. It can be used to test whether a property is defined in the database or not e.g.

sl_props.push_back(parity_prop);
dbase->get_device_property(device_name, sl_props);
if (! parity_prop.is_empty())
{
parity_prop >> parity;
}
else
{
cout << device_name << " has no parity defined in database !" << endl;
}
Returns
True if DdDatum instance is empty
Exceptions
WrongDataif requested

◆ operator<<()

void Tango::DbDatum::operator<< ( bool  val)

Inserters operators.

The insert and extract operators are specified for the following C++ types :

  • bool
  • unsigned char
  • short
  • unsigned short
  • DevLong
  • DevULong
  • DevLong64
  • DevULong64
  • float
  • double
  • string
  • char* (insert only)
  • const char *
  • vector<string>
  • vector<short>
  • vector<unsigned short>
  • vector<DevLong>
  • vector<DevULong>
  • vector<DevLong64>
  • vector<DevULong64>
  • vector<float>
  • vector<double>

Here is an example of creating, inserting and extracting some DbDatum types :

DbDatum my_short("my_short"), my_long(“my_long”), my_string("my_string");
DbDatum my_float_vector("my_float_vector"), my_double_vector("my_double_vector");
string a_string;
short a_short;
DevLong a_long;
vector<float> a_float_vector;
vector<double> a_double_vector;
my_short << 100; // insert a short
my_short >> a_short; // extract a short
my_long << 1000; // insert a DevLong
my_long >> a_long; // extract a long
my_string << string("estas lista a bailar el tango ?"); // insert a string
my_string >> a_string; // extract a string
my_float_vector << a_float_vector // insert a vector of floats
my_float_vector >> a_float_vector; // extract a vector of floats
my_double_vector << a_double_vector; // insert a vector of doubles
my_double_vector >> a_double_vector; // extract a vector of doubles
Parameters
[in]valData to be inserted
Exceptions
WrongDataif requested

◆ operator>>()

bool Tango::DbDatum::operator>> ( bool &  val)

Extractors operators.

See documentation of the DbDatum::operator<< for details

Parameters
[out]valData to be initalized with database value
Returns
A boolean set to true if the extraction succeeds
Exceptions
WrongDataif requested

◆ reset_exceptions()

void Tango::DbDatum::reset_exceptions ( except_flags  fl)
inline

Reset one exception flag.

Resets one exception flag

Parameters
[in]flThe exception flag

◆ set_exceptions()

void Tango::DbDatum::set_exceptions ( except_flags  fl)
inline

Set one exception flag.

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

Parameters
[in]flThe exception flag

The documentation for this class was generated from the following file:
DeviceAttribute::exceptions
void exceptions(bitset< numFlags > fl)
Set exception flag.
Definition: DeviceAttribute.h:955
Tango::DbDatum::DbDatum
DbDatum(string name)
Create a DbDatum object.