33#include "commonGlobal.h"
53template <
typename _Tp>
struct ItomParamHelper;
110 NoAutosave = 0x010000,
138 NotAvailable = 0x100000,
161 DObjPtr = 0x0010 | Pointer,
164 String = 0x0020 | Pointer,
167 HWRef = 0x0040 | Pointer,
170 CharArray = Char | Pointer,
173 IntArray = Int | Pointer,
176 DoubleArray = Double | Pointer,
179 ComplexArray = Complex | Pointer,
182 PointCloudPtr = 0x0080 | Pointer,
185 PointPtr = 0x0100 | Pointer,
188 PolygonMeshPtr = 0x0200 | Pointer,
191 StringList = 0x0800 | Pointer
221 const ByteArray& name,
const uint32 typeAndFlags,
const uint32 size,
const char* values);
225 const ByteArray& name,
const uint32 typeAndFlags,
const uint32 size,
const int32* values);
229 const ByteArray& name,
const uint32 typeAndFlags,
const uint32 size,
const float64* values);
234 const uint32 typeAndFlags,
236 const complex128* values);
241 const uint32 typeAndFlags,
259 const ParamBase operator[](
const int index)
const;
270 std::swap(d, other.d);
286 return !(*
this == rhs);
294 bool isNumeric(
void)
const;
297 bool isNumericArray(
void)
const;
301 bool isValid(
void)
const;
304 uint16 getType()
const;
307 uint32 getFlags()
const;
310 void setFlags(
const uint32 flags);
313 const char* getName(
void)
const;
321 bool getAutosave()
const;
325 void setAutosave(
const bool autosave);
375 template <
typename _Tp>
inline _Tp
getVal()
const
388 template <
typename _Tp>
inline _Tp
getVal(
int& len)
const
397 Data(
const ByteArray& name_ =
"") : ref(0), flags(0), type(0), len(0), name(name_)
427 void clearData(
Data* data);
438 void detach(
bool allocNewArray =
true);
444 if (x && (!(x->
ref--)))
462 void setDefaultAutosaveFlag();
464 void checkAndCorrectInOutFlag();
519 Param(
const ByteArray& name,
const uint32 typeAndFlags,
const char* val,
const char* info);
536 const uint32 typeAndFlags,
557 const uint32 typeAndFlags,
578 const uint32 typeAndFlags,
579 const float64 minVal,
580 const float64 maxVal,
597 const uint32 typeAndFlags,
598 const unsigned int size,
615 const uint32 typeAndFlags,
616 const unsigned int size,
633 const uint32 typeAndFlags,
634 const unsigned int size,
635 const float64* values,
651 const uint32 typeAndFlags,
652 const unsigned int size,
653 const complex128* values,
669 const uint32 typeAndFlags,
670 const unsigned int size,
687 const uint32 typeAndFlags,
705 const uint32 typeAndFlags,
723 const uint32 typeAndFlags,
740 const uint32 typeAndFlags,
741 const complex128 val,
759 const uint32 typeAndFlags,
760 const unsigned int size,
780 const uint32 typeAndFlags,
781 const unsigned int size,
800 const uint32 typeAndFlags,
801 const unsigned int size,
802 const float64* values,
820 const uint32 typeAndFlags,
821 const unsigned int size,
822 const complex128* values,
840 const uint32 typeAndFlags,
841 const unsigned int size,
860 const Param operator[](
const int index)
const;
906 inline void decRefMeta(MetaShared* ms)
const
908 if (ms && !(ms->ref--))
923 return m_info.
data();
943 return m_pMetaShared ? m_pMetaShared->meta :
nullptr;
950 return m_pMetaShared ? m_pMetaShared->meta :
nullptr;
957 if (m_pMetaShared && m_pMetaShared->ref > 0)
964 return m_pMetaShared ? m_pMetaShared->meta :
nullptr;
974 template <
typename _Tp>
inline const _Tp*
getMetaT(
void)
const
978 return static_cast<const _Tp*
>(m_pMetaShared->meta);
993 return static_cast<const _Tp*
>(m_pMetaShared->meta);
1004 template <
typename _Tp>
inline _Tp* getMetaT(
void)
1008 if (m_pMetaShared->ref > 0)
1015 return static_cast<_Tp*
>(m_pMetaShared->meta);
1029 void setMeta(ParamMeta* meta,
bool takeOwnership =
false);
1034 float64 getMin()
const;
1039 float64 getMax()
const;
1052 static_assert(std::is_pointer<_Tp>::value,
"unsupported template type.");
1054 switch (param->
d->
type)
1062 param->
d->
data.ptrVal = (
void*)(
reinterpret_cast<const void*
>(val));
1068 auto cVal_ = param->
d->
data.ptrVal;
1072 int str_len =
static_cast<int>(strlen((
const char*)val));
1074 if (((ito::uint32)str_len != param->
d->
len) || (param->
d->
data.ptrVal ==
nullptr))
1076 param->
d->
data.ptrVal =
new char[str_len + 1];
1083 std::copy_n((
const char*)val, str_len + 1, (
char*)param->
d->
data.ptrVal);
1084 param->
d->
len = str_len;
1088 param->
d->
data.ptrVal = 0;
1094 delete[](
char*) cVal_;
1100 auto cVal_ = param->
d->
data.ptrVal;
1102 if ((val) && (len > 0))
1104 if ((ito::uint32)len != param->
d->
len)
1106 param->
d->
data.ptrVal =
new char[len];
1107 param->
d->
len = len;
1114 std::copy_n((
const char*)val, len, (
char*)param->
d->
data.ptrVal);
1118 param->
d->
data.ptrVal =
nullptr;
1124 delete[](
char*) cVal_;
1130 auto cVal_ = param->
d->
data.ptrVal;
1132 if ((val) && (len > 0))
1134 if ((ito::uint32)len != param->
d->
len)
1136 param->
d->
data.ptrVal =
new int32[len];
1137 param->
d->
len = len;
1144 std::copy_n((
const int32*)val, len, (int32*)param->
d->
data.ptrVal);
1148 param->
d->
data.ptrVal =
nullptr;
1154 delete[](int32*) cVal_;
1160 auto cVal_ = param->
d->
data.ptrVal;
1162 if ((val) && (len > 0))
1164 if ((ito::uint32)len != param->
d->
len)
1166 param->
d->
data.ptrVal =
new float64[len];
1167 param->
d->
len = len;
1174 std::copy_n((
const float64*)val, len, (float64*)param->
d->
data.ptrVal);
1178 param->
d->
data.ptrVal =
nullptr;
1184 delete[](float64*) cVal_;
1190 auto cVal_ = param->
d->
data.ptrVal;
1192 if ((val) && (len > 0))
1194 if ((ito::uint32)len != param->
d->
len)
1196 param->
d->
data.ptrVal =
new complex128[len];
1197 param->
d->
len = len;
1204 std::copy_n((
const complex128*)val, len, (complex128*)param->
d->
data.ptrVal);
1208 param->
d->
data.ptrVal =
nullptr;
1214 delete[](complex128*) cVal_;
1218 case ito::ParamBase::StringList:{
1220 auto cVal_ = param->
d->
data.ptrVal;
1222 if ((val) && (len > 0))
1225 param->
d->
data.ptrVal = dest;
1227 for (
int i = 0; i < len; ++i)
1232 param->
d->
len = len;
1236 param->
d->
data.ptrVal =
nullptr;
1250 "_Tp parameter of setVal<_Tp> does not match the type of the parameter");
1256 static_assert(std::is_pointer<_Tp>::value,
"unsupported template type.");
1258 if (std::is_pointer<_Tp>::value)
1260 if (std::is_same<_Tp, ito::ByteArray*>::value ||
1261 std::is_same<_Tp, void*>::value ||
1262 std::is_same<_Tp, char*>::value ||
1263 std::is_same<_Tp, ito::int8*>::value ||
1264 std::is_same<_Tp, ito::int16*>::value ||
1265 std::is_same<_Tp, ito::int32*>::value ||
1266 std::is_same<_Tp, ito::float32*>::value ||
1267 std::is_same<_Tp, ito::float64*>::value ||
1268 std::is_same<_Tp, ito::complex64*>::value ||
1269 std::is_same<_Tp, ito::complex128*>::value)
1275 switch (param->
d->
type)
1278 if (param->
d->
data.ptrVal)
1280 len =
static_cast<int>(strlen((
const char*)param->
d->
data.ptrVal));
1281 return reinterpret_cast<_Tp
>((
char*)param->
d->
data.ptrVal);
1293 case ito::ParamBase::StringList:
1294 if (param->
d->
data.ptrVal)
1296 len = param->
d->
len;
1297 return reinterpret_cast<_Tp
>((
char*)param->
d->
data.ptrVal);
1310 return reinterpret_cast<_Tp
>((
char*)param->
d->
data.ptrVal);
1313 throw std::logic_error(
"Param::getVal<_Tp>: Non-matching type!");
1324 switch (param->
d->
type)
1327 param->
d->
data.
i8Val =
static_cast<int8
>(val);
1343 "float64 value passed to setVal<float64> does not match the type of the parameter");
1349 switch (param->
d->
type)
1352 return static_cast<float64
>(param->
d->
data.
i8Val);
1354 return static_cast<float64
>(param->
d->
data.
i32Val);
1360 throw std::logic_error(
"Param::getVal<float64>: Non-matching type!");
1371 switch (param->
d->
type)
1374 param->
d->
data.
i8Val =
static_cast<int8
>(val);
1380 param->
d->
data.
f64Val =
static_cast<float64
>(val);
1383 param->
d->
data.
c128Val.real =
static_cast<float64
>(val);
1390 "int32 value passed to setVal<int32> does not match the type of the parameter");
1396 switch (param->
d->
type)
1405 return static_cast<int32
>(param->
d->
data.
c128Val.real);
1407 throw std::invalid_argument(
"Param::getVal<int32>: non existent parameter");
1410 throw std::logic_error(
"Param::getVal<int32>: Non-matching type!");
1421 switch (param->
d->
type)
1424 param->
d->
data.
i8Val =
static_cast<int8
>(val);
1430 param->
d->
data.
f64Val =
static_cast<float64
>(val);
1433 param->
d->
data.
c128Val.real =
static_cast<float64
>(val);
1440 "char value passed to setVal<int8> does not match the type of the parameter");
1446 switch (param->
d->
type)
1449 return static_cast<int8
>(param->
d->
data.
i8Val);
1457 throw std::invalid_argument(
"Param::getVal<int8>: non existent parameter");
1460 throw std::logic_error(
"Param::getVal<int8>: Non-matching type!");
1471 switch (param->
d->
type)
1474 param->
d->
data.
i8Val =
static_cast<int8
>(val);
1480 param->
d->
data.
f64Val =
static_cast<float64
>(val);
1483 param->
d->
data.
c128Val.real =
static_cast<float64
>(val);
1490 "char value passed to setVal<char> does not match the type of the parameter");
1496 switch (param->
d->
type)
1499 return static_cast<char>(param->
d->
data.
i8Val);
1507 throw std::invalid_argument(
"Param::getVal<char>: non existent parameter");
1510 throw std::logic_error(
"Param::getVal<char>: Non-matching type!");
1521 switch (param->
d->
type)
1531 "complex128 value passed to setVal<complex128> does not match the type of the "
1538 switch (param->
d->
type)
1541 return complex128(param->
d->
data.
i8Val, 0.0);
1549 throw std::logic_error(
"Param::getVal<complex128>: Non-matching type!");
This is a Qt-free class for byte arrays (strings) without specific encoding information.
Definition byteArray.h:65
const char * data() const
return the pointer to the internal character array. If it is empty, the returned pointer still points...
Definition byteArray.h:144
_Tp getVal(int &len) const
Definition param.h:388
void detach(bool allocNewArray=true)
Definition param.cpp:1044
void incRef(Data *x)
depending on the type, set the default value for the autosave flag.
Definition param.h:453
ito::RetVal setVal(_Tp val, int len)
Definition param.h:364
ito::RetVal setVal(_Tp val)
Definition param.h:352
Type
Definition param.h:142
@ Double
complex (complex128) parameter
Definition param.h:155
@ Int
double (float64) parameter
Definition param.h:152
@ PointCloudPtr
point parameter (pointer, no auto-safe possible)
Definition param.h:182
@ DObjPtr
string parameter
Definition param.h:161
@ IntArray
array of doubles
Definition param.h:173
@ CharArray
array of integers
Definition param.h:170
@ Char
integer (int32) parameter
Definition param.h:149
@ PointPtr
polygon mesh parameter (pointer, no auto-safe possible)
Definition param.h:185
@ Complex
dataObject parameter (pointer, no auto-save possible)
Definition param.h:158
@ ComplexArray
point cloud parameter (pointer, no auto-safe possible)
Definition param.h:179
@ String
reference to another plugin instance (pointer, no auto-save possible)
Definition param.h:164
@ HWRef
array of characters
Definition param.h:167
@ DoubleArray
array of complex numbers
Definition param.h:176
@ PolygonMeshPtr
list of strings, given as ito::ByteArray
Definition param.h:188
_Tp getVal() const
Definition param.h:375
void decRefAndFree(Data *x)
increments the reference counter of data
Definition param.h:442
Data * d
Definition param.h:423
Flag
< Flag section, new for itom > 4.1. Before it was part of the Type enumeration.
Definition param.h:105
ParamBase & operator=(ParamBase &&other) noexcept
just copies the value from the right-hand-side tParam (rhs) to this tParam.
Definition param.h:266
class for parameter handling e.g. to pass parameters to plugins
Definition param.h:477
void setInfo(const char *info)
set the info string (description) to info.
Definition param.h:928
const ParamMeta * getMeta() const
Definition param.h:941
const char * getInfo() const
< returns content of info string (string is not copied)
Definition param.h:921
const ParamMeta * getConstMeta() const
Definition param.h:948
void setInfo(const ByteArray &info)
Definition param.h:934
MetaShared * m_pMetaShared
description of this parameter
Definition param.h:886
const _Tp * getConstMetaT(void) const
Definition param.h:989
const _Tp * getMetaT(void) const
Definition param.h:974
ParamMeta * getMeta(void)
Definition param.h:955
Class for managing status values (like errors or warning)
Definition retVal.h:54
Definition apiFunctionsGraph.cpp:40
const uint32 paramFlagMask
Definition param.h:55
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:210
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:198
const uint32 paramTypeMask
Definition param.h:57
@ retError
Definition typeDefs.h:60
@ retOk
Definition typeDefs.h:58
< struct used as shared memory of ParamBase shared data container
Definition param.h:396
ParamBaseData data
length of array if the type is an array type (including string or string list)
Definition param.h:406
uint16 type
name of this parameter
Definition param.h:415
uint32 len
flags, bitmask of the higher level values in ParamBase::Flag
Definition param.h:409
Data(const ByteArray &name_="")
Definition param.h:397
uint16 flags
type, correspond to ParamBase::Type
Definition param.h:412
std::atomic_int ref
value as union
Definition param.h:403
Union for the internal parameter value of class ParamBase.
Definition param.h:63
complex128_ c128Val
8 bytes
Definition param.h:80
int8 i8Val
< 1 byte
Definition param.h:71
float64 f64Val
16 bytes
Definition param.h:77
int32 i32Val
8 bytes
Definition param.h:74