LiteralImpl.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 ArmarX::Core
19 * @author Kai Welke (welke _at_ kit _dot_ edu)
20 * @date 2012
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24 
25 #pragma once
26 
27 #include <memory>
28 #include <string>
29 
30 #include <IceUtil/Handle.h>
31 
33 #include <ArmarXCore/interface/observers/ObserverInterface.h>
34 #include <ArmarXCore/interface/observers/VariantBase.h>
38 
39 namespace armarx
40 {
41  class LiteralImpl;
42 
43  /**
44  * Typedef of LiteralImplPtr as IceInternal::Handle<LiteralImpl> for convenience.
45  */
47 
48  /**
49  * @class LiteralImpl
50  * @brief LiteralImpls are the basic elements for defining conditional expressions.
51  * @ingroup Conditions
52  *
53  * LiteralImpl are leaves in the expression tree. Each LiteralImpl is associated to a ConditionCheck. The state of
54  * the LiteralImpl corresponds to the state of the ConditionCheck.
55  */
57  virtual public LiteralImplBase,
58  virtual public TermImpl
59  {
60  friend class ConditionHandler;
61  friend class Literal;
62  template <class BaseClass, class VariantClass>
63  friend class GenericFactory;
64 
65  protected:
66  /**
67  * Creates an empty LiteralImpl. Required for Ice ObjectFactory
68  */
69  LiteralImpl();
70 
71  ~LiteralImpl();
72 
73  /**
74  * Creates a LiteralImpl using string as dataFieldIdentifier with multiple parameter. See also createParameterList().
75  *
76  * @param dataFieldIdentifierStr identifier of the datafield used by the condition in the form "observerName.channelName.datafieldName"
77  * @param checkName name of the condition check
78  * @param checkParameter parameter for the condition check
79  */
80  LiteralImpl(const std::string& dataFieldIdentifierStr,
81  const std::string& checkName,
82  const ParameterList& checkParameters);
83 
84  /**
85  * Creates a LiteralImpl using the DataFieldIdentifier type with multiple parameter. See also createParameterList()
86  *
87  * @param dataFieldIdentifier identifier of the datafield used by the condition
88  * @param checkName name of the condition check
89  * @param checkParameters list of check parameters
90  */
91  LiteralImpl(const DataFieldIdentifier& dataFieldIdentifier,
92  const std::string& checkName,
93  const ParameterList& checkParameters);
94 
95  /**
96  * Creates a LiteralImpl using the DataFieldIdentifier type with multiple parameter. See also createParameterList()
97  *
98  * @param dataFieldIdentifier pointer to identifier of the datafield used by the condition
99  * @param checkName name of the condition check
100  * @param checkParameters list of check parameters
101  */
102  LiteralImpl(const DataFieldIdentifierPtr& dataFieldIdentifier,
103  const std::string& checkName,
104  const ParameterList& checkParameters);
105 
106  LiteralImpl(const DatafieldRefBasePtr& dataFieldIdentifier,
107  const std::string& checkName,
108  const ParameterList& checkParameters);
109 
110  void createInstance();
111 
112  public:
113  /**
114  * Retrieve check configuration. Inherited from LiteralImplBase
115  *
116  * @return configuration of check
117  */
118  CheckConfiguration
119  getCheckConfiguration(const Ice::Current& c = Ice::emptyCurrent) override;
120 
121  /**
122  * Set value of LiteralImpl
123  *
124  * @param value of LiteralImpl
125  */
126  void setValue(bool value, const Ice::Current& c = Ice::emptyCurrent) override;
127  void setValueAndData(bool value,
130  const Ice::Current& c = Ice::emptyCurrent) override;
131 
132  /**
133  * Reimplementation of the ice_clone method.
134  *
135  * @return clone of the object
136  */
137  Ice::ObjectPtr ice_clone() const override;
138 
139  /**
140  * output to stream. pure virtual.
141  *
142  * @param stream
143  */
144  void output(std::ostream& out) const override;
145 
146  /**
147  * stream operator for LiteralImpl
148  */
149  friend std::ostream&
150  operator<<(std::ostream& stream, const LiteralImpl& rhs)
151  {
152  rhs.output(stream);
153 
154  return stream;
155  }
156 
157  /**
158  * stream operator for LiteralImplPtr
159  */
160  friend std::ostream&
161  operator<<(std::ostream& stream, const LiteralImplPtr& rhs)
162  {
163  rhs->output(stream);
164 
165  return stream;
166  }
167 
168  protected:
169  void init(const std::string& dataFieldIdentifierStr,
170  const std::string& checkName,
171  const ParameterList& checkParameters);
172 
173  private:
174  void installCheck(const Ice::ObjectAdapterPtr& adapter, const ObserverInterfacePrx& proxy);
175  void removeCheck(const Ice::ObjectAdapterPtr& adapter, const ObserverInterfacePrx& proxy);
176 
177  struct Impl;
178  std::unique_ptr<Impl> impl;
179  };
180 } // namespace armarx
181 extern template class ::IceInternal::Handle<::armarx::LiteralImpl>;
armarx::LiteralImpl
LiteralImpls are the basic elements for defining conditional expressions.
Definition: LiteralImpl.h:56
armarx::VariantBasePtr
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr
Definition: ManagedIceObject.h:108
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
DataFieldIdentifier.h
armarx::ConditionHandler
Definition: ConditionHandler.h:62
TermImpl.h
armarx::DataFieldIdentifierBasePtr
IceInternal::Handle< DataFieldIdentifierBase > DataFieldIdentifierBasePtr
Definition: StatechartContextInterface.h:42
IceInternal::Handle
Definition: forward_declarations.h:8
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::LiteralImpl::output
void output(std::ostream &out) const override
output to stream.
Definition: LiteralImpl.cpp:133
armarx::operator<<
std::ostream & operator<<(std::ostream &os, const PythonApplicationManager::Paths &paths)
Definition: PythonApplicationManager.cpp:285
ImportExport.h
armarx::Literal
Definition: Term.h:208
armarx::GenericFactory
Definition: FactoryCollectionBase.h:51
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
ARMARXCORE_IMPORT_EXPORT
#define ARMARXCORE_IMPORT_EXPORT
Definition: ImportExport.h:38
armarx::LiteralImplPtr
IceInternal::Handle< LiteralImpl > LiteralImplPtr
Typedef of LiteralImplPtr as IceInternal::Handle<LiteralImpl> for convenience.
Definition: ConditionRoot.h:48
armarx::TermImpl
Definition: TermImpl.h:53
Variant.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::DataFieldIdentifier
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
Definition: DataFieldIdentifier.h:48