#include <Clcm.hxx>
Public Member Functions | |
Clcm (const std::string stype, const std::string myName, const std::string myPath) throw (LCMexception) | |
Clcm (const std::string stype, ClcmPtr myClcm) throw (LCMexception) | |
Clcm (lcm *mylcm, const int_32 type, const int_32 access, const std::string OSname) | |
~Clcm () | |
void | expor (const std::string stype) |
void | expor (const std::string stype, const std::string new_name) |
void | except () |
std::string | getName () throw () |
std::string | getPath () throw () |
int_32 | getType () throw () |
int_32 | getLength () throw (LCMexception) |
std::string | getDirectory () throw (LCMexception) |
int_32 | getAccess () throw (LCMexception) |
int_32 | getLrda () throw () |
int_32 | getVersion () throw () |
bool | isEmpty () throw (LCMexception) |
bool | isNew () throw () |
void | open (const std::string saccess) throw (LCMexception) |
void | close (const std::string saccess) throw (LCMexception) |
int_32 | length (const std::string key) throw (LCMexception) |
int_32 | length (const int_32 iset) throw (LCMexception) |
int_32 | type (const std::string key) throw (LCMexception) |
int_32 | type (const int_32 iset) throw (LCMexception) |
void | lib () throw (LCMexception) |
void | val () throw (LCMexception) |
ClcmPtr | setDictionary (const std::string key) throw (LCMexception) |
ClcmPtr | setDictionary (const int_32 iset) throw (LCMexception) |
ClcmPtr | setList (const std::string key, const int_32 ilong) throw (LCMexception) |
ClcmPtr | setList (const int_32 iset, const int_32 ilong) throw (LCMexception) |
ClcmPtr | getClcm (const std::string key) throw (LCMexception) |
ClcmPtr | getClcm (const int_32 iset) throw (LCMexception) |
IntPtrConst | getInt (const std::string key) throw (LCMexception) |
IntPtrConst | getInt (const int_32 iset) throw (LCMexception) |
FloatPtrConst | getFloat (const std::string key) throw (LCMexception) |
FloatPtrConst | getFloat (const int_32 iset) throw (LCMexception) |
StringPtrConst | getString (const std::string key) throw (LCMexception) |
StringPtrConst | getString (const int_32 iset) throw (LCMexception) |
StringVecPtr | getVecString (const std::string key, const int_32 size) throw (LCMexception) |
StringVecPtr | getVecString (const int_32 iset, const int_32 size) throw (LCMexception) |
DoublePtrConst | getDouble (const std::string key) throw (LCMexception) |
DoublePtrConst | getDouble (const int_32 iset) throw (LCMexception) |
BoolPtrConst | getBool (const std::string key) throw (LCMexception) |
BoolPtrConst | getBool (const int_32 iset) throw (LCMexception) |
ComplexPtrConst | getComplex (const std::string key) throw (LCMexception) |
ComplexPtrConst | getComplex (const int_32 iset) throw (LCMexception) |
StringVecPtr | keys () throw (LCMexception) |
void | put (const std::string key, IntPtr myArray, const int_32 myLength) throw (LCMexception) |
void | put (const int_32 iset, IntPtr myArray, const int_32 myLength) throw (LCMexception) |
void | put (const std::string key, FloatPtr myArray, const int_32 myLength) throw (LCMexception) |
void | put (const int_32 iset, FloatPtr myArray, const int_32 myLength) throw (LCMexception) |
void | put (const std::string key, StringPtr myArray) throw (LCMexception) |
void | put (const int_32 iset, StringPtr myArray) throw (LCMexception) |
void | put (const std::string key, StringVecPtr myArray) throw (LCMexception) |
void | put (const int_32 iset, StringVecPtr myArray) throw (LCMexception) |
void | put (const std::string key, DoublePtr myArray, const int_32 myLength) throw (LCMexception) |
void | put (const int_32 iset, DoublePtr myArray, const int_32 myLength) throw (LCMexception) |
void | put (const std::string key, BoolPtr myArray, const int_32 myLength) throw (LCMexception) |
void | put (const int_32 iset, BoolPtr myArray, const int_32 myLength) throw (LCMexception) |
void | put (const std::string key, ComplexPtr myArray, const int_32 myLength) throw (LCMexception) |
void | put (const int_32 iset, ComplexPtr myArray, const int_32 myLength) throw (LCMexception) |
void | put (const std::string key, ClcmPtr myClcm) throw (LCMexception) |
void | put (const int_32 iset, ClcmPtr myClcm) throw (LCMexception) |
lcm * | extract () |
Friends | |
std::ostream & | operator<< (std::ostream &s, ClcmPtr myClcm) throw (LCMexception) |
This class is an implementation of the C++/Boost bindings for LCM. LCM capabilities are available for a program written in C++ by using methods belonging to the Clcm class. These methods encapsulate the LCM C API calls used as "extern"C" functions.
A Clcm object in C++ can encapsulate a native LCM object which can be memory-resident or persistent (using the XSM C API) or a file. A LCM or XSM native object can contains dictionaries (aka associative tables or hash tables) and lists.
The Clcm class uses predefined declarations for some datatypes:
#define IntPtr : | boost::shared_array<int_32> |
#define FloatPtr : | boost::shared_array<float_32> |
#define StringPtr : | boost::shared_ptr<std::string> |
#define DoublePtr : | boost::shared_array<double_64> |
#define BoolPtr : | boost::shared_array<bool> |
#define ComplexPtr : | boost::shared_array< complex<float_32> > |
#define StringVecPtr : | boost::shared_ptr< std::vector<std::string> > |
#define ClcmPtr : | boost::shared_ptr<Clcm> |
Moreover, get methods are constructing shared arrays that cannot be modified in the calling C++ code. To prevent this, they are declared const
using the following predefined declarations:
#define IntPtrConst : | boost::shared_array<const int_32> |
#define FloatPtrConst : | boost::shared_array<const float_32> |
#define StringPtrConst : | boost::shared_ptr<const std::string> |
#define DoublePtrConst : | boost::shared_array<const double_64> |
#define BoolPtrConst : | boost::shared_array<const bool> |
#define ComplexPtrConst : | boost::shared_array<const complex<float_32> > |
ganlib::Clcm::Clcm | ( | const std::string | stype, |
const std::string | myName, | ||
const std::string | myPath | ||
) | throw (LCMexception) |
Use this constructor to create a Clcm object of a specified type. The new LCM object is open in modification mode and is in a state such that the isNew()
method will return true
. If a XSM file name
exists, the Clcm object is pointing to this file open in "READ-ONLY"
mode and is in a state such that the isNew()
method will return false
. If the type is "LCM_IMP"
or "XSM_IMP"
, the new LCM object is open in modification mode and the isNew()
method will return false
.
A Clcm object is created using a construct similar to the following one:
ClcmPtr myNewClcm = ClcmPtr(new Clcm("XSM_IMP_ASCII", "Multicompo", "./"));
where a XSM file is imported from ASCII file ./Multicompo
.
stype | type of the new Clcm object. This variable is chosen among the following values:
|
myName | creation name of the new Clcm object |
myPath | path to access the associated file. This can be a sequential import file (with "_" prefix), an "XSM" , "BINARY" , "ASCII" or "DA" file. Set to "./" to work in the current directory. |
ganlib::Clcm::Clcm | ( | const std::string | stype, |
ClcmPtr | myClcm | ||
) | throw (LCMexception) |
Use this constructor to create a clone of an existing Clcm object. This is a deep-copy operation. A clone is created using the following construct:
ClcmPtr myClcmClone = ClcmPtr(new Clcm("LCM", myClcm));
stype | type of the new Clcm object. This variable is chosen among the following values:
|
myClcm | existing ClcmPtr object accessed in read-only mode. This object must me of LCM or XSM type. |
ganlib::Clcm::Clcm | ( | lcm * | mylcm, |
const int_32 | type, | ||
const int_32 | access, | ||
const std::string | OSname | ||
) |
Use this constructor to encapsulate an open LCM or XSM object into a Clcm object. The existing LCM or XSM object is not garbage collected (it may belong to another Clcm object).
mylcm | existing LCM or XSM object. |
type | type of object (=1: LCM; =2:XSM). |
access | access mode of object (=1: ; =2:). |
OSname | operating system name of object. |
ganlib::Clcm::~Clcm | ( | ) |
void ganlib::Clcm::close | ( | const std::string | saccess | ) | throw (LCMexception) |
Close a Clcm object.
saccess | ="KEEP" : close without destruction of the object content; ="DESTROY" : close with destruction of the object content. |
void ganlib::Clcm::except | ( | ) |
Cause an exception (used to debug XABORT in C++).
void ganlib::Clcm::expor | ( | const std::string | stype | ) |
Serialize and save the object content on a sequential file. This method is not available for file-type Clcm objects. The name of the sequential file is the catenation of "_"
with the name of the Clcm object.
stype | type of the export file. This variable is chosen among the following values:
|
void ganlib::Clcm::expor | ( | const std::string | stype, |
const std::string | new_name | ||
) |
Serialize and save the object content on a sequential file. This method is not available for file-type Clcm objects.
stype | type of the export file. This variable is chosen among the following values:
|
new_name | name of the sequential file. This name must begin by character "_" . |
lcm * ganlib::Clcm::extract | ( | ) |
Extract the LCM structure.
int_32 ganlib::Clcm::getAccess | ( | ) | throw (LCMexception) |
Return the access type of a Clcm object.
BoolPtrConst ganlib::Clcm::getBool | ( | const std::string | key | ) | throw (LCMexception) |
Recover a boolean array from a dictionary-type Clcm object. General rule: Never try to modify, deallocate or free the object returned by getBool
. This method is not available for file-type Clcm objects.
key | key identification of the boolean array in the dictionary |
BoolPtr
object. BoolPtrConst ganlib::Clcm::getBool | ( | const int_32 | iset | ) | throw (LCMexception) |
Recover a boolean array from a list-type Clcm object. General rule: Never try to modify, deallocate or free the object returned by getBool
. This method is not available for file-type Clcm objects.
iset | index of the boolean array in the list. The first list element is stored at index 0. |
BoolPtr
object. ClcmPtr ganlib::Clcm::getClcm | ( | const std::string | key | ) | throw (LCMexception) |
ClcmPtr ganlib::Clcm::getClcm | ( | const int_32 | iset | ) | throw (LCMexception) |
ComplexPtrConst ganlib::Clcm::getComplex | ( | const std::string | key | ) | throw (LCMexception) |
Recover a complex array from a dictionary-type Clcm object. General rule: Never try to modify, deallocate or free the object returned by getComplex
. This method is not available for file-type Clcm objects.
key | key identification of the complex array in the dictionary |
ComplexPtr
object. ComplexPtrConst ganlib::Clcm::getComplex | ( | const int_32 | iset | ) | throw (LCMexception) |
Recover a complex array from a list-type Clcm object. General rule: Never try to modify, deallocate or free the object returned by getComplex
. This method is not available for file-type Clcm objects.
iset | index of the complex array in the list. The first list element is stored at index 0. |
ComplexPtr
object. string ganlib::Clcm::getDirectory | ( | ) | throw (LCMexception) |
DoublePtrConst ganlib::Clcm::getDouble | ( | const std::string | key | ) | throw (LCMexception) |
Recover a double precision real array from a dictionary-type Clcm object. General rule: Never try to modify, deallocate or free the object returned by getDouble
. This method is not available for file-type Clcm objects.
key | key identification of the double precision array in the dictionary |
DoublePtr
object. DoublePtrConst ganlib::Clcm::getDouble | ( | const int_32 | iset | ) | throw (LCMexception) |
Recover a double precision real array from a list-type Clcm object. General rule: Never try to modify, deallocate or free the object returned by getDouble
. This method is not available for file-type Clcm objects.
iset | index of the double precision array in the list. The first list element is stored at index 0. |
DoublePtr
object. FloatPtrConst ganlib::Clcm::getFloat | ( | const std::string | key | ) | throw (LCMexception) |
Recover a single precision real array from a dictionary-type Clcm object. General rule: Never try to modify, deallocate or free the object returned by getFloat
. This method is not available for file-type Clcm objects.
key | key identification of the real array in the dictionary |
FloatPtr
object. FloatPtrConst ganlib::Clcm::getFloat | ( | const int_32 | iset | ) | throw (LCMexception) |
Recover a single precision real array from a list-type Clcm object. General rule: Never try to modify, deallocate or free the object returned by getFloat
. This method is not available for file-type Clcm objects.
iset | index of the real array in the list. The first list element is stored at index 0. |
FloatPtr
object. IntPtrConst ganlib::Clcm::getInt | ( | const std::string | key | ) | throw (LCMexception) |
Recover an integer array from a dictionary-type Clcm object. General rule: Never try to modify, deallocate or free the object returned by getInt
. This method is not available for file-type Clcm objects.
Example: An integer array named "myArray"
is read from Clcm object named multicompo
using
IntPtrConst ia = multicompo->getInt("myArray"); for(int i = 0; i < multicompo->length("myArray"); ++i) cout << "ia(" << i << ")=" << ia[i] << endl;
key | key identification of the integer array in the dictionary |
IntPtr
object. IntPtrConst ganlib::Clcm::getInt | ( | const int_32 | iset | ) | throw (LCMexception) |
Recover an integer array from a list-type Clcm object. General rule: Never try to modify, deallocate or free the object returned by getInt
. This method is not available for file-type Clcm objects.
iset | index of the integer array in the list. The first list element is stored at index 0. |
IntPtr
object. int_32 ganlib::Clcm::getLength | ( | ) | throw (LCMexception) |
int_32 ganlib::Clcm::getLrda | ( | ) | throw () |
Return the number of words in a record of a direct access-type Clcm object.
string ganlib::Clcm::getName | ( | ) | throw () |
Return the name of the Clcm object.
string ganlib::Clcm::getPath | ( | ) | throw () |
Return the path to access the associated file.
StringPtrConst ganlib::Clcm::getString | ( | const std::string | key | ) | throw (LCMexception) |
Recover a string pointer from a dictionary-type Clcm object. General rule: Never try to modify, deallocate or free the string returned by getString
. This method is not available for file-type Clcm objects.
key | key identification of the character array in the dictionary |
StringPtr
object. StringPtrConst ganlib::Clcm::getString | ( | const int_32 | iset | ) | throw (LCMexception) |
Recover a string pointer from a list-type Clcm object. General rule: Never try to modify, deallocate or free the string returned by getString
. This method is not available for file-type Clcm objects.
iset | index of the integer array in the list. The first list element is stored at index 0. |
StringPtr
object. int_32 ganlib::Clcm::getType | ( | ) | throw () |
Return the type of the Clcm object.
StringVecPtr ganlib::Clcm::getVecString | ( | const std::string | key, |
const int_32 | size | ||
) | throw (LCMexception) |
Recover a vector-of-string pointer from a dictionary-type Clcm object. General rule: Never try to modify, deallocate or free the vector-of-string returned by getVecString
. This method is not available for file-type Clcm objects.
key | key identification of the character array in the dictionary |
size | number of components in the vector-of-string |
StringVecPtr
object. StringVecPtr ganlib::Clcm::getVecString | ( | const int_32 | iset, |
const int_32 | size | ||
) | throw (LCMexception) |
Recover a vector-of-string pointer from a list-type Clcm object. General rule: Never try to modify, deallocate or free the vector-of-string returned by getVecString
. This method is not available for file-type Clcm objects.
iset | index of the integer array in the list. The first list element is stored at index 0. |
size | number of components in the vector-of-string |
StringVecPtr
object. int_32 ganlib::Clcm::getVersion | ( | ) | throw () |
Return the original version of the imported object.
bool ganlib::Clcm::isEmpty | ( | ) | throw (LCMexception) |
bool ganlib::Clcm::isNew | ( | ) | throw () |
StringVecPtr ganlib::Clcm::keys | ( | ) | throw (LCMexception) |
Recover a vector-of-string pointer containing the keys of a dictionary-type Clcm object. General rule: Never try to modify, deallocate or free the vector-of-string returned by keys
. This method is not available for file-type or list-type Clcm objects.
StringVecPtr
of a vector-of-string containing the dictionary keys int_32 ganlib::Clcm::length | ( | const std::string | key | ) | throw (LCMexception) |
Return the length of a block of information in a dictionary-type Clcm object. This method is not available for file-type Clcm objects.
key | key identification of the block in the dictionary |
int_32 ganlib::Clcm::length | ( | const int_32 | iset | ) | throw (LCMexception) |
Return the length of a block of information in a list-type Clcm object. This method is not available for file-type Clcm objects.
iset | index of the block in the list. The first list element is stored at index 0. |
void ganlib::Clcm::lib | ( | ) | throw (LCMexception) |
void ganlib::Clcm::open | ( | const std::string | saccess | ) | throw (LCMexception) |
Open a new Clcm object or reopen an existing Clcm object already closed by the close("KEEP"
) method. In this case, the Clcm object is reopen in a state such as the isNew()
method will return false.
saccess | type of open. This variable is chosen among the following values:
|
void ganlib::Clcm::put | ( | const std::string | key, |
IntPtr | myArray, | ||
const int_32 | myLength | ||
) | throw (LCMexception) |
Store an integer array in a dictionary-type Clcm object. This method is not available for file-type Clcm objects.
Example: An integer array named "myIntArray"
is inserted in Clcm object named multicompo
using
static int_32 myStaticArray[] = {33, 22, 11, 89}; IntPtr myIntPtr = IntPtr(new int_32[4]); for(int i = 0; i < 4; ++i) myIntPtr[i] = myStaticArray[i]; multicompo->put("myIntArray", myIntPtr, 4);
key | key identification of the block in the dictionary |
myArray | integer array stored as IntPtr object. |
myLength | number of components in integer array. |
void ganlib::Clcm::put | ( | const int_32 | iset, |
IntPtr | myArray, | ||
const int_32 | myLength | ||
) | throw (LCMexception) |
Store an integer array in a list-type Clcm object. This method is not available for file-type Clcm objects.
iset | index of the integer array in the list. The first list element is stored at index 0. |
myArray | integer array stored as IntPtr object. |
myLength | number of components in integer array. |
void ganlib::Clcm::put | ( | const std::string | key, |
FloatPtr | myArray, | ||
const int_32 | myLength | ||
) | throw (LCMexception) |
void ganlib::Clcm::put | ( | const int_32 | iset, |
FloatPtr | myArray, | ||
const int_32 | myLength | ||
) | throw (LCMexception) |
Store a single precision real array in a list-type Clcm object. This method is not available for file-type Clcm objects.
iset | index of the real array in the list. The first list element is stored at index 0. |
myArray | single precision real array stored as FloatPtr object. |
myLength | number of components in real array. |
void ganlib::Clcm::put | ( | const std::string | key, |
StringPtr | myArray | ||
) | throw (LCMexception) |
void ganlib::Clcm::put | ( | const int_32 | iset, |
StringPtr | myArray | ||
) | throw (LCMexception) |
void ganlib::Clcm::put | ( | const std::string | key, |
StringVecPtr | myArray | ||
) | throw (LCMexception) |
void ganlib::Clcm::put | ( | const int_32 | iset, |
StringVecPtr | myArray | ||
) | throw (LCMexception) |
Store a vector-of-string pointer in a list-type Clcm object. This method is not available for file-type Clcm objects.
iset | index of the character array in the list. The first list element is stored at index 0. |
myArray | vector-of-string containing the character information stored as StringVecPtr object. |
void ganlib::Clcm::put | ( | const std::string | key, |
DoublePtr | myArray, | ||
const int_32 | myLength | ||
) | throw (LCMexception) |
Store a double precision real array in a dictionary-type Clcm object. This method is not available for file-type Clcm objects.
key | key identification of the double precision array in the dictionary |
myArray | double precision array stored as DoublePtr object. |
myLength | number of components in double precision array. |
void ganlib::Clcm::put | ( | const int_32 | iset, |
DoublePtr | myArray, | ||
const int_32 | myLength | ||
) | throw (LCMexception) |
Store a double precision real array in a list-type Clcm object. This method is not available for file-type Clcm objects.
iset | index of the double precision array in the list. The first list element is stored at index 0. |
myArray | double precision array stored as DoublePtr object. |
myLength | number of components in double precision array. |
void ganlib::Clcm::put | ( | const std::string | key, |
BoolPtr | myArray, | ||
const int_32 | myLength | ||
) | throw (LCMexception) |
void ganlib::Clcm::put | ( | const int_32 | iset, |
BoolPtr | myArray, | ||
const int_32 | myLength | ||
) | throw (LCMexception) |
Store a boolean array in a list-type Clcm object. This method is not available for file-type Clcm objects.
iset | index of the boolean array in the list. The first list element is stored at index 0. |
myArray | boolean array stored as BoolPtr object. |
myLength | number of components in boolean array. |
void ganlib::Clcm::put | ( | const std::string | key, |
ComplexPtr | myArray, | ||
const int_32 | myLength | ||
) | throw (LCMexception) |
Store a complex array in a dictionary-type Clcm object. This method is not available for file-type Clcm objects.
Example: A complex array named "myComplArray"
is inserted in Clcm object named multicompo
using
ComplexPtr myComplexPtr = ComplexPtr(new complex<float_32>[2]); myComplexPtr[0] = complex<float_32>(3.3, 8.9); myComplexPtr[1] = complex<float_32>(-3.3, 7.9); multicompo->put("myComplArray", myComplexPtr, 2);
key | key identification of the block in the dictionary |
myArray | complex array stored as ComplexPtr object. |
myLength | number of components in complex array. |
void ganlib::Clcm::put | ( | const int_32 | iset, |
ComplexPtr | myArray, | ||
const int_32 | myLength | ||
) | throw (LCMexception) |
Store a complex array in a list-type Clcm object. This method is not available for file-type Clcm objects.
iset | index of the complex array in the list. The first list element is stored at index 0. |
myArray | complex array stored as ComplexPtr object. |
myLength | number of components in complex array. |
void ganlib::Clcm::put | ( | const std::string | key, |
ClcmPtr | myClcm | ||
) | throw (LCMexception) |
void ganlib::Clcm::put | ( | const int_32 | iset, |
ClcmPtr | myClcm | ||
) | throw (LCMexception) |
ClcmPtr ganlib::Clcm::setDictionary | ( | const std::string | key | ) | throw (LCMexception) |
ClcmPtr ganlib::Clcm::setDictionary | ( | const int_32 | iset | ) | throw (LCMexception) |
ClcmPtr ganlib::Clcm::setList | ( | const std::string | key, |
const int_32 | ilong | ||
) | throw (LCMexception) |
Set a daughter list-type Clcm object from a dictionary-type Clcm object. This method is not available for file-type Clcm objects.
key | key identification of the daughter Clcm object in the dictionary |
ilong | initial length of the heterogeneous list |
ClcmPtr ganlib::Clcm::setList | ( | const int_32 | iset, |
const int_32 | ilong | ||
) | throw (LCMexception) |
Set a daughter list-type Clcm object from a list-type Clcm object This method is not available for file-type Clcm objects.
iset | index of the daughter Clcm object in the list. The first list element is stored at index 0. |
ilong | initial length of the heterogeneous list |
int_32 ganlib::Clcm::type | ( | const std::string | key | ) | throw (LCMexception) |
Return the type of a block of information in a dictionary-type Clcm object. This method is not available for file-type Clcm objects.
key | key identification of the block in the dictionary |
int_32 ganlib::Clcm::type | ( | const int_32 | iset | ) | throw (LCMexception) |
Return the type of a block of information in a list-type Clcm object. This method is not available for file-type Clcm objects.
iset | index of the block in the list. The first list element is stored at index 0. |
void ganlib::Clcm::val | ( | ) | throw (LCMexception) |
|
friend |
Export a Clcm object into an ostream (ascii stream). This method is not available for file-type Clcm objects. A Clcm object can be dumped to the standard output using:
cout << myClcm;
s | initial std::ostream objet. |
myClcm | ClcmPtr object to export. |