MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

The values with which a Device can tag a Frame. More...

Collaboration diagram for FCam::TagValue:
Collaboration graph
[legend]

List of all members.

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 () const
  Serialize into a more efficient binary format.
Constructors

TagValues can be constructed from many different types.

The default constructor makes a Null TagValue. Each other constructor makes a copy of its argument.

  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

You assign to a TagValue from any of the types a TagValue supports.

This sets the TagValue to a copy of the argument.

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.

Detailed Description

The values with which a Device can tag a Frame.


Member Enumeration Documentation

A TagValue can represent one of a number of types listed below.

Enumerator:
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.


Member Function Documentation

bool FCam::TagValue::valid (  )  [inline]

Does this tag exist? That is, is type equal to Null.

std::string FCam::TagValue::toBlob (  )  const

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.


Friends And Related Function Documentation

std::istream & operator>> ( std::istream &  in,
TagValue t  
) [related]

Deserialize a TagValue from either the human-readable or the binary format.


Member Data Documentation

The type of this tag.

A pointer to the actual value of this tag.


Copyright (c) 2012, Nokia Corporation and/or its subsidiary(-ies). All rights reserved. See Copyright.
MeeGo 1.2 Harmattan API