Essentia  2.1-beta6-dev
parameter.h File Reference
#include <map>
#include <vector>
#include "types.h"
#include "utils/tnt/tnt_array2d.h"

Go to the source code of this file.

Classes

class  Parameter
 
class  ParameterMap
 

Namespaces

 essentia
 

Macros

#define SPECIALIZE_CTOR(valueType, paramType, mName)    Parameter (const valueType& x) : _type(paramType), _##mName(x), _configured(true) {}
 
#define SPECIALIZE_VECTOR_CTOR(valueType, paramType)
 
#define SPECIALIZE_MAP_CTOR(valueType, paramType)
 
#define SPECIALIZE_MATRIX_CTOR(valueType, innerType)
 
#define TO(fname, valueType, paramType, mName)
 
#define TOVECTOR(fname, valueType, paramType)
 
#define TOMAP(fname, valueType, paramType)
 
#define TOMATRIX(fname, valueType, paramType)
 

Functions

std::ostream & operator<< (std::ostream &out, const Parameter &p)
 
std::ostream & operator<< (std::ostream &out, const ParameterMap &m)
 
std::ostream & operator<< (std::ostream &out, const Parameter::ParamType &t)
 

Macro Definition Documentation

◆ SPECIALIZE_CTOR

#define SPECIALIZE_CTOR (   valueType,
  paramType,
  mName 
)     Parameter (const valueType& x) : _type(paramType), _##mName(x), _configured(true) {}

◆ SPECIALIZE_MAP_CTOR

#define SPECIALIZE_MAP_CTOR (   valueType,
  paramType 
)
Value:
Parameter(const std::map<std::string, valueType>& m) : _type(paramType), _configured(true) { \
for (std::map<std::string, valueType>::const_iterator i = m.begin(); \
i != m.end(); \
++i) { _map[(*i).first] = new Parameter((*i).second); } \
}

◆ SPECIALIZE_MATRIX_CTOR

#define SPECIALIZE_MATRIX_CTOR (   valueType,
  innerType 
)
Value:
Parameter(const TNT::Array2D<valueType>& mat) : _type(MATRIX_##innerType), _configured(true) { \
_vec.resize(mat.dim1()); \
for (int i=0; i<mat.dim1(); ++i) { \
_vec[i] = new Parameter(VECTOR_##innerType); \
_vec[i]->_configured = true; \
_vec[i]->_vec.resize(mat.dim2()); \
for (int j=0; j<mat.dim2(); ++j) { \
_vec[i]->_vec[j] = new Parameter(mat[i][j]); \
} \
} \
}
Definition: tnt_array2d.h:38
int dim1() const
Definition: tnt_array2d.h:231
int dim2() const
Definition: tnt_array2d.h:234

◆ SPECIALIZE_VECTOR_CTOR

#define SPECIALIZE_VECTOR_CTOR (   valueType,
  paramType 
)
Value:
Parameter(const std::vector<valueType>& v) : _type(paramType), _configured(true) {\
_vec.resize(v.size()); \
for (int i=0; i<int(v.size()); ++i) { _vec[i] = new Parameter(v[i]); } \
}

◆ TO

#define TO (   fname,
  valueType,
  paramType,
  mName 
)
Value:
valueType to##fname() const { \
if (!_configured) \
throw EssentiaException("Parameter: parameter has not been configured yet (ParamType=", _type, ")"); \
if (_type != paramType) \
throw EssentiaException("Parameter: parameter is not a " #valueType ", it is a ", _type); \
\
return (valueType)_##mName; \
}

◆ TOMAP

#define TOMAP (   fname,
  valueType,
  paramType 
)
Value:
std::map<std::string, valueType > toMap##fname() const { \
if (!_configured) \
throw EssentiaException("Parameter: parameter has not been configured yet (ParamType=", _type, ")"); \
if (_type != paramType) \
throw EssentiaException("Parameter: parameter is not of type: ", paramType); \
\
std::map<std::string, valueType > result; \
\
for (std::map<std::string, Parameter*>::const_iterator i = _map.begin(); \
i != _map.end(); \
++i) { \
result[i->first] = i->second->to##fname(); \
} \
\
return result; \
}

◆ TOMATRIX

#define TOMATRIX (   fname,
  valueType,
  paramType 
)
Value:
TNT::Array2D<valueType> toMatrix##fname() const { \
if (!_configured) \
throw EssentiaException("Parameter: parameter has not been configured yet (ParamType=", _type, ")");\
if (_type != paramType) \
throw EssentiaException("Parameter: parameter is not of type: ", paramType);\
TNT::Array2D<valueType> result(_vec.size(), _vec[0]->_vec.size()); \
\
for (int i=0; i<result.dim1(); ++i) { \
for (int j=0; j<result.dim2(); ++j) { \
result[i][j] = _vec[i]->_vec[j]->to##fname(); \
} \
} \
return result; \
}

◆ TOVECTOR

#define TOVECTOR (   fname,
  valueType,
  paramType 
)
Value:
std::vector<valueType > toVector##fname() const { \
if (!_configured) \
throw EssentiaException("Parameter: parameter has not been configured yet (ParamType=", _type, ")"); \
if (_type != paramType) \
throw EssentiaException("Parameter: parameter is not of type: ", paramType); \
\
std::vector<valueType > result(_vec.size()); \
for (int i=0; i<(int)_vec.size(); ++i) { \
result[i] = _vec[i]->to##fname(); \
} \
return result; \
}