The values with which a Device can tag a Frame. More...
#include <TagValue.h>
Public Types | |
enum | Type { Null = 0, Int, Float, Double, String, Time, IntVector, FloatVector, DoubleVector, StringVector, TimeVector } |
A TagValue can represent one of a number of types listed below. More... | |
Public Member Functions | |
bool | valid () |
Does this tag exist? That is, is type equal to Null. | |
std::string | toString () const |
Serialize into a human-and-python readable format. | |
std::string | toBlob () |
Serialize into a more efficient binary format. | |
Constructors | |
TagValue () | |
TagValue (int) | |
TagValue (float) | |
TagValue (double) | |
TagValue (std::string) | |
TagValue (FCam::Time) | |
TagValue (std::vector< int >) | |
TagValue (std::vector< float >) | |
TagValue (std::vector< double >) | |
TagValue (std::vector< std::string >) | |
TagValue (std::vector< FCam::Time >) | |
TagValue (const TagValue &) | |
Assignment | |
const TagValue & | operator= (const int &) |
const TagValue & | operator= (const float &) |
const TagValue & | operator= (const double &) |
const TagValue & | operator= (const std::string &) |
const TagValue & | operator= (const FCam::Time &) |
const TagValue & | operator= (const std::vector< int > &) |
const TagValue & | operator= (const std::vector< float > &) |
const TagValue & | operator= (const std::vector< double > &) |
const TagValue & | operator= (const std::vector< std::string > &) |
const TagValue & | operator= (const std::vector< FCam::Time > &) |
const TagValue & | operator= (const TagValue &) |
Cast Operators | |
A TagValue can be implicitly cast to the appropriate type. Trying to cast a TagValue to the wrong type will result in a default value returned and a BadCast error placed on the event queue. If you wish to inspect or modify a large tag value in-place (e.g. an IntVector), cast it to a reference to the appropriate type, rather than a concrete instance of that type. The latter will make a fresh copy of the potentially large data. For example: Frame frame = Sensor.getFrame(); // This makes a copy of a potentially large array std::vector<int> bigTag = frame["bigTag"]; // This does not, and so is usually what you want to do. std::vector<int> &bigTagRef = frame["bigTag"]; | |
operator int & () const | |
operator float & () const | |
operator double & () const | |
operator std::string & () const | |
operator FCam::Time & () const | |
operator std::vector< int > & () const | |
operator std::vector< float > & () const | |
operator std::vector< double > & () const | |
operator std::vector< std::string > & () const | |
operator std::vector< FCam::Time > & () const | |
Cast methods | |
A TagValue also has explicit methods to cast it to various types. These have the same semantics as the implicit casts, but are more readable in many cases. For example: TagValue tag = std::vector<int>(); // Use the overloaded cast operator ((std::vector<int> &)tag).push_back(3); // Do the same thing using the cast method tag.asIntVector().push_back(3); | |
int & | asInt () |
float & | asFloat () |
double & | asDouble () |
std::string & | asString () |
FCam::Time & | asTime () |
std::vector< int > & | asIntVector () |
std::vector< float > & | asFloatVector () |
std::vector< double > & | asDoubleVector () |
std::vector< std::string > & | asStringVector () |
std::vector< FCam::Time > & | asTimeVector () |
Static Public Member Functions | |
static TagValue | fromString (const std::string &) |
Deserialize from either format. | |
Public Attributes | |
Type | type |
The type of this tag. | |
void * | data |
A pointer to the actual value of this tag. | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &out, const TagValue &t) |
Serialize the TagValue into a human readable format. | |
std::istream & | operator>> (std::istream &in, TagValue &t) |
Deserialize a TagValue from either the human-readable or the binary format. |
The values with which a Device can tag a Frame.
Definition at line 16 of file TagValue.h.
enum FCam::TagValue::Type |
A TagValue can represent one of a number of types listed below.
Null |
A Null TagValue represents nothing, and indicates no such tag exists. |
Int |
A 32-bit signed integer. |
Float |
A 32-bit float. |
Double |
A 64-bit double. |
String |
An std::string. Also useful to represent a blob of binary data. |
Time |
A Time. |
IntVector |
A std::vector of ints. |
FloatVector |
A std::vector of floats. |
DoubleVector |
A std::vector of doubles. |
StringVector |
A std::vector of std::strings. |
TimeVector |
A std::vector of Times. |
Definition at line 21 of file TagValue.h.
bool FCam::TagValue::valid | ( | ) | [inline] |
Does this tag exist? That is, is type equal to Null.
Definition at line 140 of file TagValue.h.
std::string FCam::TagValue::toBlob | ( | ) |
Serialize into a more efficient binary format.
For tags containing large arrays of data, this format can be over 100x more time-efficient than the human readable format, and about 2.5x more space efficient.
Definition at line 705 of file TagValue.cpp.
std::istream & operator>> | ( | std::istream & | in, | |
TagValue & | t | |||
) | [related] |
Deserialize a TagValue from either the human-readable or the binary format.
Definition at line 1006 of file TagValue.cpp.
The type of this tag.
Definition at line 155 of file TagValue.h.
void* FCam::TagValue::data |
A pointer to the actual value of this tag.
Definition at line 158 of file TagValue.h.