PropertyDefinitionContainer.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package ArmarXCore::core
19  * @author Jan Issac (jan dot issac at gmx dot de)
20  * @date 2012
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #pragma once
27 
28 #include <map>
29 #include <string>
30 #include <typeinfo>
31 #include <vector>
32 
33 #include <Ice/Proxy.h>
34 #include <Ice/ProxyHandle.h>
35 
42 
43 namespace armarx
44 {
45  class PropertyDefinitionBase;
46 
47  /**
48  * @ingroup properties
49  *
50  * @class PropertyDefinitionContainer
51  * @brief PropertyDefinitionContainer
52  */
53  class PropertyDefinitionContainer : public virtual IceUtil::Shared
54  {
55  public:
56  typedef std::map<std::string, PropertyDefinitionBase*> DefinitionContainer;
57 
58  PropertyDefinitionContainer(const std::string& prefix);
59 
61 
63 
65 
66  void writeValues();
68  std::map<std::string, ProxyPropertyDefinitionBase*> getProxyDefinitions();
69  std::vector<std::string> getSubscribedTopicDefinitions();
70 
71  template <typename PropertyType>
72  decltype(auto)
74  PropertyType& setter,
75  const std::string& name,
76  const std::string& description = "",
77  PropertyDefinitionBase::PropertyConstness constness = PropertyDefinitionBase::eConstant)
78  {
79  return requiredOrOptional(true, setter, name, description, constness);
80  }
81 
82  template <typename PropertyType>
83  decltype(auto)
85  PropertyType& setter,
86  const std::string& name,
87  const std::string& description = "",
88  PropertyDefinitionBase::PropertyConstness constness = PropertyDefinitionBase::eConstant)
89  {
90  return requiredOrOptional(false, setter, name, description, constness);
91  }
92 
93  template <typename PropertyType>
94  decltype(auto) requiredOrOptional(bool isRequired,
95  PropertyType& setter,
96  const std::string& name,
97  const std::string& description = "",
98  PropertyDefinitionBase::PropertyConstness constness =
99  PropertyDefinitionBase::eConstant);
100 
101  public:
102  template <typename PropertyType>
103  void component(IceInternal::ProxyHandle<PropertyType>& setter,
104  const std::string& default_name = "",
105  const std::string& property_name = "",
106  const std::string& description = "");
107 
108  /**
109  * Define a property to set the name of a topic which is subscribed to.
110  *
111  * This defines property to set the name of a topic of the given type from setter. Before
112  * `Component::onInitComponent()`, the component will subscribe to this topic, and before
113  * `Component::onConnectComponent()`, the topic proxy will be written into `setter`.
114  */
115  template <typename PropertyType>
116  void topic(IceInternal::ProxyHandle<PropertyType>& setter,
117  const std::string& default_name = "",
118  const std::string& property_name = "",
119  const std::string& description = "");
120 
121  /**
122  * Define a topic which is offered from the component via the template parameter.
123  *
124  * Sane defaults will be chosen for the property name and the default values depending on
125  * the template parameter, but these values can all be overridden with the parameters.
126  */
127  template <typename PropertyType>
128  void topic(std::string default_name = "",
129  std::string property_name = "",
130  std::string description = "");
131 
132  template <typename PropertyType>
133  PropertyDefinition<PropertyType>&
134  defineRequiredProperty(const std::string& name,
135  const std::string& description = "",
136  PropertyDefinitionBase::PropertyConstness constness =
137  PropertyDefinitionBase::eConstant);
138 
139  template <typename PropertyType>
140  PropertyDefinition<PropertyType>&
141  defineOptionalProperty(const std::string& name,
142  PropertyType defaultValue,
143  const std::string& description = "",
144  PropertyDefinitionBase::PropertyConstness constness =
145  PropertyDefinitionBase::eConstant);
146 
147  /**
148  * @brief Define a required property for an Eigen vector type.
149  * The EigenVectorType can be any Eigen::Vector type, (Vector3f, VectorXd, ...).
150  *
151  * @param delimiter the delimiter between vector coefficients in the string representation
152  *
153  * Usage example:
154  * @code
155  * // Definition
156  * // accepts e.g. "1.0 2.0 3.0" and "1.0 -.3 .5"
157  * defineRequiredPropertyVector<Eigen::Vector3f>("Position", "The position.");
158  * // accepts e.g. "640x480" and "1920x1080"
159  * defineRequiredPropertyVector<Eigen::Vector2i>("Resolution", "The resolution.", 'x');
160  * // accepts e.g. "0,1,2,3,4,5,6,7,8,9" and "1"
161  * defineRequiredPropertyVector<Eigen::VectorXd>("Values", "The values.", ',');
162  *
163  * // Usage:
164  * Eigen::Vector3f position = getProperty<Eigen::Vector3f>("Position");
165  * Eigen::Vector2i resolution = getProperty<Eigen::Vector2i>("Resolution");
166  * Eigen::VectorXd values = getProperty<Eigen::VectorXd>("Values");
167  * // .getValue() can trigger Eigen's implicit conversion
168  * Eigen::VectorXf positionX = getProperty<Eigen::VectorXf>("Position").getValue();
169  *
170  * // Specification on command line:
171  * ./<binary> --ArmarX.<ComponentName>.Position="1 2 3"
172  * @endcode
173  */
174  template <typename EigenVectorType>
175  PropertyDefinition<EigenVectorType>&
176  defineRequiredPropertyVector(const std::string& name,
177  const std::string& description = "",
178  const std::string& delimiter = " ",
179  PropertyDefinitionBase::PropertyConstness constness =
180  PropertyDefinitionBase::eConstant);
181 
182  // Legacy overloads taking char as delimiter.
183  template <typename EigenVectorType>
184  PropertyDefinition<EigenVectorType>&
185  defineRequiredPropertyVector(const std::string& name,
186  const std::string& description,
187  char delimiter,
188  PropertyDefinitionBase::PropertyConstness constness)
189  {
190  return defineRequiredPropertyVector<EigenVectorType>(
191  name, description, std::string(1, delimiter), constness);
192  }
193 
194  template <typename EigenVectorType>
196  defineRequiredPropertyVector(const std::string& name,
197  const std::string& description,
198  char delimiter)
199  {
200  return defineRequiredPropertyVector<EigenVectorType>(
202  }
203 
204  /**
205  * @brief Define a required property for an Eigen vector type.
206  * The EigenVectorType can be any Eigen::Vector type, (Vector3f, VectorXd, ...).
207  * @param delimiter the delimiter between vector coefficients in the string representation
208  *
209  * Usage example:
210  * @code
211  * // Definition
212  * // defaults to "0 0 0", accepts e.g. "1.0 2.0 3.0" and "1.0 -.3 .5"
213  * defineOptionalPropertyVector<Eigen::Vector3f>(
214  * "Position", Eigen::Vector3f::Zero(), "The position.");
215  * // defaults to "640x480", accepts e.g. "1920x1080"
216  * defineOptionalPropertyVector<Eigen::Vector2i>(
217  * "Resolution", Eigen::Vector2f(640, 480), "The resolution.", 'x');
218  * // defaults to "0,1,2,3,4,5,6,7,8,9", accepts e.g. "1" or "1,2,3"
219  * Eigen::VectorXd valuesDefault(10);
220  * valuesDefault << 0, 1, 2, 3, 4, 5, 6, 7, 8, 9;
221  * defineOptionalPropertyVector<Eigen::VectorXd>(
222  * "Values", valuesDefault, "The values.", ',');
223  *
224  * // Usage:
225  * Eigen::Vector3f position = getProperty<Eigen::Vector3f>("Position");
226  * Eigen::Vector2i resolution = getProperty<Eigen::Vector2i>("Resolution");
227  * Eigen::VectorXd values = getProperty<Eigen::VectorXd>("Values");
228  * // .getValue() can trigger Eigen's implicit conversion
229  * Eigen::VectorXf positionX = getProperty<Eigen::VectorXf>("Position").getValue();
230  *
231  * // Specification on command line:
232  * ./<binary> --ArmarX.<ComponentName>.Position="1 2 3"
233  * @endcode
234  */
235  template <typename EigenVectorType>
237  defineOptionalPropertyVector(const std::string& name,
238  EigenVectorType defaultValue,
239  const std::string& description = "",
240  const std::string& delimiter = " ",
243 
244  // Legacy overloads taking char as delimiter.
245  template <typename EigenVectorType>
247  defineOptionalPropertyVector(const std::string& name,
248  EigenVectorType defaultValue,
249  const std::string& description,
250  char delimiter,
252  {
253  return defineOptionalPropertyVector<EigenVectorType>(
254  name, defaultValue, description, std::string(1, delimiter), constness);
255  }
256 
257  template <typename EigenVectorType>
259  defineOptionalPropertyVector(const std::string& name,
260  EigenVectorType defaultValue,
261  const std::string& description,
262  char delimiter)
263  {
264  return defineOptionalPropertyVector<EigenVectorType>(
265  name, defaultValue, description, delimiter, PropertyDefinitionBase::eConstant);
266  }
267 
268  PropertyDefinitionBase* getDefinitionBase(const std::string& name);
269 
270  template <typename PropertyType>
271  PropertyDefinition<PropertyType>& getDefintion(const std::string& name);
272 
273  bool
274  hasDefinition(const std::string& name) const
275  {
276  return (definitions.find(name) != definitions.end());
277  }
278 
279  std::string toString(PropertyDefinitionFormatter& formatter);
280 
281  /**
282  * Returns the detailed description of the property user
283  *
284  * @return detailed description text
285  */
286  std::string getDescription() const;
287 
288  /**
289  * Sets the detailed description of the property user
290  *
291  * @param description detailed description text
292  */
293  void setDescription(const std::string& description);
294 
295  void setPrefix(std::string prefix);
296 
297  std::string getPrefix();
298 
299  bool isPropertySet(const std::string& name);
300 
301  std::string getValue(const std::string& name);
302 
303  std::map<std::string, std::string> getPropertyValues(const std::string& prefix = "") const;
304 
305  /**
306  * @brief Parses `string` to an Eigen vector of type `EigenVectorType`.
307  * @param delim The delimiter between coefficients.
308  * @throw std::bad_cast If parsing `string` fails.
309  */
310  template <typename EigenVectorType>
311  static EigenVectorType eigenVectorFactoryFunction(std::string string, std::string delim);
312  template <typename EigenVectorType>
313  static std::string eigenVectorToString(const EigenVectorType& vector, std::string delim);
314 
315  static std::string eigenVectorPropertyDescription(const std::string& description,
316  long size,
317  std::string delim);
318 
319  private:
320  template <typename PropertyType>
321  std::string ice_class_name();
322 
323  template <typename PropertyType>
324  void proxy(IceInternal::ProxyHandle<PropertyType>& setter,
325  const ProxyType proxy_type,
326  std::string default_name,
327  std::string property_name,
328  std::string description);
329 
330 
331  protected:
332  /**
333  * Property definitions container
334  */
336 
337  std::map<std::string, ProxyPropertyDefinitionBase*> proxies;
338 
339  std::vector<std::string> subscribedTopics;
340 
341  /**
342  * Prefix of the properties such as namespace, domain, component name,
343  * etc.
344  */
345  std::string prefix;
346 
347  /**
348  * Property User description
349  */
350  std::string description;
351 
352  /**
353  * PropertyUser brief description
354  */
355  std::string briefDescription;
356 
358  };
359 
360  /**
361  * PropertyDefinitions smart pointer type
362  */
364 
365  /* ====================================================================== */
366  /* === Property Definition Container Implementation ===================== */
367  /* ====================================================================== */
368 
369  std::string PropertyDefinitionContainer_ice_class_name(std::string const& full_type_name);
370 
371  template <typename PropertyType>
372  std::string
373  PropertyDefinitionContainer::ice_class_name()
374  {
375  const std::string full_type_name = PropertyType::ice_staticId();
376  return PropertyDefinitionContainer_ice_class_name(full_type_name);
377  }
378 
379  template <typename PropertyType>
380  inline decltype(auto)
381  PropertyDefinitionContainer::requiredOrOptional(
382  bool isRequired,
383  PropertyType& setter,
384  const std::string& name,
385  const std::string& description,
386  PropertyDefinitionBase::PropertyConstness constness)
387  {
388  using plugin = meta::properties::DefinePropertyPlugin<PropertyType>;
389  if constexpr (plugin::value)
390  {
391  plugin::Define(*this, isRequired, setter, name, description, constness);
392  }
393  else
394  {
395  PropertyDefinition<PropertyType>* def;
396  if (isRequired)
397  {
398  def = new PropertyDefinition<PropertyType>(&setter, name, description, constness);
399  }
400  else
401  {
402  def = new PropertyDefinition<PropertyType>(
403  &setter, name, setter, description, constness);
404  }
405 
406  def->setTypeIdName(typeid(PropertyType).name());
407  definitions[name] = static_cast<PropertyDefinitionBase*>(def);
408  return *def;
409  }
410  }
411 
412  template <typename PropertyType>
413  void
415  const std::string& default_name,
416  const std::string& property_name,
417  const std::string& description)
418  {
419  proxy(setter, ProxyType::component, default_name, property_name, description);
420  }
421 
422  template <typename PropertyType>
423  void
425  const std::string& default_name,
426  const std::string& property_name,
427  const std::string& description)
428  {
429  proxy(setter, ProxyType::topic, default_name, property_name, description);
430  }
431 
432  template <typename PropertyType>
433  void
434  PropertyDefinitionContainer::topic(std::string default_name,
435  std::string property_name,
436  std::string description)
437  {
438  const std::string class_name = ice_class_name<PropertyType>();
439 
440  if (default_name.empty())
441  {
442  default_name = class_name;
443  }
444  if (property_name.empty())
445  {
446  property_name = "tpc.sub." + class_name;
447  }
448  if (description.empty())
449  {
450  description = "Name of the `" + class_name + "` topic to subscribe to.";
451  }
452 
453  // Append property definition for the proxy name.
455  nullptr, property_name, default_name, description, PropertyDefinitionBase::eConstant);
456  def_name->setTypeIdName(typeid(std::string).name());
457  definitions[property_name] = static_cast<PropertyDefinitionBase*>(def_name);
458  subscribedTopics.push_back(property_name);
459  }
460 
461  template <typename PropertyType>
462  void
463  PropertyDefinitionContainer::proxy(IceInternal::ProxyHandle<PropertyType>& setter,
464  const ProxyType proxy_type,
465  std::string default_name,
466  std::string property_name,
467  std::string description)
468  {
469  using PropertyTypePrx = IceInternal::ProxyHandle<PropertyType>;
470 
471  const std::string class_name = ice_class_name<PropertyType>();
472 
473  if (default_name.empty())
474  {
475  default_name = class_name;
476  }
477  if (property_name.empty())
478  {
479  switch (proxy_type)
480  {
482  property_name = "cmp." + class_name;
483  break;
484  case ProxyType::topic:
485  property_name = "tpc.pub." + class_name;
486  break;
487  }
488  }
489  if (description.empty())
490  {
491  switch (proxy_type)
492  {
494  description = "Ice object name of the `" + class_name + "` component.";
495  break;
496  case ProxyType::topic:
497  description = "Name of the `" + class_name + "` topic to publish data to.";
498  break;
499  }
500  }
501 
502  // Append property definition for the proxy name.
503  PropertyDefinition<std::string>* def_name = new PropertyDefinition<std::string>(
504  nullptr, property_name, default_name, description, PropertyDefinitionBase::eConstant);
505  def_name->setTypeIdName(typeid(std::string).name());
506  definitions[property_name] = static_cast<PropertyDefinitionBase*>(def_name);
507 
508  // Append proxy definition.
509  ProxyPropertyDefinition<PropertyTypePrx>* def =
510  new ProxyPropertyDefinition<PropertyTypePrx>(&setter, proxy_type);
511  proxies[property_name] = static_cast<ProxyPropertyDefinitionBase*>(def);
512  }
513 
514  template <typename PropertyType>
515  PropertyDefinition<PropertyType>&
517  const std::string& name,
518  const std::string& description,
520  {
522  new PropertyDefinition<PropertyType>(nullptr, name, description, constness);
523 
524  def->setTypeIdName(typeid(PropertyType).name());
525 
526  definitions[name] = static_cast<PropertyDefinitionBase*>(def);
527 
528  return *def;
529  }
530 
531  template <typename PropertyType>
534  const std::string& name,
535  PropertyType defaultValue,
536  const std::string& description,
538  {
540  nullptr, name, defaultValue, description, constness);
541 
542  def->setTypeIdName(typeid(PropertyType).name());
543 
544  definitions[name] = static_cast<PropertyDefinitionBase*>(def);
545 
546  return *def;
547  }
548 
549  template <typename EigenVectorType>
552  const std::string& name,
553  const std::string& description,
554  const std::string& delimiter,
556  {
557  std::string appendedDescription = eigenVectorPropertyDescription(
558  description, EigenVectorType::SizeAtCompileTime, delimiter);
559 
561  defineRequiredProperty<EigenVectorType>(name, appendedDescription, constness);
562 
563  // set a factory
564  def.setFactory([delimiter](std::string string) -> EigenVectorType
565  { return eigenVectorFactoryFunction<EigenVectorType>(string, delimiter); });
566  def.setCaseInsensitive(true);
567 
568  return def;
569  }
570 
571  template <typename EigenVectorType>
574  const std::string& name,
575  EigenVectorType defaultValue,
576  const std::string& description,
577  const std::string& delimiter,
579  {
580  std::string appendedDescription = eigenVectorPropertyDescription(
581  description, EigenVectorType::SizeAtCompileTime, delimiter);
582 
583  PropertyDefinition<EigenVectorType>& def = defineOptionalProperty<EigenVectorType>(
584  name, defaultValue, appendedDescription, constness);
585 
586  // set a factory
587  def.setFactory([delimiter](std::string string) -> EigenVectorType
588  { return eigenVectorFactoryFunction<EigenVectorType>(string, delimiter); });
589  // map the default value
590  def.map(eigenVectorToString<EigenVectorType>(defaultValue, delimiter), defaultValue);
591  def.setCaseInsensitive(true);
592 
593  return def;
594  }
595 
596  template <typename PropertyType>
599  {
600  // check definition existance
601  if (definitions.find(name) == definitions.end())
602  {
603  std::stringstream ss;
604  ss << name + " property is not defined. Defined are ";
605  for (typename DefinitionContainer::iterator it = definitions.begin();
606  it != definitions.end();
607  ++it)
608  {
609  ss << "\n" << it->first;
610  }
611  throw armarx::LocalException(ss.str());
612  }
613 
614  PropertyDefinitionBase* def = definitions[name];
615 
616  // check definition type
617  if (def->getTypeIdName().compare(typeid(PropertyType).name()) != 0)
618  {
619  throw armarx::LocalException(
620  std::string("Calling getProperty<T>() for the property '") + name +
621  "' with wrong property type [note: " + typeid(PropertyType).name() +
622  " instead of " + def->getTypeIdName() + "]");
623  }
624 
625  // retrieve and down cast the requested definition
626  return *dynamic_cast<PropertyDefinition<PropertyType>*>(def);
627  }
628 
629  template <typename EigenVectorType>
630  EigenVectorType
631  PropertyDefinitionContainer::eigenVectorFactoryFunction(std::string string, std::string delim)
632  {
633  using Scalar = typename EigenVectorType::Scalar;
634 
635  long size = EigenVectorType::SizeAtCompileTime;
636  bool isFixedSize = size >= 0; // Eigen::Dynamic is -1.
637 
638  const std::vector<std::string> stringScalars = split(string, delim, true);
639 
640  std::vector<Scalar> scalars;
641  if (isFixedSize)
642  {
643  if (stringScalars.size() != static_cast<std::size_t>(size))
644  {
645  throw std::bad_cast();
646  }
647  scalars.reserve(size);
648  }
649  for (const auto& scalarStr : stringScalars)
650  {
651  // May throw boost::bad_lexical_cast (derives from std::bad_cast).
652  Scalar value = PropertyDefinition_lexicalCastTo<Scalar>(scalarStr);
653  scalars.push_back(value);
654  }
655 
656  EigenVectorType vector;
657  if (!isFixedSize)
658  {
659  vector.resize(scalars.size());
660  }
661  // Write values.
662  for (std::size_t i = 0; i < scalars.size(); ++i)
663  {
664  vector(i) = scalars[i];
665  }
666  return vector;
667  }
668 
669  template <typename EigenVectorType>
670  std::string
672  std::string delim)
673  {
674  std::stringstream ss;
675  long size = vector.size();
676 
677  ss << vector(0);
678  for (int i = 1; i < size; ++i)
679  {
680  ss << delim << vector(i);
681  }
682 
683  return ss.str();
684  }
685 
686 
687 } // namespace armarx
armarx::PropertyDefinitionContainer::eigenVectorFactoryFunction
static EigenVectorType eigenVectorFactoryFunction(std::string string, std::string delim)
Parses string to an Eigen vector of type EigenVectorType.
Definition: PropertyDefinitionContainer.h:631
armarx::PropertyDefinitionContainer::setPrefix
void setPrefix(std::string prefix)
Definition: PropertyDefinitionContainer.cpp:192
armarx::PropertyDefinitionContainer::getDescription
std::string getDescription() const
Returns the detailed description of the property user.
Definition: PropertyDefinitionContainer.cpp:180
armarx::PropertyDefinitionContainer::getProperties
Ice::PropertiesPtr getProperties()
Definition: PropertyDefinitionContainer.cpp:118
armarx::PropertyDefinitionBase
Common interface of any property definition.
Definition: PropertyDefinitionInterface.h:51
armarx::PropertyDefinitionContainer::setProperties
void setProperties(Ice::PropertiesPtr properties)
Definition: PropertyDefinitionContainer.cpp:124
armarx::PropertyDefinitionContainer::setDescription
void setDescription(const std::string &description)
Sets the detailed description of the property user.
Definition: PropertyDefinitionContainer.cpp:186
armarx::PropertyDefinitionContainer::defineRequiredProperty
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Definition: PropertyDefinitionContainer.h:516
LocalException.h
armarx::PropertyDefinitionContainer::defineOptionalProperty
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Definition: PropertyDefinitionContainer.h:533
armarx::PropertyDefinitionBase::PropertyConstness
PropertyConstness
Definition: PropertyDefinitionInterface.h:54
armarx::PropertyDefinitionContainer::hasDefinition
bool hasDefinition(const std::string &name) const
Definition: PropertyDefinitionContainer.h:274
armarx::ProxyType::component
@ component
armarx::PropertyDefinitionContainer::writeValues
void writeValues()
Definition: PropertyDefinitionContainer.cpp:76
armarx::PropertyDefinitionContainer::required
decltype(auto) required(PropertyType &setter, const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Definition: PropertyDefinitionContainer.h:73
armarx::PropertyDefinitionContainer::briefDescription
std::string briefDescription
PropertyUser brief description.
Definition: PropertyDefinitionContainer.h:355
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
PropertyDefinitionFormatter.h
armarx::PropertyDefinitionContainer::eigenVectorPropertyDescription
static std::string eigenVectorPropertyDescription(const std::string &description, long size, std::string delim)
Definition: PropertyDefinitionContainer.cpp:255
armarx::PropertyDefinitionContainer::subscribedTopics
std::vector< std::string > subscribedTopics
Definition: PropertyDefinitionContainer.h:339
armarx::PropertyDefinitionContainer::component
void component(IceInternal::ProxyHandle< PropertyType > &setter, const std::string &default_name="", const std::string &property_name="", const std::string &description="")
Definition: PropertyDefinitionContainer.h:414
armarx::PropertyDefinitionContainer::defineRequiredPropertyVector
PropertyDefinition< EigenVectorType > & defineRequiredPropertyVector(const std::string &name, const std::string &description, char delimiter)
Definition: PropertyDefinitionContainer.h:196
armarx::PropertyDefinitionContainer::topic
void topic(IceInternal::ProxyHandle< PropertyType > &setter, const std::string &default_name="", const std::string &property_name="", const std::string &description="")
Define a property to set the name of a topic which is subscribed to.
Definition: PropertyDefinitionContainer.h:424
IceInternal::Handle<::Ice::Properties >
armarx::PropertyDefinitionContainer::getValue
std::string getValue(const std::string &name)
Definition: PropertyDefinitionContainer.cpp:211
armarx::PropertyDefinitionContainer::description
std::string description
Property User description.
Definition: PropertyDefinitionContainer.h:350
armarx::PropertyDefinitionContainer::getDefintion
PropertyDefinition< PropertyType > & getDefintion(const std::string &name)
Definition: PropertyDefinitionContainer.h:598
PropertyDefinitionInterface.h
armarx::PropertyDefinitionContainer::defineOptionalPropertyVector
PropertyDefinition< EigenVectorType > & defineOptionalPropertyVector(const std::string &name, EigenVectorType defaultValue, const std::string &description, char delimiter, PropertyDefinitionBase::PropertyConstness constness)
Definition: PropertyDefinitionContainer.h:247
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::PropertyDefinitionContainer::definitions
DefinitionContainer definitions
Property definitions container.
Definition: PropertyDefinitionContainer.h:335
armarx::ProxyType::topic
@ topic
armarx::PropertyDefinitionContainer::getProxyDefinitions
std::map< std::string, ProxyPropertyDefinitionBase * > getProxyDefinitions()
Definition: PropertyDefinitionContainer.cpp:106
IceManager.h
armarx::ProxyType
ProxyType
Definition: ProxyPropertyDefinition.h:40
armarx::PropertyDefinitionContainer::proxies
std::map< std::string, ProxyPropertyDefinitionBase * > proxies
Definition: PropertyDefinitionContainer.h:337
armarx::PropertyDefinitionContainer::properties
Ice::PropertiesPtr properties
Definition: PropertyDefinitionContainer.h:357
armarx::PropertyDefinitionContainer::getDefinitionBase
PropertyDefinitionBase * getDefinitionBase(const std::string &name)
Definition: PropertyDefinitionContainer.cpp:130
IceInternal
This file is part of ArmarX.
Definition: InstrumentationI.h:16
armarx::PropertyDefinitionContainer
PropertyDefinitionContainer.
Definition: PropertyDefinitionContainer.h:53
armarx::PropertyDefinitionContainer::getPropertyValues
std::map< std::string, std::string > getPropertyValues(const std::string &prefix="") const
Definition: PropertyDefinitionContainer.cpp:224
armarx::PropertyDefinitionContainer::requiredOrOptional
decltype(auto) requiredOrOptional(bool isRequired, PropertyType &setter, const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
armarx::PropertyDefinitionContainer::writeProxyValues
void writeProxyValues(IceManagerPtr)
Definition: PropertyDefinitionContainer.cpp:88
armarx::PropertyDefinitionContainer::getSubscribedTopicDefinitions
std::vector< std::string > getSubscribedTopicDefinitions()
Definition: PropertyDefinitionContainer.cpp:112
armarx::PropertyDefinitionContainer::defineOptionalPropertyVector
PropertyDefinition< EigenVectorType > & defineOptionalPropertyVector(const std::string &name, EigenVectorType defaultValue, const std::string &description="", const std::string &delimiter=" ", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Define a required property for an Eigen vector type.
Definition: PropertyDefinitionContainer.h:573
armarx::PropertyDefinitionContainer::optional
decltype(auto) optional(PropertyType &setter, const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Definition: PropertyDefinitionContainer.h:84
std
Definition: Application.h:66
IceUtil::Handle< IceManager >
armarx::PropertyDefinitionContainer::DefinitionContainer
std::map< std::string, PropertyDefinitionBase * > DefinitionContainer
Definition: PropertyDefinitionContainer.h:56
Scalar
float Scalar
Definition: basic.h:15
IceInternal::ProxyHandle
Definition: ObjectPoseClientWidget.h:45
armarx::PropertyDefinitionContainer::isPropertySet
bool isPropertySet(const std::string &name)
Definition: PropertyDefinitionContainer.cpp:204
armarx::PropertyDefinitionContainer::defineOptionalPropertyVector
PropertyDefinition< EigenVectorType > & defineOptionalPropertyVector(const std::string &name, EigenVectorType defaultValue, const std::string &description, char delimiter)
Definition: PropertyDefinitionContainer.h:259
armarx::PropertyDefinitionContainer_ice_class_name
std::string PropertyDefinitionContainer_ice_class_name(std::string const &full_type_name)
Definition: PropertyDefinitionContainer.cpp:276
armarx::PropertyDefinitionContainer::eigenVectorToString
static std::string eigenVectorToString(const EigenVectorType &vector, std::string delim)
Definition: PropertyDefinitionContainer.h:671
armarx::PropertyDefinitionContainer::getPrefix
std::string getPrefix()
Definition: PropertyDefinitionContainer.cpp:198
armarx::PropertyDefinition::setCaseInsensitive
PropertyDefinition< PropertyType > & setCaseInsensitive(bool isCaseInsensitive)
Sets whether the property value matching is case insensitive.
Definition: PropertyDefinition.hpp:144
ProxyPropertyDefinition.h
armarx::PropertyDefinitionContainer::~PropertyDefinitionContainer
~PropertyDefinitionContainer() override
Definition: PropertyDefinitionContainer.cpp:60
armarx::PropertyDefinitionContainer::PropertyDefinitionContainer
PropertyDefinitionContainer(const std::string &prefix)
Definition: PropertyDefinitionContainer.cpp:53
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::PropertyDefinitionFormatter
PropertyDefinitionFormatter is the base class for all formatters of PropertyDefinitions.
Definition: PropertyDefinitionFormatter.h:38
armarx::PropertyDefinition
PropertyDefinition defines a property that will be available within the PropertyUser.
Definition: PropertyDefinition.h:117
armarx::PropertyDefinitionContainer::defineRequiredPropertyVector
PropertyDefinition< EigenVectorType > & defineRequiredPropertyVector(const std::string &name, const std::string &description="", const std::string &delimiter=" ", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Define a required property for an Eigen vector type.
Definition: PropertyDefinitionContainer.h:551
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::PropertyDefinitionContainer::toString
std::string toString(PropertyDefinitionFormatter &formatter)
Definition: PropertyDefinitionContainer.cpp:143
armarx::split
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelpers.cpp:38
armarx::PropertyDefinitionBase::eConstant
@ eConstant
Definition: PropertyDefinitionInterface.h:56