latest version v1.9 - last update 10 Apr 2010 |
Camera database. More...
#include <ltiFireWireDCAM.h>
Public Member Functions | |
nameDB () | |
~nameDB () | |
bool | use (const std::string &filename) |
bool | query (const std::string &name, u_int64_t &id) const |
bool | add (const std::string &name, u_int64_t &id) |
bool | del (const std::string &name) |
Protected Member Functions | |
bool | dump () |
bool | read (const std::string &filename) |
void | hexToString (const u_int64_t &data, std::string &str) const |
bool | stringToHex (const std::string &str, u_int64_t &data) const |
Protected Attributes | |
std::map< std::string, u_int64_t > | data_ |
std::string | filename_ |
mutex | lock_ |
bool | init_ |
bool | modified_ |
Camera database.
Just one instance of this class is used to manage the names of the available cameras.
lti::fireWireDCAM::nameDB::nameDB | ( | ) |
Default constructor.
Does nothing
lti::fireWireDCAM::nameDB::~nameDB | ( | ) |
Default destructor.
Saves all new data acquired in the file indicated by the use() method.
bool lti::fireWireDCAM::nameDB::add | ( | const std::string & | name, | |
u_int64_t & | id | |||
) |
Add a name,id pair.
true
if the pair could be successfully added or false
if there was a problem (usually, the name already existed! bool lti::fireWireDCAM::nameDB::del | ( | const std::string & | name | ) |
Delete an entry with the given name as key.
true
if the entry was removed or false
if some problem occured, for instance, the entry didn't exist. bool lti::fireWireDCAM::nameDB::dump | ( | ) | [protected] |
Dump the data_ into the file with the name filename_.
This does not lock! Do it outside the method.
true
if the file could be dumped or false
if an error occurred (like no use() called before) void lti::fireWireDCAM::nameDB::hexToString | ( | const u_int64_t & | data, | |
std::string & | str | |||
) | const [protected] |
Convert a 64 integer into a hex chain.
Since not all compilers behave the same with 64 bit chains, we better take charge ourselves of converting them into a chain of 16 nibbles preceded by 0x.
bool lti::fireWireDCAM::nameDB::query | ( | const std::string & | name, | |
u_int64_t & | id | |||
) | const |
bool lti::fireWireDCAM::nameDB::read | ( | const std::string & | filename | ) | [protected] |
Read the data_ from the file with the name filename
.
This does not lock! Do it outside the method.
true
if the file could be read or false
if an error occurred (like no use() called before) bool lti::fireWireDCAM::nameDB::stringToHex | ( | const std::string & | str, | |
u_int64_t & | data | |||
) | const [protected] |
Convert a 16 nibble string into a u_int64_t value.
The string has to begin with "0x" and continue with a number of less or exactly 16 hex digits
bool lti::fireWireDCAM::nameDB::use | ( | const std::string & | filename | ) |
Use the given file to serialize the data.
true
if the file can be successfully open and read, or if it does not exist, if it can be successfully created. std::map<std::string,u_int64_t> lti::fireWireDCAM::nameDB::data_ [protected] |
Map names to the identification numbers of cameras.
std::string lti::fireWireDCAM::nameDB::filename_ [protected] |
Filename in use (given by use() method).
bool lti::fireWireDCAM::nameDB::init_ [protected] |
The file has to be read just once!
This flag stores if it was read or not
mutex lti::fireWireDCAM::nameDB::lock_ [mutable, protected] |
Protect data.
bool lti::fireWireDCAM::nameDB::modified_ [protected] |
Flag to indicate if the database has been modified since the last read.