23 #include <visiontransfer/parameter.h>
25 namespace visiontransfer {
28 using namespace internal;
30 class Parameter::Pimpl {
33 Pimpl(
const std::string& uid);
34 Pimpl(
const Pimpl& other);
35 static void copyData(Pimpl& dst,
const Pimpl& src);
36 std::string getUid()
const {
return uid; }
37 std::string getName()
const {
return name; }
38 std::string getModuleName()
const {
return modulename; }
39 std::string getCategoryName()
const {
return categoryname; }
40 std::string getDescription()
const {
return description; }
41 std::string getUnit()
const {
return unit; }
42 inline ParameterValue::ParameterType getType()
const {
return type; }
43 ParameterAccessMode getAccessForConfig()
const {
return accessForConfig; }
44 ParameterAccessMode getAccessForApi()
const {
return accessForApi; }
45 inline Pimpl& setAccessForConfig(ParameterAccessMode mode) { accessForConfig = mode;
return *
this; }
46 inline Pimpl& setAccessForApi(ParameterAccessMode mode) { accessForApi = mode;
return *
this; }
47 ParameterInteractionHint getInteractionHint()
const {
return interactionHint; }
48 inline Pimpl& setInteractionHint(ParameterInteractionHint hint) { interactionHint = hint;
return *
this; }
49 bool getIsModified()
const {
return isModified; }
50 bool getIsPolled()
const {
return isPolledForUpdates; }
51 inline Pimpl& setIsPolled(
bool mod) { isPolledForUpdates = isCommand() ? false : mod;
return *
this; }
52 inline Pimpl& setIsModified(
bool mod) { isModified = isCommand() ? false : mod;
return *
this; }
53 GovernorType getGovernorType()
const {
return governorType; }
54 std::string getGovernorString()
const {
return governorString; }
55 inline Pimpl& setGovernor(GovernorType govType,
const std::string& govStr) { governorType = govType; governorString = govStr;
return *
this; }
56 inline Pimpl& setGovernorPollString(
const std::string& govStr) { governorPollString = govStr;
return *
this; }
57 bool getInvokeGovernorOnInit()
const {
return invokeGovernorOnInit; }
58 Pimpl& setInvokeGovernorOnInit(
bool invoke) { invokeGovernorOnInit = invoke;
return *
this; }
59 std::string interpolateCommandLine(
const ParameterValue& newVal, GovernorFunction fn = GOVERNOR_FN_CHANGE_VALUE);
60 bool isTensor()
const {
return type == ParameterValue::ParameterType::TYPE_TENSOR; }
61 bool isScalar()
const {
return type != ParameterValue::ParameterType::TYPE_TENSOR; }
62 bool isCommand()
const {
return currentValue.isCommand(); }
63 unsigned int getTensorDimension()
const {
64 return currentValue.isDefined() ? currentValue.getTensorDimension() : defaultValue.getTensorDimension(); }
65 std::vector<unsigned int> getTensorShape()
const {
66 return currentValue.isDefined() ? currentValue.getTensorShape() : defaultValue.getTensorShape();}
67 unsigned int getTensorNumElements()
const {
68 return currentValue.isDefined() ? currentValue.getTensorNumElements() : defaultValue.getTensorNumElements();}
69 std::vector<double> getTensorData()
const;
70 std::vector<double> getTensorDefaultData()
const;
71 std::vector<double>& getTensorDataReference();
72 std::vector<double>& getTensorDefaultDataReference();
73 inline Pimpl& setTensorData(
const std::vector<double>& data) {
74 currentValue.setTensorData(data);
77 inline Pimpl& setTensorDefaultData(
const std::vector<double>& data) {
78 defaultValue.setTensorData(data);
81 inline Pimpl& setName(
const std::string& name) { this->name = name;
return *
this; }
82 inline Pimpl& setModuleName(
const std::string& n) { this->modulename = n;
return *
this; }
83 inline Pimpl& setCategoryName(
const std::string& n) { this->categoryname = n;
return *
this; }
84 inline Pimpl& setDescription(
const std::string& d) { this->description = d;
return *
this; }
85 inline Pimpl& setUnit(
const std::string& d) { this->unit = d;
return *
this; }
86 inline Pimpl& setType(ParameterValue::ParameterType t) {
89 if (t==ParameterValue::ParameterType::TYPE_COMMAND) {
91 defaultValue.setType(this->type);
92 currentValue.setType(this->type);
93 defaultValue.setValue(
"");
94 currentValue.setValue(
"");
98 inline Pimpl& setAsTensor(
const std::vector<unsigned int>& shape) {
99 setType(ParameterValue::TYPE_TENSOR);
100 defaultValue.setTensorShape(shape);
101 currentValue.setTensorShape(shape);
105 bool isValidNewValue(T t)
const {
106 if (validOptions.size()) {
108 for (
auto& o: validOptions) {
109 if (o.getValue<T>() == t)
return true;
113 if ((type==ParameterValue::ParameterType::TYPE_INT) || (type==ParameterValue::ParameterType::TYPE_DOUBLE)) {
114 if (minValue.isUndefined() || maxValue.isUndefined()) {
120 return val>=minValue.getValue<
double>() && val<=maxValue.getValue<
double>();
128 bool ensureValidDefault();
129 bool ensureValidCurrent();
130 template<
typename T> T enforceIncrement(T t);
132 Pimpl& setDefault(T t) {
133 defaultValue.setType(getType());
134 defaultValue.setValue(enforceIncrement(t));
135 ensureValidDefault();
139 Pimpl& setRange(T mn, T mx) {
140 minValue.setType(type);
141 maxValue.setType(type);
142 minValue.setValue(mn);
143 maxValue.setValue(mx);
144 ensureValidDefault();
145 ensureValidCurrent();
148 Pimpl& unsetRange() {
149 minValue.setType(ParameterValue::ParameterType::TYPE_UNDEFINED);
150 maxValue.setType(ParameterValue::ParameterType::TYPE_UNDEFINED);
151 ensureValidDefault();
152 ensureValidCurrent();
156 Pimpl& setIncrement(T t) {
157 incrementValue.setType(type);
158 incrementValue.setValue(t);
159 ensureValidDefault();
160 ensureValidCurrent();
164 Pimpl& setCurrent(T t) {
165 currentValue.setType(getType());
166 currentValue.setValue(enforceIncrement(t));
167 ensureValidCurrent();
170 Pimpl& setCurrentFrom(
const Pimpl& from);
171 Pimpl& setCurrentFromDefault();
173 Pimpl& setOptions(
const std::vector<T>& opts,
const std::vector<std::string>& descriptions) {
174 if (opts.size() != descriptions.size())
throw std::runtime_error(
"Option list and description list of mismatched size");
175 validOptions.clear();
176 validOptionDescriptions.clear();
177 for (
unsigned int i=0; i<opts.size(); ++i) {
178 validOptions.push_back(ParameterValue().setType(type).setValue(opts[i]));
179 validOptionDescriptions.push_back(descriptions[i]);
181 ensureValidDefault();
182 ensureValidCurrent();
186 Pimpl& setOptions(std::initializer_list<T> opts, std::initializer_list<std::string> descriptions) {
187 std::vector<T> tmpOpts(opts);
188 std::vector<std::string> tmpComm(descriptions);
189 return setOptions(tmpOpts, tmpComm);
192 std::vector<T> getOptions()
const {
194 for (
auto& o: validOptions) {
195 vec.push_back(o.getValue<T>());
199 std::vector<std::string> getOptionDescriptions()
const {
200 return validOptionDescriptions;
202 inline ParameterValue getCurrentParameterValue() {
209 throw std::runtime_error(std::string(
"Tried getCurrent(), but no value set and no default defined for ") + getUid());
214 T getCurrent()
const {
216 return currentValue.getValue<T>();
219 return defaultValue.getValue<T>();
221 throw std::runtime_error(std::string(
"Tried getCurrent(), but no value set and no default defined for ") + getUid());
225 inline ParameterValue getDefaultParameterValue() {
229 T getDefault()
const {
230 return defaultValue.getValue<T>();
234 return minValue.isDefined() ? (minValue.getValue<T>()) : (std::numeric_limits<T>::lowest());
238 return maxValue.isDefined() ? (maxValue.getValue<T>()) : ((std::numeric_limits<T>::max)());
241 T getIncrement()
const {
242 return incrementValue.isDefined() ? (incrementValue.getValue<T>()) : internal::ConversionHelpers::toStringIfStringExpected<T>(1);
244 bool hasOptions()
const {
245 return validOptions.size() > 0;
247 bool hasCurrent()
const {
248 if (type == ParameterValue::ParameterType::TYPE_TENSOR) {
250 return currentValue.isDefined() && (currentValue.getTensorCurrentDataSize() == currentValue.getTensorNumElements());
252 return currentValue.isDefined();
255 bool hasDefault()
const {
256 if (defaultValue.isTensor()) {
258 return defaultValue.isDefined() && (defaultValue.getTensorCurrentDataSize() == defaultValue.getTensorNumElements());
260 return defaultValue.isDefined();
263 bool hasRange()
const {
264 return maxValue.isDefined();
266 bool hasIncrement()
const {
267 return incrementValue.isDefined();
269 double at(
unsigned int x) {
return getCurrentParameterValue().tensorElementAt(x); }
270 double at(
unsigned int y,
unsigned int x) {
return getCurrentParameterValue().tensorElementAt(y, x); }
271 double at(
unsigned int z,
unsigned int y,
unsigned int x) {
return getCurrentParameterValue().tensorElementAt(z, y, x); }
277 std::string modulename;
278 std::string categoryname;
279 std::string description;
281 ParameterValue::ParameterType type;
283 ParameterValue defaultValue;
284 ParameterValue currentValue;
285 ParameterValue minValue;
286 ParameterValue maxValue;
287 ParameterValue incrementValue;
288 std::vector<ParameterValue> validOptions;
289 std::vector<std::string> validOptionDescriptions;
292 GovernorType governorType;
293 std::string governorString;
294 std::string governorPollString;
297 bool invokeGovernorOnInit;
299 ParameterAccessMode accessForConfig;
300 ParameterAccessMode accessForApi;
302 ParameterInteractionHint interactionHint;
304 bool isPolledForUpdates;
311 void Parameter::Pimpl::copyData(Parameter::Pimpl& dst,
const Parameter::Pimpl& src) {
314 dst.modulename = src.modulename;
315 dst.categoryname = src.categoryname;
316 dst.description = src.description;
319 dst.defaultValue = src.defaultValue;
320 dst.currentValue = src.currentValue;
321 dst.minValue = src.minValue;
322 dst.maxValue = src.maxValue;
323 dst.incrementValue = src.incrementValue;
324 dst.validOptions = src.validOptions;
325 dst.validOptionDescriptions = src.validOptionDescriptions;
326 dst.governorType = src.governorType;
327 dst.governorString = src.governorString;
328 dst.governorPollString = src.governorPollString;
329 dst.invokeGovernorOnInit = src.invokeGovernorOnInit;
330 dst.accessForConfig = src.accessForConfig;
331 dst.accessForApi = src.accessForApi;
332 dst.interactionHint = src.interactionHint;
333 dst.isModified = src.isModified;
334 dst.isPolledForUpdates = src.isPolledForUpdates;
335 dst.isPollResult = src.isPollResult;
338 Parameter::Pimpl::Pimpl()
339 : uid(
"undefined"), name(
"undefined"), governorType(GOVERNOR_NONE), invokeGovernorOnInit(false), accessForConfig(ACCESS_NONE), accessForApi(ACCESS_NONE), interactionHint(INTERACTION_ACTIVE), isModified(false), isPolledForUpdates(false) {
342 Parameter::Pimpl::Pimpl(
const std::string& uid)
343 : uid(uid), name(uid), governorType(GOVERNOR_NONE), invokeGovernorOnInit(false), accessForConfig(ACCESS_NONE), accessForApi(ACCESS_NONE), interactionHint(INTERACTION_ACTIVE), isModified(false), isPolledForUpdates(false) {
345 Parameter::Pimpl::Pimpl(
const Parameter::Pimpl& other) {
346 copyData(*
this, other);
349 std::string Parameter::Pimpl::interpolateCommandLine(
const ParameterValue& newVal, GovernorFunction govFn) {
350 std::string result = (govFn==GOVERNOR_FN_CHANGE_VALUE) ? governorString : governorPollString;
351 std::set<char> subst{
'P',
'O',
'N',
'E',
'D'};
352 std::ostringstream ss;
357 int foundRightmost = -1;
359 for (
auto ch: subst) {
360 std::string lookfor =
"%";
362 foundAt = (int) result.rfind(lookfor, where);
363 if (foundAt > foundRightmost) {
364 foundRightmost = foundAt;
368 if (foundRightmost >= 0) {
372 ss <<
"\"" << getUid() <<
"\"";
376 ss <<
"\"" << getCurrent<std::string>() <<
"\"";
379 for (
auto e: getTensorData()) {
380 if (first) first =
false;
387 ss << getTensorDimension();
389 auto sh = getTensorShape();
396 ss << newVal.getTensorDimension();
398 auto sh = newVal.getTensorShape();
406 if (newVal.isScalar()) {
407 ss <<
"\"" << newVal.getValue<std::string>() <<
"\"";
410 for (
auto e: newVal.getTensorData()) {
411 if (first) first =
false;
418 result.replace(foundRightmost, 2, ss.str());
420 if (where == 0)
break;
421 where = (foundRightmost > 0) ? foundRightmost-1 : 0;
426 Parameter::Pimpl& Parameter::Pimpl::setCurrentFrom(
const Parameter::Pimpl& from) {
428 if(currentValue.getTensorShape() != from.getTensorShape()) {
429 throw std::runtime_error(
"Cannot assign tensors with unequal shape");
431 setTensorData(from.getTensorData());
433 currentValue.setType(getType());
436 case ParameterValue::ParameterType::TYPE_INT:
437 currentValue.setValue(from.getCurrent<
int>());
break;
438 case ParameterValue::ParameterType::TYPE_DOUBLE:
439 currentValue.setValue(from.getCurrent<
double>());
break;
440 case ParameterValue::ParameterType::TYPE_STRING:
441 case ParameterValue::ParameterType::TYPE_SAFESTRING:
442 case ParameterValue::ParameterType::TYPE_COMMAND:
443 currentValue.setValue(from.getCurrent<std::string>());
break;
445 case ParameterValue::ParameterType::TYPE_BOOL:
446 currentValue.setValue(from.getCurrent<
bool>());
break;
448 case ParameterValue::ParameterType::TYPE_TENSOR:
450 case ParameterValue::ParameterType::TYPE_UNDEFINED:
451 throw std::runtime_error(
"Cannot assign a value to an undefined parameter");
453 ensureValidCurrent();
458 Parameter::Pimpl& Parameter::Pimpl::setCurrentFromDefault() {
460 throw std::runtime_error(std::string(
"Cannot set current value from default - no default value set for ") + getUid());
463 case ParameterValue::ParameterType::TYPE_INT:
464 currentValue.setType(getType());
465 currentValue.setValue(getDefault<int>());
467 case ParameterValue::ParameterType::TYPE_DOUBLE:
468 currentValue.setType(getType());
469 currentValue.setValue(getDefault<double>());
471 case ParameterValue::ParameterType::TYPE_STRING:
472 case ParameterValue::ParameterType::TYPE_SAFESTRING:
473 currentValue.setType(getType());
474 currentValue.setValue(getDefault<std::string>());
476 case ParameterValue::ParameterType::TYPE_BOOL:
477 currentValue.setType(getType());
478 currentValue.setValue(getDefault<bool>());
480 case ParameterValue::ParameterType::TYPE_TENSOR:
481 if (hasCurrent() && (currentValue.getTensorNumElements() != defaultValue.getTensorNumElements())) {
482 throw std::runtime_error(std::string(
"Mismatching current and default tensor sizes for ") + getUid());
484 currentValue.setType(getType());
485 currentValue.setTensorData(defaultValue.getTensorData());
487 case ParameterValue::ParameterType::TYPE_COMMAND:
490 case ParameterValue::ParameterType::TYPE_UNDEFINED:
491 throw std::runtime_error(
"Cannot assign a value to an undefined parameter");
496 template<> VT_EXPORT
bool Parameter::Pimpl::enforceIncrement(
bool t) {
500 template<> VT_EXPORT
int Parameter::Pimpl::enforceIncrement(
int t) {
501 if (hasIncrement() && ((getType()==ParameterValue::TYPE_INT) || (getType()==ParameterValue::TYPE_DOUBLE))) {
503 double inc = getIncrement<double>();
505 double min = getMin<double>();
506 return (
int) (min + inc * ((int) (val-min)/inc));
508 return (
int) (inc * ((int) val/inc));
515 template<> VT_EXPORT
double Parameter::Pimpl::enforceIncrement(
double t) {
516 if (hasIncrement() && ((getType()==ParameterValue::TYPE_INT) || (getType()==ParameterValue::TYPE_DOUBLE))) {
518 double inc = getIncrement<double>();
520 double min = getMin<double>();
521 return min + inc * ((int) (val-min)/inc);
523 return inc * ((int) val/inc);
530 template<> VT_EXPORT std::string Parameter::Pimpl::enforceIncrement(std::string t) {
531 if (hasIncrement() && ((getType()==ParameterValue::TYPE_INT) || (getType()==ParameterValue::TYPE_DOUBLE))) {
532 double val = ConversionHelpers::anyToDouble(t);
533 double inc = getIncrement<double>();
535 double min = getMin<double>();
536 return ConversionHelpers::anyToString(min + inc * ((
int) (val-min)/inc));
538 return ConversionHelpers::anyToString(inc * ((
int) val/inc));
545 std::vector<double>& Parameter::Pimpl::getTensorDataReference() {
547 return currentValue.getTensorDataReference();
550 return defaultValue.getTensorDataReference();
552 throw std::runtime_error(
"Tried getTensorDataReference(), but no value set and no default defined");
557 std::vector<double> Parameter::Pimpl::getTensorData()
const {
559 return currentValue.getTensorData();
562 return defaultValue.getTensorData();
564 throw std::runtime_error(
"Tried getTensorData(), but no value set and no default defined");
569 std::vector<double>& Parameter::Pimpl::getTensorDefaultDataReference() {
571 return defaultValue.getTensorDataReference();
573 throw std::runtime_error(
"Tried getTensorDefaultDataReference(), but no value set and no default defined");
577 std::vector<double> Parameter::Pimpl::getTensorDefaultData()
const {
579 return defaultValue.getTensorData();
581 throw std::runtime_error(
"Tried getTensorDefaultData(), but no default defined");
585 bool Parameter::Pimpl::ensureValidDefault() {
586 if (!hasDefault())
return false;
587 if (isTensor() || isCommand())
return false;
589 std::string val = defaultValue.getValue<std::string>();
590 for (
auto& o: validOptions) {
591 if (val == o.getValue<std::string>()) {
596 defaultValue.setValue<std::string>(validOptions[0].getValue<std::string>());
599 if ((type==ParameterValue::ParameterType::TYPE_INT) || (type==ParameterValue::ParameterType::TYPE_DOUBLE)) {
602 double minVal = minValue.getValue<
double>();
603 double maxVal = maxValue.getValue<
double>();
604 double val = defaultValue.getValue<
double>();
605 double incVal = enforceIncrement(val);
607 defaultValue.setValue<
double>(minVal);
609 }
else if (val > maxVal) {
610 defaultValue.setValue<
double>(maxVal);
612 }
else if (val != incVal) {
614 defaultValue.setValue<
double>(incVal);
629 bool Parameter::Pimpl::ensureValidCurrent() {
630 if (!hasCurrent())
return false;
631 if (isTensor() || isCommand())
return false;
633 std::string val = currentValue.getValue<std::string>();
634 for (
auto& o: validOptions) {
635 if (val == o.getValue<std::string>()) {
641 std::string defVal = defaultValue.getValue<std::string>();
642 for (
auto& o: validOptions) {
643 if (defVal == o.getValue<std::string>()) {
644 currentValue.setValue<std::string>(defVal);
650 currentValue.setValue<std::string>(validOptions[0].getValue<std::string>());
653 if ((type==ParameterValue::ParameterType::TYPE_INT) || (type==ParameterValue::ParameterType::TYPE_DOUBLE)) {
656 double minVal = minValue.getValue<
double>();
657 double maxVal = maxValue.getValue<
double>();
658 double val = currentValue.getValue<
double>();
659 double incVal = enforceIncrement(val);
661 currentValue.setValue<
double>(minVal);
663 }
else if (val > maxVal) {
664 currentValue.setValue<
double>(maxVal);
666 }
else if (val != incVal) {
668 currentValue.setValue<
double>(incVal);
692 Parameter::Parameter()
693 : pimpl(new Parameter::Pimpl()) {
695 Parameter::Parameter(
const std::string& uid)
696 : pimpl(new Parameter::Pimpl(uid)) {
698 Parameter::Parameter(
const Parameter& other)
699 : pimpl(new Parameter::Pimpl()) {
700 Parameter::Pimpl::copyData(*pimpl, *(other.pimpl));
702 Parameter::~Parameter() {
705 Parameter& Parameter::operator= (
const Parameter& other) {
706 Parameter::Pimpl::copyData(*pimpl, *(other.pimpl));
710 std::string Parameter::getUid()
const {
711 return pimpl->getUid();
713 std::string Parameter::getName()
const {
714 return pimpl->getName();
716 std::string Parameter::getModuleName()
const {
717 return pimpl->getModuleName();
719 std::string Parameter::getCategoryName()
const {
720 return pimpl->getCategoryName();
722 std::string Parameter::getDescription()
const {
723 return pimpl->getDescription();
725 std::string Parameter::getUnit()
const {
726 return pimpl->getUnit();
728 ParameterValue::ParameterType Parameter::getType()
const {
729 return pimpl->getType();
731 Parameter::ParameterAccessMode Parameter::getAccessForConfig()
const {
732 return pimpl->getAccessForConfig();
734 Parameter::ParameterAccessMode Parameter::getAccessForApi()
const {
735 return pimpl->getAccessForApi();
738 Parameter& Parameter::setAccessForConfig(Parameter::ParameterAccessMode mode) {
742 Parameter& Parameter::setAccessForApi(Parameter::ParameterAccessMode mode) {
746 Parameter::ParameterInteractionHint Parameter::getInteractionHint()
const {
749 Parameter& Parameter::setInteractionHint(Parameter::ParameterInteractionHint hint) {
753 bool Parameter::getIsModified()
const {
756 bool Parameter::getIsPolled()
const {
757 return pimpl->getIsPolled();
759 Parameter& Parameter::setIsPolled(
bool mod) {
763 Parameter& Parameter::setIsModified(
bool mod) {
767 Parameter::GovernorType Parameter::getGovernorType()
const {
770 std::string Parameter::getGovernorString()
const {
771 return pimpl->getGovernorString();
773 Parameter& Parameter::setGovernor(Parameter::GovernorType govType,
const std::string& govStr) {
777 Parameter& Parameter::setGovernorPollString(
const std::string& govStr) {
781 bool Parameter::getInvokeGovernorOnInit()
const {
784 Parameter& Parameter::setInvokeGovernorOnInit(
bool invoke) {
788 std::string Parameter::interpolateCommandLine(
const ParameterValue& newVal, Parameter::GovernorFunction fn) {
791 bool Parameter::isTensor()
const {
792 return pimpl->isTensor();
794 bool Parameter::isScalar()
const {
795 return pimpl->isScalar();
797 bool Parameter::isCommand()
const {
798 return pimpl->isCommand();
800 unsigned int Parameter::getTensorDimension()
const {
801 return pimpl->getTensorDimension();
803 std::vector<unsigned int> Parameter::getTensorShape()
const {
804 return pimpl->getTensorShape();
806 unsigned int Parameter::getTensorNumElements()
const {
807 return pimpl->getTensorNumElements();
809 std::vector<double> Parameter::getTensorData()
const {
810 return pimpl->getTensorData();
812 std::vector<double> Parameter::getTensorDefaultData()
const {
813 return pimpl->getTensorDefaultData();
815 std::vector<double>& Parameter::getTensorDataReference() {
816 return pimpl->getTensorDataReference();
818 std::vector<double>& Parameter::getTensorDefaultDataReference() {
819 return pimpl->getTensorDefaultDataReference();
821 Parameter& Parameter::setTensorData(
const std::vector<double>& data) {
825 Parameter& Parameter::setTensorDefaultData(
const std::vector<double>& data) {
830 Parameter& Parameter::setName(
const std::string& name) {
834 Parameter& Parameter::setModuleName(
const std::string& n) {
838 Parameter& Parameter::setCategoryName(
const std::string& n) {
842 Parameter& Parameter::setDescription(
const std::string& d) {
846 Parameter& Parameter::setUnit(
const std::string& d) {
850 Parameter& Parameter::setType(ParameterValue::ParameterType t) {
854 Parameter& Parameter::setAsTensor(
const std::vector<unsigned int>& shape) {
858 bool Parameter::ensureValidDefault() {
861 bool Parameter::ensureValidCurrent() {
862 return pimpl->ensureValidCurrent();
866 template<> VT_EXPORT
bool Parameter::isValidNewValue(
int t)
const {
return pimpl->isValidNewValue<
int>(t); }
867 template<> VT_EXPORT
bool Parameter::isValidNewValue(
bool t)
const {
return pimpl->isValidNewValue<
bool>(t); }
868 template<> VT_EXPORT
bool Parameter::isValidNewValue(
double t)
const {
return pimpl->isValidNewValue<
double>(t); }
869 template<> VT_EXPORT
bool Parameter::isValidNewValue(std::string t)
const {
return pimpl->isValidNewValue<std::string>(t); }
872 template<> VT_EXPORT
int Parameter::enforceIncrement(
int t) {
return pimpl->enforceIncrement<
int>(t); }
873 template<> VT_EXPORT
bool Parameter::enforceIncrement(
bool t) {
return pimpl->enforceIncrement<
bool>(t); }
874 template<> VT_EXPORT
double Parameter::enforceIncrement(
double t) {
return pimpl->enforceIncrement<
double>(t); }
875 template<> VT_EXPORT std::string Parameter::enforceIncrement(std::string t) {
return pimpl->enforceIncrement<std::string>(t); }
879 template<> VT_EXPORT
Parameter& Parameter::setDefault(
bool t) { pimpl->
setDefault<
bool>(t);
return *
this; }
880 template<> VT_EXPORT Parameter& Parameter::setDefault(
double t) { pimpl->setDefault<
double>(t);
return *
this; }
881 template<> VT_EXPORT Parameter& Parameter::setDefault(std::string t) { pimpl->setDefault<std::string>(t);
return *
this; }
884 template<> VT_EXPORT
Parameter& Parameter::setRange(
int mn,
int mx) { pimpl->
setRange<
int>(mn, mx);
return *
this; }
885 template<> VT_EXPORT
Parameter& Parameter::setRange(
bool mn,
bool mx) { pimpl->
setRange<
bool>(mn, mx);
return *
this; }
886 template<> VT_EXPORT
Parameter& Parameter::setRange(
double mn,
double mx) { pimpl->
setRange<
double>(mn, mx);
return *
this; }
887 template<> VT_EXPORT Parameter& Parameter::setRange(std::string mn, std::string mx) { pimpl->setRange<std::string>(mn, mx);
return *
this; }
889 Parameter& Parameter::unsetRange() {
895 template<> VT_EXPORT Parameter& Parameter::setIncrement(
int t) { pimpl->setIncrement<
int>(t);
return *
this; }
896 template<> VT_EXPORT Parameter& Parameter::setIncrement(
bool t) { pimpl->setIncrement<
bool>(t);
return *
this; }
897 template<> VT_EXPORT Parameter& Parameter::setIncrement(
double t) { pimpl->setIncrement<
double>(t);
return *
this; }
898 template<> VT_EXPORT Parameter& Parameter::setIncrement(std::string t) { pimpl->setIncrement<std::string>(t);
return *
this; }
901 template<> VT_EXPORT Parameter& Parameter::setCurrent(
int t) { pimpl->setCurrent<
int>(t);
return *
this; }
902 template<> VT_EXPORT Parameter& Parameter::setCurrent(
bool t) { pimpl->setCurrent<
bool>(t);
return *
this; }
903 template<> VT_EXPORT Parameter& Parameter::setCurrent(
double t) { pimpl->setCurrent<
double>(t);
return *
this; }
904 template<> VT_EXPORT Parameter& Parameter::setCurrent(std::string t) { pimpl->setCurrent<std::string>(t);
return *
this; }
906 Parameter& Parameter::setCurrentFrom(
const Parameter& from) {
907 pimpl->setCurrentFrom(*(from.pimpl));
910 Parameter& Parameter::setCurrentFromDefault() {
911 pimpl->setCurrentFromDefault();
916 template<> VT_EXPORT
Parameter& Parameter::setOptions(
const std::vector<int>& opts,
const std::vector<std::string>& descriptions) { pimpl->
setOptions<
int>(opts, descriptions);
return *
this; }
917 template<> VT_EXPORT Parameter& Parameter::setOptions(
const std::vector<bool>& opts,
const std::vector<std::string>& descriptions) { pimpl->setOptions<
bool>(opts, descriptions);
return *
this; }
918 template<> VT_EXPORT Parameter& Parameter::setOptions(
const std::vector<double>& opts,
const std::vector<std::string>& descriptions) { pimpl->setOptions<
double>(opts, descriptions);
return *
this; }
919 template<> VT_EXPORT Parameter& Parameter::setOptions(
const std::vector<std::string>& opts,
const std::vector<std::string>& descriptions) { pimpl->setOptions<std::string>(opts, descriptions);
return *
this; }
922 template<> VT_EXPORT Parameter& Parameter::setOptions(std::initializer_list<int> opts, std::initializer_list<std::string> descriptions) { pimpl->setOptions<
int>(opts, descriptions);
return *
this; }
923 template<> VT_EXPORT Parameter& Parameter::setOptions(std::initializer_list<bool> opts, std::initializer_list<std::string> descriptions) { pimpl->setOptions<
bool>(opts, descriptions);
return *
this; }
924 template<> VT_EXPORT Parameter& Parameter::setOptions(std::initializer_list<double> opts, std::initializer_list<std::string> descriptions) { pimpl->setOptions<
double>(opts, descriptions);
return *
this; }
925 template<> VT_EXPORT Parameter& Parameter::setOptions(std::initializer_list<std::string> opts, std::initializer_list<std::string> descriptions) { pimpl->setOptions<std::string>(opts, descriptions);
return *
this; }
928 template<> VT_EXPORT std::vector<int> Parameter::getOptions()
const {
return pimpl->getOptions<
int>(); }
929 template<> VT_EXPORT std::vector<bool> Parameter::getOptions()
const {
return pimpl->getOptions<
bool>(); }
930 template<> VT_EXPORT std::vector<double> Parameter::getOptions()
const {
return pimpl->getOptions<
double>(); }
931 template<> VT_EXPORT std::vector<std::string> Parameter::getOptions()
const {
return pimpl->getOptions<std::string>(); }
933 std::vector<std::string> Parameter::getOptionDescriptions()
const {
934 return pimpl->getOptionDescriptions();
938 return pimpl->getCurrentParameterValue();
940 ParameterValue Parameter::getDefaultParameterValue() {
941 return pimpl->getDefaultParameterValue();
945 template<> VT_EXPORT
int Parameter::getCurrent()
const {
return pimpl->getCurrent<
int>(); }
946 template<> VT_EXPORT
bool Parameter::getCurrent()
const {
return pimpl->getCurrent<
bool>(); }
947 template<> VT_EXPORT
double Parameter::getCurrent()
const {
return pimpl->getCurrent<
double>(); }
948 template<> VT_EXPORT std::string Parameter::getCurrent()
const {
return pimpl->getCurrent<std::string>(); }
950 template<> VT_EXPORT
int Parameter::getDefault()
const {
return pimpl->getDefault<
int>(); }
951 template<> VT_EXPORT
bool Parameter::getDefault()
const {
return pimpl->getDefault<
bool>(); }
952 template<> VT_EXPORT
double Parameter::getDefault()
const {
return pimpl->getDefault<
double>(); }
953 template<> VT_EXPORT std::string Parameter::getDefault()
const {
return pimpl->getDefault<std::string>(); }
955 template<> VT_EXPORT
int Parameter::getMin()
const {
return pimpl->getMin<
int>(); }
956 template<> VT_EXPORT
bool Parameter::getMin()
const {
return pimpl->getMin<
bool>(); }
957 template<> VT_EXPORT
double Parameter::getMin()
const {
return pimpl->getMin<
double>(); }
958 template<> VT_EXPORT std::string Parameter::getMin()
const {
return pimpl->getMin<std::string>(); }
960 template<> VT_EXPORT
int Parameter::getMax()
const {
return pimpl->getMax<
int>(); }
961 template<> VT_EXPORT
bool Parameter::getMax()
const {
return pimpl->getMax<
bool>(); }
962 template<> VT_EXPORT
double Parameter::getMax()
const {
return pimpl->getMax<
double>(); }
963 template<> VT_EXPORT std::string Parameter::getMax()
const {
return pimpl->getMax<std::string>(); }
965 template<> VT_EXPORT
int Parameter::getIncrement()
const {
return pimpl->getIncrement<
int>(); }
966 template<> VT_EXPORT
bool Parameter::getIncrement()
const {
return pimpl->getIncrement<
bool>(); }
967 template<> VT_EXPORT
double Parameter::getIncrement()
const {
return pimpl->getIncrement<
double>(); }
968 template<> VT_EXPORT std::string Parameter::getIncrement()
const {
return pimpl->getIncrement<std::string>(); }
970 bool Parameter::hasOptions()
const {
971 return pimpl->hasOptions();
973 bool Parameter::hasCurrent()
const {
974 return pimpl->hasCurrent();
976 bool Parameter::hasDefault()
const {
977 return pimpl->hasDefault();
979 bool Parameter::hasRange()
const {
980 return pimpl->hasRange();
982 bool Parameter::hasIncrement()
const {
983 return pimpl->hasIncrement();
986 double Parameter::at(
unsigned int x) {
989 double Parameter::at(
unsigned int y,
unsigned int x) {
990 return pimpl->at(y, x);
992 double Parameter::at(
unsigned int z,
unsigned int y,
unsigned int x) {
993 return pimpl->at(z, y, x);