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 
28 
29 #include <ArmarXCore/interface/observers/VariantBase.h>
30 #include <ArmarXCore/interface/observers/ObserverInterface.h>
31 
35 
36 #include <IceUtil/Handle.h>
37 
38 #include <memory>
39 #include <string>
40 
41 
42 namespace armarx
43 {
44  class LiteralImpl;
45 
46  /**
47  * Typedef of LiteralImplPtr as IceInternal::Handle<LiteralImpl> for convenience.
48  */
50 
51  /**
52  * @class LiteralImpl
53  * @brief LiteralImpls are the basic elements for defining conditional expressions.
54  * @ingroup Conditions
55  *
56  * LiteralImpl are leaves in the expression tree. Each LiteralImpl is associated to a ConditionCheck. The state of
57  * the LiteralImpl corresponds to the state of the ConditionCheck.
58  */
60  virtual public LiteralImplBase,
61  virtual public TermImpl
62  {
63  friend class ConditionHandler;
64  friend class Literal;
65  template <class BaseClass, class VariantClass>
66  friend class GenericFactory;
67 
68  protected:
69  /**
70  * Creates an empty LiteralImpl. Required for Ice ObjectFactory
71  */
72  LiteralImpl();
73 
74  ~LiteralImpl();
75 
76  /**
77  * Creates a LiteralImpl using string as dataFieldIdentifier with multiple parameter. See also createParameterList().
78  *
79  * @param dataFieldIdentifierStr identifier of the datafield used by the condition in the form "observerName.channelName.datafieldName"
80  * @param checkName name of the condition check
81  * @param checkParameter parameter for the condition check
82  */
83  LiteralImpl(const std::string& dataFieldIdentifierStr, const std::string& checkName, const ParameterList& checkParameters);
84 
85  /**
86  * Creates a LiteralImpl using the DataFieldIdentifier type with multiple parameter. See also createParameterList()
87  *
88  * @param dataFieldIdentifier identifier of the datafield used by the condition
89  * @param checkName name of the condition check
90  * @param checkParameters list of check parameters
91  */
92  LiteralImpl(const DataFieldIdentifier& dataFieldIdentifier, const std::string& checkName, const ParameterList& checkParameters);
93 
94  /**
95  * Creates a LiteralImpl using the DataFieldIdentifier type with multiple parameter. See also createParameterList()
96  *
97  * @param dataFieldIdentifier pointer to identifier of the datafield used by the condition
98  * @param checkName name of the condition check
99  * @param checkParameters list of check parameters
100  */
101  LiteralImpl(const DataFieldIdentifierPtr& dataFieldIdentifier, const std::string& checkName, const ParameterList& checkParameters);
102 
103  LiteralImpl(const DatafieldRefBasePtr& dataFieldIdentifier, const std::string& checkName, const ParameterList& checkParameters);
104 
105  void createInstance();
106  public:
107  /**
108  * Retrieve check configuration. Inherited from LiteralImplBase
109  *
110  * @return configuration of check
111  */
112  CheckConfiguration getCheckConfiguration(const Ice::Current& c = Ice::emptyCurrent) override;
113 
114  /**
115  * Set value of LiteralImpl
116  *
117  * @param value of LiteralImpl
118  */
119  void setValue(bool value, const Ice::Current& c = Ice::emptyCurrent) override;
120  void setValueAndData(bool value, const ::armarx::DataFieldIdentifierBasePtr& id, const ::armarx::VariantBasePtr& data, const Ice::Current& c = Ice::emptyCurrent) override;
121 
122  /**
123  * Reimplementation of the ice_clone method.
124  *
125  * @return clone of the object
126  */
127  Ice::ObjectPtr ice_clone() const override;
128 
129  /**
130  * output to stream. pure virtual.
131  *
132  * @param stream
133  */
134  void output(std::ostream& out) const override;
135 
136 
137  /**
138  * stream operator for LiteralImpl
139  */
140  friend std::ostream& operator<<(std::ostream& stream, const LiteralImpl& rhs)
141  {
142  rhs.output(stream);
143 
144  return stream;
145  }
146 
147  /**
148  * stream operator for LiteralImplPtr
149  */
150  friend std::ostream& operator<<(std::ostream& stream, const LiteralImplPtr& rhs)
151  {
152  rhs->output(stream);
153 
154  return stream;
155  }
156  protected:
157  void init(const std::string& dataFieldIdentifierStr, const std::string& checkName, const ParameterList& checkParameters);
158  private:
159  void installCheck(const Ice::ObjectAdapterPtr& adapter, const ObserverInterfacePrx& proxy);
160  void removeCheck(const Ice::ObjectAdapterPtr& adapter, const ObserverInterfacePrx& proxy);
161 
162  struct Impl;
163  std::unique_ptr<Impl> impl;
164  };
165 }
166 extern template class ::IceInternal::Handle<::armarx::LiteralImpl>;
armarx::LiteralImpl
LiteralImpls are the basic elements for defining conditional expressions.
Definition: LiteralImpl.h:59
armarx::VariantBasePtr
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr
Definition: ManagedIceObject.h:109
armarx::LiteralImpl::operator<<
friend std::ostream & operator<<(std::ostream &stream, const LiteralImplPtr &rhs)
stream operator for LiteralImplPtr
Definition: LiteralImpl.h:150
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
DataFieldIdentifier.h
armarx::ConditionHandler
Definition: ConditionHandler.h:65
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:926
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:119
armarx::LiteralImpl::operator<<
friend std::ostream & operator<<(std::ostream &stream, const LiteralImpl &rhs)
stream operator for LiteralImpl
Definition: LiteralImpl.h:140
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:50
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:28
armarx::DataFieldIdentifier
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
Definition: DataFieldIdentifier.h:48