EZC3D
|
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 ¶ms, 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. | |
Parameter of a C3D file.
Definition at line 16 of file Parameter.h.
ezc3d::ParametersNS::GroupNS::Parameter::Parameter | ( | const std::string & | name = "" , |
const std::string & | description = "" |
||
) |
Create an empty parameter.
name | The name of the parameter |
description | The description of the parameter |
Definition at line 13 of file Parameter.cpp.
const std::string & ezc3d::ParametersNS::GroupNS::Parameter::description | ( | ) | const |
Get the description of the parameter.
Definition at line 203 of file Parameter.cpp.
void ezc3d::ParametersNS::GroupNS::Parameter::description | ( | const std::string | description | ) |
Set the description of the parameter.
description | The description of the parameter |
Definition at line 208 of file Parameter.cpp.
const std::vector< size_t > ezc3d::ParametersNS::GroupNS::Parameter::dimension | ( | ) | const |
Return 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.
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.
dataSize | The size of the STL vector of the parameter |
dimension | The dimension mapping of the parameter matrix |
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.
bool ezc3d::ParametersNS::GroupNS::Parameter::isLocked | ( | ) | const |
Get the locking status of the parameter.
Definition at line 213 of file Parameter.cpp.
const std::string & ezc3d::ParametersNS::GroupNS::Parameter::name | ( | ) | const |
Get the name of the parameter.
Definition at line 193 of file Parameter.cpp.
void ezc3d::ParametersNS::GroupNS::Parameter::name | ( | const std::string | name | ) |
Set the name of the parameter.
name | The name of the parameter |
Definition at line 198 of file Parameter.cpp.
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.
c3d | C3D reference to copy the data in |
params | Reference to a valid parameter |
file | The file stream already opened with read access |
nbCharInName | The number of character of the parameter name |
Definition at line 132 of file Parameter.cpp.
void ezc3d::ParametersNS::GroupNS::Parameter::set | ( | int | data | ) |
Set the integer scalar value for the parameter.
data | The integer data |
Set the scalar value for a parameter assuming this value is an integer.
Definition at line 258 of file Parameter.cpp.
void ezc3d::ParametersNS::GroupNS::Parameter::set | ( | size_t | data | ) |
Set the size_t scalar value as integer for the parameter.
data | The 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.
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.
data | The integer data |
dimension | The 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.
void ezc3d::ParametersNS::GroupNS::Parameter::set | ( | float | data | ) |
Set the float scalar value for the parameter.
data | The float data |
Set the scalar value for a parameter assuming this value is a float.
Definition at line 283 of file Parameter.cpp.
void ezc3d::ParametersNS::GroupNS::Parameter::set | ( | double | data | ) |
Set the double scalar value as float for the parameter.
data | The 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.
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.
data | The float data |
dimension | The 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.
void ezc3d::ParametersNS::GroupNS::Parameter::set | ( | const std::string & | data | ) |
Set the single string value for the parameter.
data | The string data |
Definition at line 308 of file Parameter.cpp.
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.
data | The vector of strings |
dimension | The 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.
ezc3d::DATA_TYPE ezc3d::ParametersNS::GroupNS::Parameter::type | ( | ) | const |
Return the type of the data.
Definition at line 253 of file Parameter.cpp.
const std::vector< int > & ezc3d::ParametersNS::GroupNS::Parameter::valuesAsByte | ( | ) | const |
Return 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.
const std::vector< float > & ezc3d::ParametersNS::GroupNS::Parameter::valuesAsFloat | ( | ) | const |
Return 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.
const std::vector< int > & ezc3d::ParametersNS::GroupNS::Parameter::valuesAsInt | ( | ) | const |
Return 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.
const std::vector< std::string > & ezc3d::ParametersNS::GroupNS::Parameter::valuesAsString | ( | ) | const |
Return 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.
void ezc3d::ParametersNS::GroupNS::Parameter::write | ( | std::fstream & | f, |
int | groupIdx, | ||
std::streampos & | dataStartPosition | ||
) | const |
Write the parameter to an opened file.
f | Already opened fstream file with write access |
groupIdx | Index of the group that this particular parameter is in |
dataStartPosition | The 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.
|
protected |
Write a matrix of parameter to a file.
f | The file stream already opened with write access |
dim | The dimension of the matrix of parameter |
currentIdx | Internal variable that keep track where it is in the matrix recursive calls. It should be set to 0 when called the first time. |
cmp | Internal variable that keep track where it is in the parameter recursive calls. It should be set to 0 when called the first time. |
Definition at line 110 of file Parameter.cpp.