EZC3D
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ezc3d::ParametersNS::GroupNS::Parameter Class Reference

Parameter of a C3D file. More...

#include <Parameter.h>

Public Member Functions

 Parameter (const std::string &name="", const std::string &description="")
 Create an empty parameter. More...
 
void print () const
 Print the parameter and its values.
 
void write (std::fstream &f, int groupIdx, std::streampos &dataStartPosition) const
 Write the parameter to an opened file. More...
 
int read (c3d &c3d, const Parameters &params, std::fstream &file, int nbCharInName)
 Read and store a parameter from an opened C3D file. More...
 
const std::string & name () const
 Get the name of the parameter. More...
 
void name (const std::string name)
 Set the name of the parameter. More...
 
const std::string & description () const
 Get the description of the parameter. More...
 
void description (const std::string description)
 Set the description of the parameter. More...
 
bool isLocked () const
 Get the locking status of the parameter. More...
 
void lock ()
 Set the locking status of the parameter to true.
 
void unlock ()
 Set the locking status of the parameter to false.
 
const std::vector< size_t > dimension () const
 Return the vector mapping the dimension of the parameter matrix. More...
 
bool isDimensionConsistent (size_t dataSize, const std::vector< size_t > &dimension) const
 Check if the dimension parameter is consistent with the values. More...
 
ezc3d::DATA_TYPE type () const
 Return the type of the data. More...
 
const std::vector< int > & valuesAsByte () const
 Return the vector of values of the parameter. More...
 
const std::vector< int > & valuesAsInt () const
 Return the vector of values of the parameter. More...
 
const std::vector< float > & valuesAsFloat () const
 Return the vector of values of the parameter. More...
 
const std::vector< std::string > & valuesAsString () const
 Return the vector of values of the parameter. More...
 
void set (int data)
 Set the integer scalar value for the parameter. More...
 
void set (size_t data)
 Set the size_t scalar value as integer for the parameter. More...
 
void set (const std::vector< int > &data, const std::vector< size_t > &dimension={})
 Set the integer vector of values for the parameter. More...
 
void set (float data)
 Set the float scalar value for the parameter. More...
 
void set (double data)
 Set the double scalar value as float for the parameter. More...
 
void set (const std::vector< float > &data, const std::vector< size_t > &dimension={})
 Set the float vector of values for the parameter. More...
 
void set (const std::string &data)
 Set the single string value for the parameter. More...
 
void set (const std::vector< std::string > &data, const std::vector< size_t > &dimension={})
 Set the vector of strings for the parameter. More...
 

Protected Member Functions

size_t writeImbricatedParameter (std::fstream &f, const std::vector< size_t > &dim, size_t currentIdx=0, size_t cmp=0) const
 Write a matrix of parameter to a file. More...
 

Protected Attributes

std::string _name
 The name of the parameter.
 
std::string _description
 The description of the parameter.
 
bool _isLocked
 The lock status of the parameter.
 
ezc3d::DATA_TYPE _data_type
 The type of data (int, float or string) the parameter is.
 
std::vector< size_t > _dimension
 Mapping of the data vector to the matrix of parameter.
 
std::vector< int > _param_data_int
 Parameter values if the parameter type is DATA_TYPE::BYTE of DATA_TYPE::INT.
 
std::vector< float > _param_data_float
 Parameter values if the parameter type is DATA_TYPE::FLOAT.
 
std::vector< std::string > _param_data_string
 Parameter values if the parameter type is DATA_TYPE::CHAR.
 

Detailed Description

Parameter of a C3D file.

Definition at line 16 of file Parameter.h.

Constructor & Destructor Documentation

◆ Parameter()

ezc3d::ParametersNS::GroupNS::Parameter::Parameter ( const std::string &  name = "",
const std::string &  description = "" 
)

Create an empty parameter.

Parameters
nameThe name of the parameter
descriptionThe description of the parameter

Definition at line 13 of file Parameter.cpp.

Member Function Documentation

◆ description() [1/2]

const std::string & ezc3d::ParametersNS::GroupNS::Parameter::description ( ) const

Get the description of the parameter.

Returns
The description of the parameter

Definition at line 203 of file Parameter.cpp.

◆ description() [2/2]

void ezc3d::ParametersNS::GroupNS::Parameter::description ( const std::string  description)

Set the description of the parameter.

Parameters
descriptionThe description of the parameter

Definition at line 208 of file Parameter.cpp.

◆ dimension()

const std::vector< size_t > ezc3d::ParametersNS::GroupNS::Parameter::dimension ( ) const

Return the vector mapping the dimension of the parameter matrix.

Returns
The vector mapping the dimension of the parameter matrix

A parameter can have multiple values organized in vector or matrix. This parameter keeps track of the dimension of the parameter. For example, if dimension == {2, 3, 4}, then the values of the parameters are organized into a 3-dimensional fashion with rows == 2, columns == 3 and sheets == 4.

Definition at line 228 of file Parameter.cpp.

◆ isDimensionConsistent()

bool ezc3d::ParametersNS::GroupNS::Parameter::isDimensionConsistent ( size_t  dataSize,
const std::vector< size_t > &  dimension 
) const

Check if the dimension parameter is consistent with the values.

Parameters
dataSizeThe size of the STL vector of the parameter
dimensionThe dimension mapping of the parameter matrix
Returns
If the dimension is consistent with the parameter size

The dimension of a parameter would be considered consistent if the product of all its values equals the dataSize. For example, if dimension == {2, 3, 4}, a consistent dataSize would be 24 (2*3*4).

Definition at line 233 of file Parameter.cpp.

◆ isLocked()

bool ezc3d::ParametersNS::GroupNS::Parameter::isLocked ( ) const

Get the locking status of the parameter.

Returns
The locking status of the parameter

Definition at line 213 of file Parameter.cpp.

◆ name() [1/2]

const std::string & ezc3d::ParametersNS::GroupNS::Parameter::name ( ) const

Get the name of the parameter.

Returns
The name of the parameter

Definition at line 193 of file Parameter.cpp.

◆ name() [2/2]

void ezc3d::ParametersNS::GroupNS::Parameter::name ( const std::string  name)

Set the name of the parameter.

Parameters
nameThe name of the parameter

Definition at line 198 of file Parameter.cpp.

◆ read()

int ezc3d::ParametersNS::GroupNS::Parameter::read ( ezc3d::c3d c3d,
const Parameters params,
std::fstream &  file,
int  nbCharInName 
)

Read and store a parameter from an opened C3D file.

Parameters
c3dC3D reference to copy the data in
paramsReference to a valid parameter
fileThe file stream already opened with read access
nbCharInNameThe number of character of the parameter name
Returns
The position in the file of the next Group/Parameter

Definition at line 132 of file Parameter.cpp.

◆ set() [1/8]

void ezc3d::ParametersNS::GroupNS::Parameter::set ( int  data)

Set the integer scalar value for the parameter.

Parameters
dataThe integer data

Set the scalar value for a parameter assuming this value is an integer.

Definition at line 258 of file Parameter.cpp.

◆ set() [2/8]

void ezc3d::ParametersNS::GroupNS::Parameter::set ( size_t  data)

Set the size_t scalar value as integer for the parameter.

Parameters
dataThe size_t scalar data

Set the scalar value as integer for a parameter assuming this value is an size_t.

Definition at line 263 of file Parameter.cpp.

◆ set() [3/8]

void ezc3d::ParametersNS::GroupNS::Parameter::set ( const std::vector< int > &  data,
const std::vector< size_t > &  dimension = {} 
)

Set the integer vector of values for the parameter.

Parameters
dataThe integer data
dimensionThe vector mapping of the dimension of the parameter matrix

Set the values for a parameter assuming these values are integers. If no dimension mapping is provided, it assumes to be a scalar if the data is the size of 1 or a vector if the data has a size higher than 1.

Definition at line 268 of file Parameter.cpp.

◆ set() [4/8]

void ezc3d::ParametersNS::GroupNS::Parameter::set ( float  data)

Set the float scalar value for the parameter.

Parameters
dataThe float data

Set the scalar value for a parameter assuming this value is a float.

Definition at line 283 of file Parameter.cpp.

◆ set() [5/8]

void ezc3d::ParametersNS::GroupNS::Parameter::set ( double  data)

Set the double scalar value as float for the parameter.

Parameters
dataThe double data

Set the scalar value as a flot for a parameter assuming this value is a double.

Definition at line 288 of file Parameter.cpp.

◆ set() [6/8]

void ezc3d::ParametersNS::GroupNS::Parameter::set ( const std::vector< float > &  data,
const std::vector< size_t > &  dimension = {} 
)

Set the float vector of values for the parameter.

Parameters
dataThe float data
dimensionThe vector mapping of the dimension of the parameter matrix

Set the values for a parameter assuming these values are floats. If no dimension mapping is provided, it assumes to be a scalar if the data is the size of 1 or a vector if the data has a size higher than 1.

Definition at line 293 of file Parameter.cpp.

◆ set() [7/8]

void ezc3d::ParametersNS::GroupNS::Parameter::set ( const std::string &  data)

Set the single string value for the parameter.

Parameters
dataThe string data

Definition at line 308 of file Parameter.cpp.

◆ set() [8/8]

void ezc3d::ParametersNS::GroupNS::Parameter::set ( const std::vector< std::string > &  data,
const std::vector< size_t > &  dimension = {} 
)

Set the vector of strings for the parameter.

Parameters
dataThe vector of strings
dimensionThe vector mapping of the dimension of the parameter matrix

Set the vector of strings for a parameter. If no dimension mapping is provided, it assumes to be a single string if the data is the size of 1 or a vector if the data has a size higher than 1.

Definition at line 313 of file Parameter.cpp.

◆ type()

ezc3d::DATA_TYPE ezc3d::ParametersNS::GroupNS::Parameter::type ( ) const

Return the type of the data.

Returns
The type of the data

Definition at line 253 of file Parameter.cpp.

◆ valuesAsByte()

const std::vector< int > & ezc3d::ParametersNS::GroupNS::Parameter::valuesAsByte ( ) const

Return the vector of values of the parameter.

Returns
The vector of values of the parameter

Return the vector of values that was previously stored into the parameter.

Throw an std::invalid_argument if the asked type was wrong (i.e. not DATA_TYPE::BYTE).

Definition at line 336 of file Parameter.cpp.

◆ valuesAsFloat()

const std::vector< float > & ezc3d::ParametersNS::GroupNS::Parameter::valuesAsFloat ( ) const

Return the vector of values of the parameter.

Returns
The vector of values of the parameter

Return the vector of values that was previously stored into the parameter.

Throw an std::invalid_argument if the asked type was wrong (i.e. not DATA_TYPE::FLOAT).

Definition at line 350 of file Parameter.cpp.

◆ valuesAsInt()

const std::vector< int > & ezc3d::ParametersNS::GroupNS::Parameter::valuesAsInt ( ) const

Return the vector of values of the parameter.

Returns
The vector of values of the parameter

Return the vector of values that was previously stored into the parameter.

Throw an std::invalid_argument if the asked type was wrong (i.e. not DATA_TYPE::INT).

Definition at line 343 of file Parameter.cpp.

◆ valuesAsString()

const std::vector< std::string > & ezc3d::ParametersNS::GroupNS::Parameter::valuesAsString ( ) const

Return the vector of values of the parameter.

Returns
The vector of values of the parameter

Return the vector of values that was previously stored into the parameter.

Throw an std::invalid_argument if the asked type was wrong (i.e. not DATA_TYPE::STRING).

Definition at line 357 of file Parameter.cpp.

◆ write()

void ezc3d::ParametersNS::GroupNS::Parameter::write ( std::fstream &  f,
int  groupIdx,
std::streampos &  dataStartPosition 
) const

Write the parameter to an opened file.

Parameters
fAlready opened fstream file with write access
groupIdxIndex of the group that this particular parameter is in
dataStartPositionThe position in the file where the data start (special case for POINT:DATA_START parameter)

Write the parameter and its values to a file

Definition at line 44 of file Parameter.cpp.

◆ writeImbricatedParameter()

size_t ezc3d::ParametersNS::GroupNS::Parameter::writeImbricatedParameter ( std::fstream &  f,
const std::vector< size_t > &  dim,
size_t  currentIdx = 0,
size_t  cmp = 0 
) const
protected

Write a matrix of parameter to a file.

Parameters
fThe file stream already opened with write access
dimThe dimension of the matrix of parameter
currentIdxInternal variable that keep track where it is in the matrix recursive calls. It should be set to 0 when called the first time.
cmpInternal variable that keep track where it is in the parameter recursive calls. It should be set to 0 when called the first time.
Returns
The internal variable cmp. It should be ignore by the user.

Definition at line 110 of file Parameter.cpp.


The documentation for this class was generated from the following files: