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