33 #include "commonGlobal.h"
35 #include "byteArray.h"
37 #include "paramMeta.h"
75 static inline uint32 typeFilter(uint32 type) {
return type &
paramTypeMask; }
90 NoAutosave = 0x010000,
117 NotAvailable = 0x100000,
129 DObjPtr = 0x000010 | Pointer | NoAutosave,
130 String = 0x000020 | Pointer,
131 HWRef = 0x000040 | Pointer | NoAutosave,
132 CharArray = Char | Pointer,
133 IntArray = Int | Pointer,
134 DoubleArray = Double | Pointer,
135 ComplexArray = Complex | Pointer,
136 PointCloudPtr = 0x000080 | Pointer | NoAutosave,
137 PointPtr = 0x000100 | Pointer | NoAutosave,
138 PolygonMeshPtr = 0x000200 | Pointer | NoAutosave
146 ParamBase() : m_type(0), m_name(NULL), m_dVal(0.0, 0.0), m_iVal(0), m_cVal(NULL) {}
153 ParamBase(
const ByteArray &name,
const uint32 type,
const uint32 size,
const char *values);
154 ParamBase(
const ByteArray &name,
const uint32 type,
const uint32 size,
const int32 *values);
155 ParamBase(
const ByteArray &name,
const uint32 type,
const uint32 size,
const float64 *values);
156 ParamBase(
const ByteArray &name,
const uint32 type,
const uint32 size,
const complex128 *values);
163 const ParamBase operator [] (
const int num)
const;
174 return !(*
this == rhs);
185 return ((m_type & numericTypeMask) > 0) && !(m_type & ito::ParamBase::Pointer);
192 return (m_type & (numericTypeMask | ito::ParamBase::Pointer)) > 0;
196 inline bool isValid(
void)
const {
return m_type != 0; }
199 inline uint32
getType(
bool filterFlags =
true)
const
218 inline bool getAutosave(
void)
const {
return (m_type & NoAutosave) > 0; }
222 inline void setAutosave(
const bool autosave) { m_type = autosave ? (m_type | NoAutosave) : (m_type & ~NoAutosave); }
225 int getLen(
void)
const;
257 template<
typename _Tp>
inline _Tp
getVal(
void)
const
269 template<
typename _Tp>
inline _Tp
getVal(
int &len)
const
331 Param(
const ByteArray &name,
const uint32 type,
const char *val,
const char *info);
345 Param(
const ByteArray &name,
const uint32 type,
const char minVal,
const char maxVal,
const char val,
const char *info);
359 Param(
const ByteArray &name,
const uint32 type,
const int32 minVal,
const int32 maxVal,
const int32 val,
const char *info);
373 Param(
const ByteArray &name,
const uint32 type,
const float64 minVal,
const float64 maxVal,
const float64 val,
const char *info);
386 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const char *values,
const char *info);
399 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const int32 *values,
const char *info);
412 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const float64 *values,
const char *info);
425 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const complex128 *values,
const char *info);
490 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const char *values,
ParamMeta *meta,
const char *info);
505 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const int32 *values,
ParamMeta *meta,
const char *info);
519 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const float64 *values,
ParamMeta *meta,
const char *info);
533 Param(
const ByteArray &name,
const uint32 type,
const unsigned int size,
const complex128 *values,
ParamMeta *meta,
const char *info);
544 const Param operator [] (
const int num)
const;
555 inline void setInfo(
const char *info)
560 inline void setInfo(
const ByteArray &info)
572 template<
typename _Tp>
inline const _Tp* getMetaT(
void)
const
574 return static_cast<const _Tp*
>(m_pMeta);
581 template<
typename _Tp>
inline _Tp* getMetaT(
void)
583 return static_cast<_Tp*
>(m_pMeta);
592 void setMeta(ParamMeta* meta,
bool takeOwnership =
false);
594 float64 getMin()
const;
595 float64 getMax()
const;
599 template<
typename _Tp>
600 struct ItomParamHelper
602 static ito::RetVal setVal(uint32 type,
char *&cVal, int32 &iVal, complex128_ &,
const _Tp val,
int len = 0)
604 switch (type & paramTypeMask)
612 cVal = (
char*)(reinterpret_cast<const char*>(val));
620 cVal = _strdup((
const char*)val);
621 iVal =
static_cast<int>(strlen(cVal));
638 if ((val) && (len > 0))
640 cVal = (
char*)malloc(len *
sizeof(
char));
641 memcpy(cVal, val, len *
sizeof(
char));
659 if ((val) && (len > 0))
661 cVal = (
char*)malloc(len *
sizeof(ito::int32));
662 memcpy(cVal, val, len *
sizeof(ito::int32));
680 if ((val) && (len > 0))
682 cVal = (
char*)malloc(len *
sizeof(ito::float64));
683 memcpy(cVal, val, len *
sizeof(ito::float64));
701 if ((val) && (len > 0))
703 cVal = (
char*)malloc(len *
sizeof(ito::complex128));
704 memcpy(cVal, val, len *
sizeof(ito::complex128));
724 static _Tp getVal(
const uint32 type,
const char *cVal,
const int32 &iVal,
const complex128_ &,
int &len)
726 switch (type & paramTypeMask)
731 len =
static_cast<int>(strlen(cVal));
732 return reinterpret_cast<_Tp
>(
const_cast<char*
>(cVal));
747 return reinterpret_cast<_Tp
>(
const_cast<char*
>(cVal));
760 return reinterpret_cast<_Tp
>(
const_cast<char*
>(cVal));
763 throw std::logic_error(
"Param::getVal<_Tp>: Non-matching type!");
773 switch (type & paramTypeMask)
777 dVal.real =
static_cast<float64
>(val);
783 iVal =
static_cast<int32
>(val);
787 return ito::RetVal(
ito::retError, 0,
"float64 value passed to setVal<float64> does not match the type of the parameter");
791 static float64 getVal(
const uint32 type,
const char * ,
const int32 &iVal,
const complex128_ &dVal,
int & )
793 switch (type & paramTypeMask)
797 return static_cast<float64
>(iVal);
804 throw std::logic_error(
"Param::getVal<float64>: Non-matching type!");
814 switch (type & paramTypeMask)
818 dVal.real =
static_cast<float64
>(val);
828 return ito::RetVal(
ito::retError, 0,
"int32 value passed to setVal<int32> does not match the type of the parameter");
832 static int32 getVal(
const uint32 type,
const char * ,
const int32 &iVal,
const complex128_ &dVal,
int & )
834 switch (type & paramTypeMask)
842 return static_cast<int32
>(dVal.real);
845 throw std::invalid_argument(
"Param::getVal<int32>: non existent parameter");
848 throw std::logic_error(
"Param::getVal<int32>: Non-matching type!");
858 switch (type & paramTypeMask)
862 dVal.real =
static_cast<float64
>(val);
868 iVal =
static_cast<char>(val);
876 static char getVal(
const uint32 type,
const char * ,
const int32 &iVal,
const complex128_ &dVal,
int & )
878 switch (type & paramTypeMask)
882 return static_cast<char>(iVal);
886 return static_cast<char>(dVal.real);
889 throw std::invalid_argument(
"Param::getVal<char>: non existent parameter");
892 throw std::logic_error(
"Param::getVal<char>: Non-matching type!");
902 switch (type & paramTypeMask)
906 dVal.real =
static_cast<float64
>(val);
912 iVal =
static_cast<unsigned char>(val);
916 return ito::RetVal(
ito::retError, 0,
"unsigned char value passed to setVal<unsigned char> does not match the type of the parameter");
920 static char getVal(
const uint32 type,
const char * ,
const int32 &iVal,
const complex128_ &dVal,
int & )
922 switch (type & paramTypeMask)
926 return static_cast<unsigned char>(iVal);
930 return static_cast<unsigned char>(dVal.real);
933 throw std::invalid_argument(
"Param::getVal<uchar>: non existent parameter");
936 throw std::logic_error(
"Param::getVal<uchar>: Non-matching type!");
946 switch (type & paramTypeMask)
949 dVal.real = val.real();
950 dVal.imag = val.imag();
954 return ito::RetVal(
ito::retError, 0,
"complex128 value passed to setVal<complex128> does not match the type of the parameter");
958 static complex128 getVal(
const uint32 type,
const char * ,
const int32 &iVal,
const complex128_ &dVal,
int & )
960 switch (type & paramTypeMask)
964 return complex128(iVal, 0.0);
967 return complex128(dVal.real, dVal.imag);
973 throw std::logic_error(
"Param::getVal<complex128>: Non-matching type!");
array of complex numbers
Definition: param.h:135
bool isNumericArray(void) const
returns true if Param is of type char array, int array, double array or complex array ...
Definition: param.h:189
complex128_ m_dVal
internal value for float64 and complex128 typed values
Definition: param.h:78
Param(const ByteArray &name)
type-less Param with name and type
Definition: param.h:309
void setFlags(const uint32 flags)
sets parameter flagsfor possible flags see tParamType
Definition: param.h:211
complex (complex128) parameter
Definition: param.h:128
bool isNumeric(void) const
returns true if Param is of type char, int, double or complex
Definition: param.h:182
ito::RetVal setVal(_Tp val, int len)
Definition: param.h:246
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:283
bool getAutosave(void) const
Definition: param.h:218
const char * getInfo(void) const
< returns content of info string (string is not copied)
Definition: param.h:552
array of doubles
Definition: param.h:134
array of integers
Definition: param.h:133
ParamMeta * getMeta(void)
returns pointer to meta-information instance or NULL if not available. Cast this pointer to the right...
Definition: param.h:566
This is a Qt-free class for byte arrays (strings) without specific encoding information.
Definition: byteArray.h:64
Param()
default constructor, creates "empty" Param
Definition: param.h:300
Definition: typeDefs.h:58
ito::RetVal setVal(_Tp val)
Definition: param.h:234
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:10622
polygon mesh parameter (pointer, no auto-safe possible)
Definition: param.h:138
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:565
point parameter (pointer, no auto-safe possible)
Definition: param.h:137
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:196
array of characters
Definition: param.h:132
ParamBase()
default constructor, creates "empty" ParamBase
Definition: param.h:146
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:199
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:185
point cloud parameter (pointer, no auto-safe possible)
Definition: param.h:136
reference to another plugin instance (pointer, no auto-save possible)
Definition: param.h:131
void setAutosave(const bool autosave)
Definition: param.h:222
Param(const ByteArray &name, const uint32 type)
Constructor for a string value (const char*)
Definition: param.h:319
uint32 getFlags(void) const
returns parameter flags
Definition: param.h:208
const char * getName(void) const
returns parameter name (returned string is no copy, do not delete it)
Definition: param.h:214
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:257
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:10215
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:197
ByteArray m_name
parameter name
Definition: param.h:71
char * m_cVal
internal pointer for pointer type values (also strings)
Definition: param.h:80
string parameter
Definition: param.h:130
Type
Definition: param.h:83
dataObject parameter (pointer, no auto-save possible)
Definition: param.h:129
const char * data() const
return the pointer to the internal character array. If it is empty, the returned pointer still points...
Definition: byteArray.h:131
integer (int32) parameter
Definition: param.h:126
_Tp getVal(int &len) const
Definition: param.h:269
double (float64) parameter
Definition: param.h:127
character (int8) parameter
Definition: param.h:125