33 #include "commonGlobal.h" 35 #include "byteArray.h" 37 #include "paramMeta.h" 75 static inline uint32 typeFilter(uint32 type) {
return type &
paramTypeMask; }
85 NoAutosave = 0x010000,
89 NotAvailable = 0x100000,
97 DObjPtr = 0x000010 | Pointer | NoAutosave,
98 String = 0x000020 | Pointer,
99 HWRef = 0x000040 | Pointer | NoAutosave,
100 CharArray = Char | Pointer,
101 IntArray = Int | Pointer,
102 DoubleArray = Double | Pointer,
103 ComplexArray = Complex | Pointer,
104 PointCloudPtr = 0x000080 | Pointer | NoAutosave,
105 PointPtr = 0x000100 | Pointer | NoAutosave,
106 PolygonMeshPtr = 0x000200 | Pointer | NoAutosave
114 ParamBase() : m_type(0), m_name(NULL), m_dVal(0.0, 0.0), m_iVal(0), m_cVal(NULL) {}
121 ParamBase(
const ByteArray &name,
const uint32 type,
const uint32 size,
const char *values);
122 ParamBase(
const ByteArray &name,
const uint32 type,
const uint32 size,
const int32 *values);
123 ParamBase(
const ByteArray &name,
const uint32 type,
const uint32 size,
const float64 *values);
124 ParamBase(
const ByteArray &name,
const uint32 type,
const uint32 size,
const complex128 *values);
131 const ParamBase operator [] (
const int num)
const;
142 return !(*
this == rhs);
152 static int numericTypeMask = ito::ParamBase::Char | ParamBase::Int | ParamBase::Double | ParamBase::Complex;
153 return ((m_type & numericTypeMask) > 0) && !(m_type & ito::ParamBase::Pointer);
159 static int numericTypeMask = ito::ParamBase::Char | ParamBase::Int | ParamBase::Double | ParamBase::Complex;
160 return (m_type & (numericTypeMask | ito::ParamBase::Pointer)) > 0;
164 inline bool isValid(
void)
const {
return m_type != 0; }
167 inline uint32
getType(
bool filterFlags =
true)
const 186 inline bool getAutosave(
void)
const {
return (m_type & NoAutosave) > 0; }
190 inline void setAutosave(
const bool autosave) { m_type = autosave ? (m_type | NoAutosave) : (m_type & ~NoAutosave); }
193 int getLen(
void)
const;
225 template<
typename _Tp>
inline _Tp
getVal(
void)
const 237 template<
typename _Tp>
inline _Tp
getVal(
int &len)
const 266 Param(
const ByteArray &name,
const uint32 type,
const char *val,
const char *info);
267 Param(
const ByteArray &name,
const uint32 type,
const char minVal,
const char maxVal,
const char val,
const char *info);
268 Param(
const ByteArray &name,
const uint32 type,
const int32 minVal,
const int32 maxVal,
const int32 val,
const char *info);
269 Param(
const ByteArray &name,
const uint32 type,
const float64 minVal,
const float64 maxVal,
const float64 val,
const char *info);
270 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const char *values,
const char *info);
271 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const int32 *values,
const char *info);
272 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const float64 *values,
const char *info);
273 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const complex128 *values,
const char *info);
278 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const char *values,
ParamMeta *meta,
const char *info);
279 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const int32 *values,
ParamMeta *meta,
const char *info);
280 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const float64 *values,
ParamMeta *meta,
const char *info);
281 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const complex128 *values,
ParamMeta *meta,
const char *info);
288 const Param operator [] (
const int num)
const;
299 inline void setInfo(
const char *info)
304 inline void setInfo(
const ByteArray &info)
316 template<
typename _Tp>
inline const _Tp* getMetaT(
void)
const 318 return static_cast<const _Tp*
>(m_pMeta);
325 template<
typename _Tp>
inline _Tp* getMetaT(
void)
327 return static_cast<_Tp*
>(m_pMeta);
336 void setMeta(
ParamMeta* meta,
bool takeOwnership =
false);
338 float64 getMin()
const;
339 float64 getMax()
const;
343 template<
typename _Tp>
346 static ito::RetVal setVal(uint32 type,
char *&cVal, int32 &iVal,
complex128_ &,
const _Tp val,
int len = 0)
348 switch (type & paramTypeMask)
350 case (ito::ParamBase::HWRef & paramTypeMask):
351 case (ito::ParamBase::DObjPtr & paramTypeMask):
352 case ito::ParamBase::PointCloudPtr & paramTypeMask:
353 case ito::ParamBase::PointPtr & paramTypeMask:
354 case ito::ParamBase::PolygonMeshPtr & paramTypeMask:
356 cVal = (
char*)(reinterpret_cast<const char*>(val));
359 case ito::ParamBase::String & paramTypeMask:
364 cVal = _strdup((
const char*)val);
365 iVal =
static_cast<int>(strlen(cVal));
382 if ((val) && (len > 0))
384 cVal = (
char*)malloc(len *
sizeof(
char));
385 memcpy(cVal, val, len *
sizeof(
char));
403 if ((val) && (len > 0))
405 cVal = (
char*)malloc(len *
sizeof(ito::int32));
406 memcpy(cVal, val, len *
sizeof(ito::int32));
424 if ((val) && (len > 0))
426 cVal = (
char*)malloc(len *
sizeof(ito::float64));
427 memcpy(cVal, val, len *
sizeof(ito::float64));
445 if ((val) && (len > 0))
447 cVal = (
char*)malloc(len *
sizeof(ito::complex128));
448 memcpy(cVal, val, len *
sizeof(ito::complex128));
468 static _Tp getVal(
const uint32 type,
const char *cVal,
const int32 &iVal,
const complex128_ &,
int &len)
470 switch (type & paramTypeMask)
472 case ito::ParamBase::String & paramTypeMask:
475 len =
static_cast<int>(strlen(cVal));
476 return reinterpret_cast<_Tp
>(
const_cast<char*
>(cVal));
491 return reinterpret_cast<_Tp
>(
const_cast<char*
>(cVal));
499 case (ito::ParamBase::HWRef & paramTypeMask):
500 case (ito::ParamBase::DObjPtr & paramTypeMask):
501 case ito::ParamBase::PointCloudPtr & paramTypeMask:
502 case ito::ParamBase::PointPtr & paramTypeMask:
503 case ito::ParamBase::PolygonMeshPtr & paramTypeMask:
504 return reinterpret_cast<_Tp
>(
const_cast<char*
>(cVal));
507 throw std::logic_error(
"Param::getVal<_Tp>: Non-matching type!");
517 switch (type & paramTypeMask)
521 dVal.real =
static_cast<float64
>(val);
527 iVal =
static_cast<int32
>(val);
531 return ito::RetVal(
ito::retError, 0,
"float64 value passed to setVal<float64> does not match the type of the parameter");
535 static float64 getVal(
const uint32 type,
const char * ,
const int32 &iVal,
const complex128_ &dVal,
int & )
537 switch (type & paramTypeMask)
541 return static_cast<float64
>(iVal);
548 throw std::logic_error(
"Param::getVal<float64>: Non-matching type!");
558 switch (type & paramTypeMask)
562 dVal.real =
static_cast<float64
>(val);
572 return ito::RetVal(
ito::retError, 0,
"int32 value passed to setVal<int32> does not match the type of the parameter");
576 static int32 getVal(
const uint32 type,
const char * ,
const int32 &iVal,
const complex128_ &dVal,
int & )
578 switch (type & paramTypeMask)
586 return static_cast<int32
>(dVal.real);
589 throw std::invalid_argument(
"Param::getVal<int32>: non existent parameter");
592 throw std::logic_error(
"Param::getVal<int32>: Non-matching type!");
602 switch (type & paramTypeMask)
606 dVal.real =
static_cast<float64
>(val);
612 iVal =
static_cast<char>(val);
620 static char getVal(
const uint32 type,
const char * ,
const int32 &iVal,
const complex128_ &dVal,
int & )
622 switch (type & paramTypeMask)
626 return static_cast<char>(iVal);
630 return static_cast<char>(dVal.real);
633 throw std::invalid_argument(
"Param::getVal<char>: non existent parameter");
636 throw std::logic_error(
"Param::getVal<char>: Non-matching type!");
646 switch (type & paramTypeMask)
650 dVal.real =
static_cast<float64
>(val);
656 iVal =
static_cast<unsigned char>(val);
660 return ito::RetVal(
ito::retError, 0,
"unsigned char value passed to setVal<unsigned char> does not match the type of the parameter");
664 static char getVal(
const uint32 type,
const char * ,
const int32 &iVal,
const complex128_ &dVal,
int & )
666 switch (type & paramTypeMask)
670 return static_cast<unsigned char>(iVal);
674 return static_cast<unsigned char>(dVal.real);
677 throw std::invalid_argument(
"Param::getVal<uchar>: non existent parameter");
680 throw std::logic_error(
"Param::getVal<uchar>: Non-matching type!");
690 switch (type & paramTypeMask)
693 dVal.real = val.real();
694 dVal.imag = val.imag();
698 return ito::RetVal(
ito::retError, 0,
"complex128 value passed to setVal<complex128> does not match the type of the parameter");
702 static complex128 getVal(
const uint32 type,
const char * ,
const int32 &iVal,
const complex128_ &dVal,
int & )
704 switch (type & paramTypeMask)
708 return complex128(iVal, 0.0);
711 return complex128(dVal.real, dVal.imag);
717 throw std::logic_error(
"Param::getVal<complex128>: Non-matching type!");
bool isNumericArray(void) const
returns true if Param is of type char array, int array, double array or complex array ...
Definition: param.h:157
complex128_ m_dVal
internal value for float64 and complex128 typed values
Definition: param.h:78
void setFlags(const uint32 flags)
sets parameter flagsfor possible flags see tParamType
Definition: param.h:179
bool isNumeric(void) const
returns true if Param is of type char, int, double or complex
Definition: param.h:150
ito::RetVal setVal(_Tp val, int len)
Definition: param.h:214
Definition: typeDefs.h:60
ito::int32 m_iVal
internal value for integer typed values
Definition: param.h:79
Class for managing status values (like errors or warning)
Definition: retVal.h:54
class for parameter handling e.g. to pass paramters to plugins
Definition: param.h:251
bool getAutosave(void) const
Definition: param.h:186
const char * getInfo(void) const
< returns content of info string (string is not copied)
Definition: param.h:296
ParamMeta * getMeta(void)
returns pointer to meta-information instance or NULL if not available. Cast this pointer to the right...
Definition: param.h:310
This is a Qt-free class for byte arrays (strings) without specific encoding information.
Definition: byteArray.h:69
Param()
default constructor, creates "empty" tParam
Definition: param.h:263
Definition: typeDefs.h:58
ito::RetVal setVal(_Tp val)
Definition: param.h:202
DataObject imag(const DataObject &dObj)
high-level value which calculates the imaginary value of each element of the input source data object...
Definition: dataobj.cpp:9069
Definition: apiFunctionsGraph.cpp:39
const ParamMeta * getMeta(void) const
returns const-pointer to meta-information instance or NULL if not available. Cast this pointer to the...
Definition: param.h:309
bool isValid(void) const
returns whether Param contains a valid type (true) or is an empty parameter (false, type == 0). The default tParam-constructor is always an invalid tParam.
Definition: param.h:164
ParamBase()
default constructor, creates "empty" ParamBase
Definition: param.h:114
uint32 getType(bool filterFlags=true) const
returns parameter type (autosave flag and other flags (like in, out or readonly) are only included if...
Definition: param.h:167
bool operator==(const ByteArray &a1, const char *a2)
comparison operator that returns true if the content of a1 is equal to the given zero-terminated stri...
Definition: byteArray.h:190
void setAutosave(const bool autosave)
Definition: param.h:190
uint32 getFlags(void) const
returns parameter flags
Definition: param.h:176
const char * getName(void) const
returns parameter name (returned string is no copy, do not delete it)
Definition: param.h:182
const uint32 paramTypeMask
bits of param type lying withing this mask describe the type (typeNoAutosave must be included there) ...
Definition: param.h:57
_Tp getVal(void) const
Definition: param.h:225
DataObject real(const DataObject &dObj)
high-level value which calculates the real value of each element of the input source data object and ...
Definition: dataobj.cpp:8985
wrapper class for a complex128 value. This class is used, since the std::complex stl class is not exp...
Definition: param.h:60
const uint32 paramFlagMask
bits of type lying within this mask are flags (e.g. typeNoAutosave, typeReadonly...)
Definition: param.h:56
bool operator!=(const ByteArray &a1, const char *a2)
comparison operator that returns true if the content of a1 is not equal to the given zero-terminated ...
Definition: byteArray.h:202
ByteArray m_name
parameter name
Definition: param.h:71
char * m_cVal
internal pointer for pointer type values (also strings)
Definition: param.h:80
const char * data() const
return the pointer to the internal character array. If it is empty, the returned pointer still points...
Definition: byteArray.h:136
_Tp getVal(int &len) const
Definition: param.h:237