PropertyDefinition.hpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * ArmarX is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * @package ArmarX::
18 * @author Mirko Waechter ( mirko.waechter at kit dot edu)
19 * @date 2015
20 * @copyright http://www.gnu.org/licenses/gpl.txt
21 * GNU General Public License
22 */
23 
24 
25 #pragma once
26 
27 #include <SimoxUtility/algorithm/get_map_keys_values.h>
28 
34 #include <ArmarXCore/util/check.h>
35 
36 // Ice
37 #include <limits>
38 #include <type_traits>
39 #include <vector>
40 
41 #include <IceUtil/Time.h>
42 
43 namespace armarx
44 {
45  template <typename PropertyType>
47  PropertyType* setterRef,
48  const std::string& propertyName,
49  const std::string& description,
51  PropertyDefinitionBase(true, constness),
52  propertyName(propertyName),
53  description(description),
54  setterRef{setterRef},
55  factory(nullptr),
56  regex(""),
57  caseInsensitive(true),
58  expandEnvVars(true),
59  stringRemoveQuotes(true),
62  {
63  initHook();
64  }
65 
66  template <typename PropertyType>
68  PropertyType* setterRef,
69  const std::string& propertyName,
70  PropertyType defaultValue,
71  const std::string& description,
73  PropertyDefinitionBase(false, constness),
74  propertyName(propertyName),
75  description(description),
76  defaultValue(defaultValue),
77  setterRef{setterRef},
78  factory(nullptr),
79  regex(""),
80  caseInsensitive(true),
81  expandEnvVars(true),
82  stringRemoveQuotes(true),
85  {
86  initHook();
87  }
88 
89  std::string PropertyDefinition_toLowerCopy(std::string const& input);
90 
91  template <typename PropertyType>
92  inline PropertyDefinition<PropertyType>&
93  PropertyDefinition<PropertyType>::map(const std::string& valueString, PropertyType value)
94  {
95  if (caseInsensitive)
96  {
97  std::string lowerCaseValueString = PropertyDefinition_toLowerCopy(valueString);
98 
99  propertyValuesMap[lowerCaseValueString] = ValueEntry(valueString, value);
100  }
101  else
102  {
103  propertyValuesMap[valueString] = ValueEntry(valueString, value);
104  }
105 
106  return *this;
107  }
108 
109  template <typename PropertyType>
111  PropertyDefinition<PropertyType>::map(const std::map<std::string, PropertyType>& values)
112  {
113  for (const auto& [name, value] : values)
114  {
115  map(name, value);
116  }
117  return *this;
118  }
119 
120  template <typename PropertyType>
121  template <class T>
122  inline std::enable_if_t<std::is_same_v<T, PropertyType> && !std::is_same_v<T, std::string>,
124  PropertyDefinition<PropertyType>::map(const std::map<T, std::string>& values)
125  {
126  for (const auto& [value, name] : values)
127  {
128  map(name, value);
129  }
130  return *this;
131  }
132 
133  template <typename PropertyType>
136  {
137  this->factory = func;
138 
139  return *this;
140  }
141 
142  template <typename PropertyType>
145  {
146  if (this->caseInsensitive != isCaseInsensitive)
147  {
148  // rebuild value map
149  PropertyValuesMap newPropertyValuesMap;
150 
151  typename PropertyValuesMap::iterator valueIter = propertyValuesMap.begin();
152 
153  std::string key;
154 
155  while (valueIter != propertyValuesMap.end())
156  {
157  key = valueIter->second.first;
158 
159  if (isCaseInsensitive)
160  {
162  }
163 
164  newPropertyValuesMap[key] = valueIter->second;
165  valueIter++;
166  }
167 
168  // set the new map
169  propertyValuesMap = newPropertyValuesMap;
170  this->caseInsensitive = isCaseInsensitive;
171  }
172 
173  return *this;
174  }
175 
176  template <typename PropertyType>
179  {
180  this->expandEnvVars = expand;
181  return *this;
182  }
183 
184  template <typename PropertyType>
187  {
188  this->stringRemoveQuotes = removeQuotes;
189  return *this;
190  }
191 
192  template <typename PropertyType>
194  PropertyDefinition<PropertyType>::setMatchRegex(const std::string& match_regex)
195  {
196  this->regex = match_regex;
197 
198  return *this;
199  }
200 
201  template <typename PropertyType>
204  {
205  if constexpr (std::is_arithmetic_v<PropertyType>)
206  {
207  this->min = min_value;
208 
209  return *this;
210  }
211  else
212  {
213  ARMARX_WARNING << "Cannot use setMin() to " << min_value
214  << " on a non-arithmetic type. Ignoring.";
215  return *this;
216  }
217  }
218 
219  template <typename PropertyType>
222  {
223  if constexpr (std::is_arithmetic_v<PropertyType>)
224  {
225  this->max = max_value;
226 
227  return *this;
228  }
229  else
230  {
231  ARMARX_WARNING << "Cannot use setMax() to " << max_value
232  << " on a non-arithmetic type. Ignoring.";
233  return *this;
234  }
235  }
236 
237  template <typename PropertyType>
238  bool
240  {
241  return caseInsensitive;
242  }
243 
244  template <typename PropertyType>
245  bool
247  {
248  return expandEnvVars;
249  }
250 
251  template <typename PropertyType>
252  bool
254  {
255  return stringRemoveQuotes;
256  }
257 
258  template <typename PropertyType>
259  std::string
261  {
262  return regex;
263  }
264 
265  template <typename PropertyType>
266  double
268  {
269  return min;
270  }
271 
272  template <typename PropertyType>
273  double
275  {
276  return max;
277  }
278 
279  template <typename PropertyType>
280  std::string
282  {
283  return propertyName;
284  }
285 
286  template <typename PropertyType>
287  std::string
289  {
290  return description;
291  }
292 
293  template <typename PropertyType>
296  {
297  return propertyValuesMap;
298  }
299 
300  template <typename PropertyType>
301  PropertyType
303  {
304  // throw exception if no default exists
305 
306  if (isRequired())
307  {
308  throw armarx::LocalException("Required property '" + getPropertyName() +
309  "': default doesn't exist.");
310  }
311 
312  return defaultValue;
313  }
314 
315  template <typename PropertyType>
318  {
319  return factory;
320  }
321 
322  template <typename PropertyType>
323  std::string
325  const std::string& value)
326  {
327  std::vector<std::string> mapValues;
328 
329  typename PropertyValuesMap::iterator it = propertyValuesMap.begin();
330 
331  while (it != propertyValuesMap.end())
332  {
333  mapValues.push_back(it->second.first);
334 
335  ++it;
336  }
337 
338  return formatter.formatDefinition(propertyName,
339  description,
342  : ""),
345  : ""),
346  getDefaultAsString(),
347  (!isCaseInsensitive() ? "yes" : "no"),
348  (isRequired() ? "yes" : "no"),
349  regex,
350  mapValues,
351  value);
352  }
353 
354  template <typename PropertyType>
355  std::string
357  {
358  if (not isRequired())
359  {
361  {
363  }
364  else if constexpr (std::is_same_v<PropertyType, IceUtil::Time>)
365  {
366  IceUtil::Time time = getDefaultValue();
367  double time_count = time.toMicroSecondsDouble();
368  std::string unit = "µs";
369 
370  if (time_count >= 1000)
371  {
372  time_count /= 1000;
373  unit = "ms";
374 
375  if (time_count >= 1000)
376  {
377  time_count /= 1000;
378  unit = "s";
379 
380  if (time_count >= 60)
381  {
382  time_count /= 60;
383  unit = "min";
384 
385  if (time_count >= 60)
386  {
387  time_count /= 60;
388  unit = "h";
389 
390  if (time_count >= 24)
391  {
392  return time.toDateTime();
393  }
394  }
395  }
396  }
397  }
398 
399  return PropertyDefinition_lexicalCastToString(time_count) + " " + unit;
400  }
401  // bool
402  else if constexpr (std::is_same_v<PropertyType, bool>)
403  {
404  return getDefaultValue() ? "true" : "false";
405  }
406  // floating point types
407  else if constexpr (std::is_floating_point_v<PropertyType>)
408  {
409  return PropertyDefinition_lexicalCastToString(getDefaultValue());
410  }
411  // integral types
412  else if constexpr (std::is_integral_v<PropertyType>)
413  {
414  return PropertyDefinition_lexicalCastToString(getDefaultValue());
415  }
416  // std::string
417  else if constexpr (std::is_same_v<PropertyType, std::string>)
418  {
419  if (getDefaultValue().empty())
420  {
421  return "\"\"";
422  }
423 
424  return getDefaultValue();
425  }
426  // mappings
427  else
428  {
429  typename PropertyValuesMap::iterator it = propertyValuesMap.begin();
430 
431  while (it != propertyValuesMap.end())
432  {
433  if (it->second.second == getDefaultValue())
434  {
435  return it->second.first;
436  }
437 
438  ++it;
439  }
440 
441  return "Default value not mapped.";
442  }
443  }
444 
445  // no default available
446  return std::string();
447  }
448 
449  template <typename PropertyType>
450  PropertyType
452  Ice::PropertiesPtr iceProperties)
453  {
454  return isRequired() ? getValueRequired(prefix, iceProperties)
455  : getValueOptional(prefix, iceProperties);
456  }
457 
458  template <typename PropertyType>
459  void
461  Ice::PropertiesPtr iceProperties)
462  {
463  if (setterRef != nullptr)
464  {
465  *setterRef = getValue(prefix, iceProperties);
466  }
467  }
468 
469  std::map<std::string, std::string>
471  std::vector<std::string> PropertyDefinition_parseVectorString(std::string const& input);
473 
474  template <typename PropertyType>
475  void
477  {
478  // bool
479  if constexpr (std::is_same_v<PropertyType, bool>)
480  {
481  setCaseInsensitive(true);
482  map("true", true);
483  map("false", false);
484  map("yes", true);
485  map("no", false);
486  map("1", true);
487  map("0", false);
488  }
489  // armarx::MessageType
490  else if constexpr (std::is_same_v<PropertyType, armarx::MessageTypeT>)
491  {
492  setCaseInsensitive(true);
493  map("Debug", armarx::MessageTypeT::DEBUG);
494  map("Verbose", armarx::MessageTypeT::VERBOSE);
495  map("Info", armarx::MessageTypeT::INFO);
496  map("Important", armarx::MessageTypeT::IMPORTANT);
497  map("Warning", armarx::MessageTypeT::WARN);
498  map("Error", armarx::MessageTypeT::ERROR);
499  map("Fatal", armarx::MessageTypeT::FATAL);
500  map("Undefined", armarx::MessageTypeT::UNDEFINED);
501  }
502  // std::map<std::string, std::string>
503  else if constexpr (std::is_same_v<PropertyType, std::map<std::string, std::string>>)
504  {
506  }
507  // std::vector<std::string>
508  else if constexpr (std::is_same_v<PropertyType, std::vector<std::string>>)
509  {
511  }
512  // IceUtil::Time
513  else if constexpr (std::is_same_v<PropertyType, IceUtil::Time>)
514  {
515  setCaseInsensitive(true);
517  }
519  {
520  meta::properties::PDInitHookPlugin<PropertyType>::Init(*this);
521  }
522  }
523 
524  template <typename PropertyType>
525  PropertyType
526  PropertyDefinition<PropertyType>::getValueRequired(const std::string& prefix,
527  Ice::PropertiesPtr iceProperties)
528  {
529  using namespace armarx::exceptions;
530 
531  checkRequirement(prefix, iceProperties);
532 
533  const std::string keyValue = getPropertyValue(prefix, iceProperties);
534  const std::string value = getRawPropertyValue(prefix, iceProperties);
535 
536  if (matchRegex(value))
537  {
538  // Try factory.
539  if (getFactory())
540  {
541  try
542  {
543  return getFactory()(value);
544  }
545  catch (const armarx::LocalException& e)
546  {
547  throw local::InvalidPropertyValueException(prefix + getPropertyName(), value)
548  << e.getReason();
549  }
550  catch (const std::exception& e)
551  {
552  throw local::InvalidPropertyValueException(prefix + getPropertyName(), value)
553  << "Unknown exception while constructing type out of value: " << e.what();
554  }
555  catch (...)
556  {
557  throw local::InvalidPropertyValueException(prefix + getPropertyName(), value)
558  << "Unknown exception while constructing type out of value.";
559  }
560  }
561 
562  // Try mapped values.
563  const PropertyValuesMap& propertyValuesMap = getValueMap();
564 
565  if (!propertyValuesMap.empty())
566  {
567  auto valueIter = propertyValuesMap.find(keyValue);
568  if (valueIter != propertyValuesMap.end())
569  {
570  return processMappedValue(valueIter->second.second);
571  }
572 
573  // Mapping exist but value not found.
574  throw local::UnmappedValueException(prefix + getPropertyName(), value)
575  << "Mapped keys: " << simox::alg::get_keys(getValueMap());
576  }
577 
578  // Try parsing raw value.
579  // bool
580  if constexpr (std::is_same_v<PropertyType, bool>)
581  {
583  }
584  // arithmetic types
585  else if constexpr (std::is_arithmetic_v<PropertyType>)
586  {
587  try
588  {
589  PropertyType numericValue =
590  PropertyDefinition_lexicalCastTo<PropertyType>(value);
591  checkLimits(prefix, numericValue);
592  return numericValue;
593  }
594  catch (const std::bad_cast&)
595  {
596  throw local::InvalidPropertyValueException(prefix + getPropertyName(), value);
597  }
598  }
599  // string
600  else if constexpr (std::is_same_v<PropertyType, std::string>)
601  {
602  return processMappedValue(value);
603  }
604  else
605  {
606  throw exceptions::local::UnmappedValueException(prefix + getPropertyName(), value)
607  << "Mapped keys: " << simox::alg::get_keys(getValueMap());
608  }
609  }
610 
611  throw local::InvalidPropertyValueException(prefix + getPropertyName(),
612  getRawPropertyValue(prefix, iceProperties));
613  }
614 
615  template <typename PropertyType>
616  PropertyType
617  PropertyDefinition<PropertyType>::getValueOptional(const std::string& prefix,
618  Ice::PropertiesPtr iceProperties)
619  {
620  using namespace armarx::exceptions;
621 
622  if (!isSet(prefix, iceProperties))
623  {
624  return getDefaultValue();
625  }
626  else
627  {
628  return getValueRequired(prefix, iceProperties);
629  }
630  }
631 
632  template <typename PropertyType>
633  std::string
634  PropertyDefinition<PropertyType>::getPropertyValue(const std::string& prefix,
635  Ice::PropertiesPtr iceProperties) const
636  {
637  std::string value = icePropertyGet(iceProperties, prefix + getPropertyName());
638 
639  if (isCaseInsensitive())
640  {
642  }
643 
644  return value;
645  }
646 
647  template <typename PropertyType>
648  std::string
649  PropertyDefinition<PropertyType>::getRawPropertyValue(const std::string& prefix,
650  Ice::PropertiesPtr iceProperties) const
651  {
652  return icePropertyGet(iceProperties, prefix + getPropertyName());
653  }
654 
655  bool PropertyDefinition_matchRegex(std::string const& regex, std::string const& value);
656 
657  template <typename PropertyType>
658  bool
659  PropertyDefinition<PropertyType>::matchRegex(const std::string& value) const
660  {
661  if (!getMatchRegex().empty())
662  {
663  return PropertyDefinition_matchRegex(getMatchRegex(), value);
664  }
665 
666  return true;
667  }
668 
669  template <typename PropertyType>
670  void
671  PropertyDefinition<PropertyType>::checkRequirement(const std::string& prefix,
672  Ice::PropertiesPtr iceProperties)
673  {
674  using namespace armarx::exceptions;
675 
676  if (isRequired())
677  {
678  if (!isSet(prefix, iceProperties))
679  {
680  throw local::MissingRequiredPropertyException(prefix + getPropertyName(),
681  iceProperties);
682  }
683  }
684  }
685 
686  template <typename PropertyType>
687  bool
688  PropertyDefinition<PropertyType>::isSet(const std::string& prefix,
689  Ice::PropertiesPtr iceProperties) const
690  {
691  return PropertyDefinitionBase::isSet(prefix, getPropertyName(), iceProperties);
692  }
693 
694  template <typename PropertyType>
695  template <typename T>
696  T
698  {
699  return value;
700  }
701 
702  template <typename PropertyType>
703  std::string
704  PropertyDefinition<PropertyType>::processMappedValue(const std::string& value)
705  {
706  std::string result = value;
707  if (expandEnvironmentVariables())
708  {
709  expandEnvironmentVariables(result, result);
710  }
711  if (removeQuotes())
712  {
713  removeQuotes(result, result);
714  }
715  return result;
716  }
717 
718  template <typename PropertyType>
719  bool
721  std::string& output)
722  {
723  output = input;
724 
725  if (input == "")
726  {
727  return false;
728  }
729 
730  bool res = true;
731  bool goOn = false;
732 
733  do
734  {
735  size_t foundStart = output.find("${");
736 
737  if (foundStart != std::string::npos)
738  {
739  goOn = true;
740  size_t foundEnd = output.find("}", foundStart);
741 
742  if (foundEnd != std::string::npos)
743  {
744  std::string envVar = output.substr(foundStart + 2, foundEnd - foundStart - 2);
745  std::string replacement;
746  char* envVarENV = getenv(envVar.c_str());
747 
748  if (envVarENV)
749  {
750  replacement = envVarENV;
751  }
752  else
753  {
754  std::cout << "WARNING: Could not expand environment variable: " << envVar
755  << std::endl;
756  }
757 
758  output.replace(foundStart, foundEnd - foundStart + 1, replacement);
759  }
760  else
761  {
762  std::cout << "ERROR: Found '${' but missing '}' in " << input << std::endl;
763  goOn = false;
764  res = false;
765  }
766  }
767  else
768  {
769  goOn = false;
770  }
771 
772  } while (goOn);
773 
774  return res;
775  }
776 
777  template <typename PropertyType>
778  void
779  PropertyDefinition<PropertyType>::removeQuotes(const std::string& input, std::string& output)
780  {
781  output = input;
782 
783  if (input.size() < 2)
784  {
785  return;
786  }
787 
788  if ((input[0] == '"' && input[input.size() - 1] == '"') ||
789  (input[0] == '\'' && input[input.size() - 1] == '\''))
790  {
791  output = input.substr(1, input.size() - 2);
792  }
793  }
794 
795  template <typename PropertyType>
796  void
797  PropertyDefinition<PropertyType>::checkLimits(const std::string& prefix,
798  PropertyType numericValue) const
799  {
800  using namespace armarx::exceptions;
801 
802  double dirtyValue = PropertyDefinition_lexicalCastTo<double>(
804 
805  if ((dirtyValue < getMin()) || (dirtyValue > getMax()))
806  {
808  prefix + getPropertyName(), getMin(), getMax(), dirtyValue);
809  }
810  }
811 } // namespace armarx
armarx::PropertyDefinition::getValue
PropertyType getValue(const std::string &prefix, Ice::PropertiesPtr)
Definition: PropertyDefinition.hpp:451
armarx::PropertyDefinition_parseVectorString
std::vector< std::string > PropertyDefinition_parseVectorString(std::string const &input)
Definition: PropertyDefinition.cpp:75
armarx::MessageTypeT::ERROR
@ ERROR
armarx::PropertyDefinition::getMatchRegex
std::string getMatchRegex() const
Definition: PropertyDefinition.hpp:260
armarx::PropertyDefinitionBase
Common interface of any property definition.
Definition: PropertyDefinitionInterface.h:51
check.h
armarx::PropertyDefinition::getValueMap
PropertyValuesMap & getValueMap()
Definition: PropertyDefinition.hpp:295
armarx::MessageTypeT::WARN
@ WARN
armarx::MessageTypeT::FATAL
@ FATAL
armarx::PropertyDefinitionBase::PropertyConstness
PropertyConstness
Definition: PropertyDefinitionInterface.h:54
armarx::MessageTypeT::UNDEFINED
@ UNDEFINED
armarx::PropertyDefinition::getMax
double getMax() const
Definition: PropertyDefinition.hpp:274
armarx::MessageTypeT::INFO
@ INFO
armarx::PropertyDefinition::setterRef
PropertyType * setterRef
Reference to a variable to set.
Definition: PropertyDefinition.h:311
armarx::MessageTypeT::VERBOSE
@ VERBOSE
armarx::exceptions::local::ValueRangeExceededException
This exception is thrown if a value is out of a specified or allowed range.
Definition: ValueRangeExceededException.h:39
armarx::PropertyDefinition::getPropertyName
std::string getPropertyName() const
Definition: PropertyDefinition.hpp:281
armarx::MessageTypeT::IMPORTANT
@ IMPORTANT
armarx::PropertyDefinition::PropertyValuesMap
std::map< std::string, ValueEntry > PropertyValuesMap
Definition: PropertyDefinition.h:122
armarx::max
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:297
InvalidPropertyValueException.h
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::PropertyDefinition::PropertyDefinition
PropertyDefinition(PropertyType *setterRef, const std::string &propertyName, const std::string &description, PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Constructs a property definition of a required property.
Definition: PropertyDefinition.hpp:46
armarx::PropertyDefinition::setExpandEnvironmentVariables
PropertyDefinition< PropertyType > & setExpandEnvironmentVariables(bool expand)
Sets whether for string values environment varbiale expanding should be considered.
Definition: PropertyDefinition.hpp:178
armarx::exceptions
Definition: DynamicLibraryException.h:31
armarx::PropertyDefinition::setMin
PropertyDefinition< PropertyType > & setMin(double min)
Sets the min allowed numeric value.
Definition: PropertyDefinition.hpp:203
cxxopts::empty
bool empty(const std::string &s)
Definition: cxxopts.hpp:234
armarx::PropertyDefinition::isCaseInsensitive
bool isCaseInsensitive() const
Definition: PropertyDefinition.hpp:239
IceInternal::Handle<::Ice::Properties >
armarx::PropertyDefinition_parseIceUtilTime
IceUtil::Time PropertyDefinition_parseIceUtilTime(std::string const &input)
Definition: PropertyDefinition.cpp:110
ValueRangeExceededException.h
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::PropertyDefinition::ValueEntry
std::pair< std::string, PropertyType > ValueEntry
Definition: PropertyDefinition.h:121
armarx::PropertyDefinition_parseMapStringString
std::map< std::string, std::string > PropertyDefinition_parseMapStringString(const std::string &input)
Definition: PropertyDefinition.cpp:58
armarx::PropertyDefinition::getFactory
PropertyFactoryFunction getFactory() const
Definition: PropertyDefinition.hpp:317
armarx::PropertyDefinition::setRemoveQuotes
PropertyDefinition< PropertyType > & setRemoveQuotes(bool removeQuotes)
Sets whether for string values leading and trailing quotes should be removed.
Definition: PropertyDefinition.hpp:186
armarx::PropertyDefinitionBase::isSet
bool isSet(std::string const &prefix, std::string const &propertyName, Ice::PropertiesPtr const &iceProperties) const
Definition: PropertyDefinition.cpp:296
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:12
armarx::PropertyDefinition_lexicalCastToString
std::string PropertyDefinition_lexicalCastToString(float input)
Definition: PropertyDefinition.cpp:180
armarx::PropertyDefinition_lexicalCastTo< bool >
bool PropertyDefinition_lexicalCastTo< bool >(std::string const &input)
Definition: PropertyDefinition.cpp:283
max
T max(T t1, T t2)
Definition: gdiam.h:51
armarx::PropertyDefinition::toString
std::string toString(PropertyDefinitionFormatter &formatter, const std::string &value) override
Definition: PropertyDefinition.hpp:324
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::PropertyDefinition::expandEnvironmentVariables
bool expandEnvironmentVariables() const
Definition: PropertyDefinition.hpp:246
armarx::PropertyDefinition_toLowerCopy
std::string PropertyDefinition_toLowerCopy(const std::string &input)
Definition: PropertyDefinition.cpp:45
armarx::PropertyDefinition::getDefaultValue
PropertyType getDefaultValue()
Definition: PropertyDefinition.hpp:302
armarx::PropertyDefinition_matchRegex
bool PropertyDefinition_matchRegex(std::string const &regex, std::string const &value)
Definition: PropertyDefinition.cpp:51
MissingRequiredPropertyException.h
armarx::PropertyDefinition::getDescription
std::string getDescription() const
Definition: PropertyDefinition.hpp:288
armarx::PropertyDefinition::isSet
bool isSet(const std::string &prefix, Ice::PropertiesPtr iceProperties) const
Definition: PropertyDefinition.hpp:688
armarx::exceptions::local::InvalidPropertyValueException
This exception is thrown if an invalid value was specified for a property.
Definition: InvalidPropertyValueException.h:38
armarx::PropertyDefinition::setMatchRegex
PropertyDefinition< PropertyType > & setMatchRegex(const std::string &expr)
Sets the regular expression which the value has to be matched with.
Definition: PropertyDefinition.hpp:194
UnmappedValueException.h
armarx::PropertyDefinition::removeQuotes
bool removeQuotes() const
Definition: PropertyDefinition.hpp:253
armarx::min
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:327
armarx::PropertyDefinitionFormatter::formatDefinition
virtual std::string formatDefinition(std::string name, std::string description, std::string min, std::string max, std::string default_, std::string casesensitivity, std::string requirement, std::string reged, std::vector< std::string > values, std::string value)=0
Definition: PropertyDefinitionFormatter.cpp:33
armarx::MessageTypeT::DEBUG
@ DEBUG
armarx::PropertyDefinition::getDefaultAsString
std::string getDefaultAsString() override
Definition: PropertyDefinition.hpp:356
armarx::meta::properties::DefaultAsStringPlugin
Definition: PropertyDefinition.h:69
armarx::PropertyDefinition::setCaseInsensitive
PropertyDefinition< PropertyType > & setCaseInsensitive(bool isCaseInsensitive)
Sets whether the property value matching is case insensitive.
Definition: PropertyDefinition.hpp:144
T
float T
Definition: UnscentedKalmanFilterTest.cpp:38
armarx::exceptions::local::MissingRequiredPropertyException
This exception is thrown if a property marked as required has not been specified.
Definition: MissingRequiredPropertyException.h:48
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::PropertyDefinition::setFactory
PropertyDefinition< PropertyType > & setFactory(const PropertyFactoryFunction &func)
Sets the factory function that creates the specified template type from the actual string value.
Definition: PropertyDefinition.hpp:135
armarx::exceptions::local::UnmappedValueException
This exception is thrown if a value specified for a property is not found in the property mapping Pro...
Definition: UnmappedValueException.h:39
armarx::PropertyDefinition::setMax
PropertyDefinition< PropertyType > & setMax(double max)
Sets the max allowed numeric value.
Definition: PropertyDefinition.hpp:221
armarx::PropertyDefinitionFormatter
PropertyDefinitionFormatter is the base class for all formatters of PropertyDefinitions.
Definition: PropertyDefinitionFormatter.h:38
armarx::PropertyDefinition::getMin
double getMin() const
Definition: PropertyDefinition.hpp:267
armarx::PropertyDefinition
PropertyDefinition defines a property that will be available within the PropertyUser.
Definition: PropertyDefinition.h:117
armarx::PropertyDefinition::PropertyFactoryFunction
std::function< PropertyType(std::string)> PropertyFactoryFunction
Definition: PropertyDefinition.h:123
armarx::PropertyDefinition::writeValueToSetter
virtual void writeValueToSetter(const std::string &prefix, Ice::PropertiesPtr) override
Definition: PropertyDefinition.hpp:460
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
PropertyDefinition.h
armarx::PropertyDefinition::map
PropertyDefinition< PropertyType > & map(const std::string &valueString, PropertyType value)
Maps a string value onto a value of the specified template type.
Definition: PropertyDefinition.hpp:93
armarx::PropertyDefinition_lexicalCastTo< double >
double PropertyDefinition_lexicalCastTo< double >(std::string const &input)
Definition: PropertyDefinition.cpp:225