EZC3D
Parameter.h
Go to the documentation of this file.
1 #ifndef PARAMETER_H
2 #define PARAMETER_H
3 
11 #include <ezc3d.h>
12 
17  //---- CONSTRUCTOR ----//
18 public:
24  Parameter(const std::string &name = "", const std::string &description = "");
25 
26 
27  //---- STREAM ----//
28 public:
32  void print() const;
33 
42  void write(std::fstream &f, int groupIdx, std::streampos &dataStartPosition) const;
43 
44 protected:
53  size_t writeImbricatedParameter(std::fstream &f, const std::vector<size_t> &dim, size_t currentIdx=0, size_t cmp=0) const;
54 
55 public:
64  int read(c3d &c3d,
65  const Parameters &params,
66  std::fstream &file,
67  int nbCharInName);
68 
69 
70  //---- METADATA ----//
71 protected:
72  std::string _name;
73  std::string _description;
74  bool _isLocked;
76 
77 public:
82  const std::string& name() const;
83 
88  void name(const std::string name);
89 
94  const std::string& description() const;
95 
100  void description(const std::string description);
101 
106  bool isLocked() const;
107 
111  void lock();
112 
116  void unlock();
117 
118 
119  //---- DATA DIMENSIONS ----//
120 protected:
121  std::vector<size_t> _dimension;
122 
123 public:
132  const std::vector<size_t> dimension() const;
133 
144  bool isDimensionConsistent(size_t dataSize, const std::vector<size_t>& dimension) const;
145 
146 
147  //---- DATA ----//
148 protected:
149  std::vector<int> _param_data_int;
150  std::vector<float> _param_data_float;
151  std::vector<std::string> _param_data_string;
152 
153 public:
158  ezc3d::DATA_TYPE type() const;
159 
168  const std::vector<int>& valuesAsByte() const;
169 
178  const std::vector<int>& valuesAsInt() const;
179 
188  const std::vector<float>& valuesAsFloat() const;
189 
198  const std::vector<std::string>& valuesAsString() const;
199 
206  void set(int data);
207 
214  void set(size_t data);
215 
225  void set(const std::vector<int>& data, const std::vector<size_t>& dimension = {});
226 
233  void set(float data);
234 
241  void set(double data);
242 
252  void set(const std::vector<float>& data, const std::vector<size_t>& dimension = {});
253 
258  void set(const std::string& data);
259 
269  void set(const std::vector<std::string>& data, const std::vector<size_t>& dimension = {});
270 
271 };
272 
273 
274 #endif
std::string _name
The name of the parameter.
Definition: Parameter.h:72
const std::vector< int > & valuesAsInt() const
Return the vector of values of the parameter.
Definition: Parameter.cpp:343
bool isDimensionConsistent(size_t dataSize, const std::vector< size_t > &dimension) const
Check if the dimension parameter is consistent with the values.
Definition: Parameter.cpp:233
Group holder of C3D parameters.
Definition: Parameters.h:16
void print() const
Print the parameter and its values.
Definition: Parameter.cpp:22
std::vector< float > _param_data_float
Parameter values if the parameter type is DATA_TYPE::FLOAT.
Definition: Parameter.h:150
bool _isLocked
The lock status of the parameter.
Definition: Parameter.h:74
void unlock()
Set the locking status of the parameter to false.
Definition: Parameter.cpp:223
ezc3d::DATA_TYPE type() const
Return the type of the data.
Definition: Parameter.cpp:253
std::vector< size_t > _dimension
Mapping of the data vector to the matrix of parameter.
Definition: Parameter.h:121
const std::vector< size_t > dimension() const
Return the vector mapping the dimension of the parameter matrix.
Definition: Parameter.cpp:228
std::vector< std::string > _param_data_string
Parameter values if the parameter type is DATA_TYPE::CHAR.
Definition: Parameter.h:151
Namespace ezc3d.
Definition: ezc3d.h:68
Parameter(const std::string &name="", const std::string &description="")
Create an empty parameter.
Definition: Parameter.cpp:13
const std::string & description() const
Get the description of the parameter.
Definition: Parameter.cpp:203
const std::string & name() const
Get the name of the parameter.
Definition: Parameter.cpp:193
std::string _description
The description of the parameter.
Definition: Parameter.h:73
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.
Definition: Parameter.cpp:110
bool isLocked() const
Get the locking status of the parameter.
Definition: Parameter.cpp:213
Main class for C3D holder.
Definition: ezc3d.h:154
void write(std::fstream &f, int groupIdx, std::streampos &dataStartPosition) const
Write the parameter to an opened file.
Definition: Parameter.cpp:44
ezc3d::DATA_TYPE _data_type
The type of data (int, float or string) the parameter is.
Definition: Parameter.h:75
const std::vector< std::string > & valuesAsString() const
Return the vector of values of the parameter.
Definition: Parameter.cpp:357
Declaration of ezc3d class.
const std::vector< float > & valuesAsFloat() const
Return the vector of values of the parameter.
Definition: Parameter.cpp:350
int read(c3d &c3d, const Parameters &params, std::fstream &file, int nbCharInName)
Read and store a parameter from an opened C3D file.
Definition: Parameter.cpp:132
const std::vector< int > & valuesAsByte() const
Return the vector of values of the parameter.
Definition: Parameter.cpp:336
std::vector< int > _param_data_int
Parameter values if the parameter type is DATA_TYPE::BYTE of DATA_TYPE::INT.
Definition: Parameter.h:149
DATA_TYPE
Enum that describes the size of different types.
Definition: ezc3d.h:73
Parameter of a C3D file.
Definition: Parameter.h:16
void lock()
Set the locking status of the parameter to true.
Definition: Parameter.cpp:218