BTK  0.3dev.0
Open-source library to visualize/process biomechanical data
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
btk::MetaDataInfo Class Reference

Container class to store data of a MetaData object. More...

#include <btkMetaDataInfo.h>

Public Types

typedef btkSharedPtr< const
MetaDataInfo
ConstPointer
 
enum  Format { Char =-1, Byte =1, Integer =2, Real =4 }
 
typedef btkNullPtr< MetaDataInfoNullPointer
 
typedef btkSharedPtr
< MetaDataInfo
Pointer
 

Public Member Functions

Pointer Clone () const
 
uint8_t GetDimension (int idx) const
 
const std::vector< uint8_t > & GetDimensions () const
 
int GetDimensionsProduct (int start=0) const
 
Format GetFormat () const
 
std::string GetFormatAsString () const
 
void * GetValue (int idx) const
 
const std::vector< void * > & GetValues () const
 
bool HasValues () const
 
void ResizeDimensions (int nb)
 
void SetDimension (int idx, uint8_t val)
 
void SetDimensions (const std::vector< uint8_t > &dims)
 
void SetFormat (Format format)
 
void SetValue (int idx, int8_t val)
 
void SetValue (int idx, int16_t val)
 
void SetValue (int idx, float val)
 
void SetValue (int idx, const std::string &val)
 
void SetValue (int idx, int val)
 
void SetValue (int idx, double val)
 
void SetValues (int8_t val)
 
void SetValues (int16_t val)
 
void SetValues (float val)
 
void SetValues (const std::string &val)
 
void SetValues (const std::vector< int8_t > &val)
 
void SetValues (const std::vector< int16_t > &val)
 
void SetValues (const std::vector< float > &val)
 
void SetValues (const std::vector< std::string > &val)
 
void SetValues (const std::vector< uint8_t > &dims, const std::vector< int8_t > &val)
 
void SetValues (const std::vector< uint8_t > &dims, const std::vector< int16_t > &val)
 
void SetValues (const std::vector< uint8_t > &dims, const std::vector< float > &val)
 
void SetValues (const std::vector< uint8_t > &dims, const std::vector< std::string > &val)
 
double ToDouble (int idx) const
 
const std::vector< double > ToDouble () const
 
void ToDouble (std::vector< double > &val) const
 
float ToFloat (int idx) const
 
const std::vector< float > ToFloat () const
 
void ToFloat (std::vector< float > &val) const
 
int ToInt (int idx) const
 
const std::vector< int > ToInt () const
 
void ToInt (std::vector< int > &val) const
 
int16_t ToInt16 (int idx) const
 
const std::vector< int16_t > ToInt16 () const
 
void ToInt16 (std::vector< int16_t > &val) const
 
int8_t ToInt8 (int idx) const
 
const std::vector< int8_t > ToInt8 () const
 
void ToInt8 (std::vector< int8_t > &val) const
 
const std::string ToString (int idx) const
 
const std::vector< std::string > ToString () const
 
void ToString (std::vector< std::string > &val) const
 
unsigned int ToUInt (int idx) const
 
const std::vector< unsigned int > ToUInt () const
 
void ToUInt (std::vector< unsigned int > &val) const
 
uint16_t ToUInt16 (int idx) const
 
const std::vector< uint16_t > ToUInt16 () const
 
void ToUInt16 (std::vector< uint16_t > &val) const
 
uint8_t ToUInt8 (int idx) const
 
const std::vector< uint8_t > ToUInt8 () const
 
void ToUInt8 (std::vector< uint8_t > &val) const
 

Static Public Member Functions

static Pointer New (int8_t val)
 
static Pointer New (int16_t val)
 
static Pointer New (float val)
 
static Pointer New (const std::string &val)
 
static Pointer New (const std::vector< int8_t > &val)
 
static Pointer New (const std::vector< int16_t > &val)
 
static Pointer New (const std::vector< float > &val)
 
static Pointer New (const std::vector< std::string > &val)
 
static Pointer New (const std::vector< uint8_t > &dim, const std::vector< int8_t > &val)
 
static Pointer New (const std::vector< uint8_t > &dim, const std::vector< int16_t > &val)
 
static Pointer New (const std::vector< uint8_t > &dim, const std::vector< float > &val)
 
static Pointer New (const std::vector< uint8_t > &dim, const std::vector< std::string > &val)
 
static NullPointer Null ()
 

Protected Member Functions

 MetaDataInfo (const std::string &val)
 
 MetaDataInfo (const std::vector< std::string > &val)
 
 MetaDataInfo (const std::vector< uint8_t > &dims, const std::vector< int8_t > &val)
 
 MetaDataInfo (const std::vector< uint8_t > &dims, const std::vector< int16_t > &val)
 
 MetaDataInfo (const std::vector< uint8_t > &dims, const std::vector< float > &val)
 
 MetaDataInfo (const std::vector< uint8_t > &dims, const std::vector< std::string > &val)
 

Friends

bool operator!= (const MetaDataInfo &rLHS, const MetaDataInfo &rRHS)
 
bool operator== (const MetaDataInfo &rLHS, const MetaDataInfo &rRHS)
 

Detailed Description

Container class to store data of a MetaData object.

You can store integer value(s), real or string. This class has also methods to convert the native type into other, like integer into string.

Only four types can be stored into a MetaDataInfo object:

Member Typedef Documentation

Smart pointer associated with a const MetaDataInfo object.

Special null pointer associated with a MetaDataInfo object. This type should be used only internally to test the nullity of a smart pointer. See the static method Null() instead.

Smart pointer associated with a MetaDataInfo object.

Member Enumeration Documentation

Enums used to specify data format.

Enumerator
Char 

Enum value which represents the string.

Byte 

Enum value which represents the signed 8-bit integers.

Integer 

Enum value which represents the the signed 16-bit integers.

Real 

Enum value which represents the floats.

Constructor & Destructor Documentation

btk::MetaDataInfo::MetaDataInfo ( const std::string &  val)
protected

Constructor which store val in a Char format with a dimension equal to 1. The dimension's value is equal to the size of val.

btk::MetaDataInfo::MetaDataInfo ( const std::vector< std::string > &  val)
protected

Constructor which store val in a Char format as an array (array's dimensions automalicaly generated)

Warning
The number of values must be lower than 256 and the maximum length for the strings is equal to 255.
btk::MetaDataInfo::MetaDataInfo ( const std::vector< uint8_t > &  dims,
const std::vector< int8_t > &  val 
)
protected

Constructor which store val in a Byte format with the dimensions dims. If the product of the dimensions is not equal to the size of val, then the number of values is adjusted to fit with it. The value added is "0".

Warning
Each dimension must be lower than 256.
btk::MetaDataInfo::MetaDataInfo ( const std::vector< uint8_t > &  dims,
const std::vector< int16_t > &  val 
)
protected

Constructor which store val in an Integer format with the dimensions dims. If the product of the dimensions is not equal to the size of val, then the number of values is adjusted to fit with it. The value added is "0".

Warning
Each dimension must be lower than 256.
btk::MetaDataInfo::MetaDataInfo ( const std::vector< uint8_t > &  dims,
const std::vector< float > &  val 
)
protected

Constructor which store val in a Real format with the dimensions dims. If the product of the dimensions is not equal to the size of val, then the number of values is adjusted to fit with it. The value added is "0".

Warning
Each dimension must be lower than 256.
btk::MetaDataInfo::MetaDataInfo ( const std::vector< uint8_t > &  dims,
const std::vector< std::string > &  val 
)
protected

Constructor which store val in a Char format with the dimensions dims. If the product of the dimensions is not equal to the size of val, then the number of values is adjusted to fit with it. The value added is " " if the dimension is null. Otherwise, it is a string of white spaces. The size of this string corresponds to the first dimension.

Warning
Each dimension must be lower than 256.

Member Function Documentation

MetaDataInfo::Pointer btk::MetaDataInfo::Clone ( ) const
inline

Returns a deep copy of the object as a smart pointer.

uint8_t btk::MetaDataInfo::GetDimension ( int  idx) const

Returns the dimension for the given idx or 0 if idx is out of range.

const std::vector< uint8_t > & btk::MetaDataInfo::GetDimensions ( ) const
inline

Returns the dimensions associated with the values.

int btk::MetaDataInfo::GetDimensionsProduct ( int  start = 0) const

Compute the product of the dimensions from the idx start.

Format btk::MetaDataInfo::GetFormat ( ) const
inline

Returns the format of the values.

std::string btk::MetaDataInfo::GetFormatAsString ( ) const

Returns the format of the values as a string.

void * btk::MetaDataInfo::GetValue ( int  idx) const

Returns the value for the given idx or 0 if idx is out of range.

const std::vector< std::string > & btk::MetaDataInfo::GetValues ( ) const
inline

Returns the values as a vector of strings.

bool btk::MetaDataInfo::HasValues ( ) const
inline

Returns if there is or not some data.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( int8_t  val)
inlinestatic

Creates a smart pointer from the MetaDataInfo(int8_t) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( int16_t  val)
inlinestatic

Creates a smart pointer from the MetaDataInfo(int16_t) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( float  val)
inlinestatic

Creates a smart pointer from the MetaDataInfo(float) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( const std::string &  val)
inlinestatic

Creates a smart pointer from the MetaDataInfo(std::string) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( const std::vector< int8_t > &  val)
inlinestatic

Creates a smart pointer from the MetaDataInfo(const std::vector<int8_t>&) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( const std::vector< int16_t > &  val)
inlinestatic

Creates a smart pointer from the MetaDataInfo(const std::vector<int16_t>&) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( const std::vector< float > &  val)
inlinestatic

Creates a smart pointer from the MetaDataInfo(const std::vector<float>&) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( const std::vector< std::string > &  val)
inlinestatic

Creates a smart pointer from the MetaDataInfo(const std::vector<std::string>&) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( const std::vector< uint8_t > &  dim,
const std::vector< int8_t > &  val 
)
inlinestatic

Creates a smart pointer from the MetaDataInfo(const std::vector<uint8_t>&, const std::vector<int8_t>&) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( const std::vector< uint8_t > &  dim,
const std::vector< int16_t > &  val 
)
inlinestatic

Creates a smart pointer from the MetaDataInfo(const std::vector<uint8_t>&, const std::vector<int16_t>&) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( const std::vector< uint8_t > &  dim,
const std::vector< float > &  val 
)
inlinestatic

Creates a smart pointer from the MetaDataInfo(const std::vector<uint8_t>&, const std::vector<float>&) constructor.

MetaDataInfo::Pointer btk::MetaDataInfo::New ( const std::vector< uint8_t > &  dim,
const std::vector< std::string > &  val 
)
inlinestatic
static NullPointer btk::MetaDataInfo::Null ( )
inlinestatic

Static function to return a special null pointer type.

Note
This static method should be used only to test if a shared ponter is null or not. It is advised to call the method without parenthesis as special (in)equality operator are implemented to use a function pointer. See the description of the class NullPtr for an example.
void btk::MetaDataInfo::ResizeDimensions ( int  nb)

Resize the dimensions and adapt the values and their structure. If the number of dimensions is greater, then the new dimensions are equal to 1. If the number of dimensions is lower, then the values are shrunken.

void btk::MetaDataInfo::SetDimension ( int  idx,
uint8_t  val 
)

Sets val as the new dimension for the given idx or do nothing if idx is out of range. This method alterates the values' structure and set default values ("0" or a string with white spaces).

void btk::MetaDataInfo::SetDimensions ( const std::vector< uint8_t > &  dims)

Sets dims as the new dimensions and adapt the values and their structure. This method can add default values ("0" or a string with white spaces).

void btk::MetaDataInfo::SetFormat ( Format  format)

Sets the format of the values and adapt the values. This method erases the values and set default values ("0" or a string with white spaces).

void btk::MetaDataInfo::SetValue ( int  idx,
int8_t  val 
)

Sets val as the value for the given index idx.

Warning
This method does nothing if the idx is out of range.
void btk::MetaDataInfo::SetValue ( int  idx,
int16_t  val 
)

Sets val as the value (if necessary, adapt it to fit the format) for the given index idx.

Warning
This method does nothing if the idx is out of range.
void btk::MetaDataInfo::SetValue ( int  idx,
float  val 
)

Sets val as the value (if necessary, adapt it to fit the format) for the given index idx.

Warning
This method does nothing if the idx is out of range.
void btk::MetaDataInfo::SetValue ( int  idx,
const std::string &  val 
)

Sets val as the value (if necessary, adapt it to fit the format) for the given index idx. Dimensions are updated if necessary.

Warning
This method does nothing if the idx is out of range.
void btk::MetaDataInfo::SetValue ( int  idx,
int  val 
)

Sets val as the value (if necessary, adapt it to fit the format) for the given index idx.

Warning
This method does nothing if the idx is out of range.
void btk::MetaDataInfo::SetValue ( int  idx,
double  val 
)

Sets val as the value (if necessary, adapt it to fit the format) for the given index idx.

Warning
This method does nothing if the idx is out of range.
void btk::MetaDataInfo::SetValues ( int8_t  val)
inline

Overwrite the data to store val in a Byte format with a null dimension.

void btk::MetaDataInfo::SetValues ( int16_t  val)
inline

Overwrite the data to store val in a Integer format with a null dimension.

void btk::MetaDataInfo::SetValues ( float  val)
inline

Overwrite the data to store val in a Real format with a null dimension.

void btk::MetaDataInfo::SetValues ( const std::string &  val)
inline

Overwrite the data to store val in a Char format with one dimension equals to the size of the strings.

void btk::MetaDataInfo::SetValues ( const std::vector< int8_t > &  val)
inline

Overwrite the data to store val in a Byte format as a 1D vector.

Warning
The number of values must be lower than 256.
void btk::MetaDataInfo::SetValues ( const std::vector< int16_t > &  val)
inline

Overwrite the data to store val in a Integer format as a 1D vector.

Warning
The number of values must be lower than 256.
void btk::MetaDataInfo::SetValues ( const std::vector< float > &  val)
inline

Overwrite the data to store val in a Real format as a 1D vector.

Warning
The number of values must be lower than 256.
void btk::MetaDataInfo::SetValues ( const std::vector< std::string > &  val)

Overwrite the data to store val in a Char format as an array with auto-generated dimensions.

Warning
The number of values must be lower than 256. The string can have a maximum length of 255.
void btk::MetaDataInfo::SetValues ( const std::vector< uint8_t > &  dims,
const std::vector< int8_t > &  val 
)

Overwrite the data to store val in an Byte format with the dimensions dims. If the product of the dimensions is not equal to the size of val, then the number of values is adjusted to fit with it. The value added is "0".

Warning
Each dimension must be lower than 256.
void btk::MetaDataInfo::SetValues ( const std::vector< uint8_t > &  dims,
const std::vector< int16_t > &  val 
)

Overwrite the data to store val in an Integer format with the dimensions dims. If the product of the dimensions is not equal to the size of val, then the number of values is adjusted to fit with it. The value added is "0".

Warning
Each dimension must be lower than 256.
void btk::MetaDataInfo::SetValues ( const std::vector< uint8_t > &  dims,
const std::vector< float > &  val 
)

Overwrite the data to store val in an Real format with the dimensions dims. If the product of the dimensions is not equal to the size of val, then the number of values is adjusted to fit with it. The value added is "0".

Warning
Each dimension must be lower than 256.
void btk::MetaDataInfo::SetValues ( const std::vector< uint8_t > &  dims,
const std::vector< std::string > &  val 
)

Overwrite the data to store val in a Char format with the dimensions dims. If the product of the dimensions is not equal to the size of val, then the number of values is adjusted to fit with it. The value added is " " if the dimension is null. Otherwise, it is a string of white spaces. The size of this string corresponds to the first dimension.

Warning
Each dimension must be lower than 256.
double btk::MetaDataInfo::ToDouble ( int  idx) const

Convert stored value at index idx into double.

const std::vector< double > btk::MetaDataInfo::ToDouble ( ) const

Convert stored values into a vector of doubles.

void btk::MetaDataInfo::ToDouble ( std::vector< double > &  val) const

Convert stored values into a vector of doubles.

float btk::MetaDataInfo::ToFloat ( int  idx) const

Convert stored value at index idx into float.

const std::vector< float > btk::MetaDataInfo::ToFloat ( ) const

Convert stored values into a vector of floats.

void btk::MetaDataInfo::ToFloat ( std::vector< float > &  val) const

Convert stored values into a vector of floats.

int btk::MetaDataInfo::ToInt ( int  idx) const

Convert stored value at index idx into integer.

const std::vector< int > btk::MetaDataInfo::ToInt ( ) const

Convert stored values into a vector of integers.

void btk::MetaDataInfo::ToInt ( std::vector< int > &  val) const

Convert stored values into a vector of integers.

int16_t btk::MetaDataInfo::ToInt16 ( int  idx) const

Convert stored value at index idx into 16-bits integer.

const std::vector< int16_t > btk::MetaDataInfo::ToInt16 ( ) const

Convert stored values into a vector of 16-bits integers.

void btk::MetaDataInfo::ToInt16 ( std::vector< int16_t > &  val) const

Convert stored values into a vector of 16-bits integers.

int8_t btk::MetaDataInfo::ToInt8 ( int  idx) const

Convert stored value at index idx into 8-bits integer.

const std::vector< int8_t > btk::MetaDataInfo::ToInt8 ( ) const

Convert stored values into a vector of 8-bits integers.

void btk::MetaDataInfo::ToInt8 ( std::vector< int8_t > &  val) const

Convert stored values into a vector of 8-bits integers.

const std::string btk::MetaDataInfo::ToString ( int  idx) const

Convert stored value at index idx into string.

const std::vector< std::string > btk::MetaDataInfo::ToString ( ) const

Convert stored value at index idx into string.

void btk::MetaDataInfo::ToString ( std::vector< std::string > &  val) const

Convert stored values into a vector of strings.

unsigned int btk::MetaDataInfo::ToUInt ( int  idx) const

Convert stored value at index idx into unsigned integer.

const std::vector< unsigned int > btk::MetaDataInfo::ToUInt ( ) const

Convert stored values into a vector of unsigned integers.

void btk::MetaDataInfo::ToUInt ( std::vector< unsigned int > &  val) const

Convert stored values into a vector of unsigned integers.

uint16_t btk::MetaDataInfo::ToUInt16 ( int  idx) const

Convert stored value at index idx into 16-bits unsigned integer.

const std::vector< uint16_t > btk::MetaDataInfo::ToUInt16 ( ) const

Convert stored values into a vector of 16-bis unsigned integers.

void btk::MetaDataInfo::ToUInt16 ( std::vector< uint16_t > &  val) const

Convert stored values into a vector of 16-bits unsigned integers.

uint8_t btk::MetaDataInfo::ToUInt8 ( int  idx) const

Convert stored value at index idx into 8-bits unsigned integer.

const std::vector< uint8_t > btk::MetaDataInfo::ToUInt8 ( ) const

Convert stored values into a vector of 8-bits unsigned integers.

void btk::MetaDataInfo::ToUInt8 ( std::vector< uint8_t > &  val) const

Convert stored values into a vector of 8-bits unsigned integers.

Friends And Related Function Documentation

bool operator!= ( const MetaDataInfo rLHS,
const MetaDataInfo rRHS 
)
friend

Inequality operator.

bool operator== ( const MetaDataInfo rLHS,
const MetaDataInfo rRHS 
)
friend

Equality operator.