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
39namespace armarx
40{
41 class LiteralImpl;
42
43 /**
44 * Typedef of LiteralImplPtr as IceInternal::Handle<LiteralImpl> for convenience.
45 */
46 using LiteralImplPtr = IceInternal::Handle<LiteralImpl>;
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 */
70
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,
128 const ::armarx::DataFieldIdentifierBasePtr& id,
129 const ::armarx::VariantBasePtr& data,
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
181extern template class ::IceInternal::Handle<::armarx::LiteralImpl>;
std::ostream & operator<<(std::ostream &strm, const AbstractInterface &a)
#define ARMARXCORE_IMPORT_EXPORT
constexpr T c
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
LiteralImpls are the basic elements for defining conditional expressions.
Definition LiteralImpl.h:59
friend class GenericFactory
Definition LiteralImpl.h:63
void output(std::ostream &out) const override
output to stream.
CheckConfiguration getCheckConfiguration(const Ice::Current &c=Ice::emptyCurrent) override
Retrieve check configuration.
friend class Literal
Definition LiteralImpl.h:61
LiteralImpl()
Creates an empty LiteralImpl.
Ice::ObjectPtr ice_clone() const override
Reimplementation of the ice_clone method.
void setValueAndData(bool value, const ::armarx::DataFieldIdentifierBasePtr &id, const ::armarx::VariantBasePtr &data, const Ice::Current &c=Ice::emptyCurrent) override
friend class ConditionHandler
Definition LiteralImpl.h:60
void setValue(bool value, const Ice::Current &c=Ice::emptyCurrent) override
Set value of LiteralImpl.
TermImpl is the superclass for all implementations of terms in the expression tree,...
Definition TermImpl.h:54
::IceInternal::Handle<::Ice::ObjectAdapter > ObjectAdapterPtr
Definition IceManager.h:52
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< DataFieldIdentifier > DataFieldIdentifierPtr
Typedef of DataFieldIdentifierPtr as IceInternal::Handle<DataFieldIdentifier> for convenience.
IceInternal::Handle< LiteralImpl > LiteralImplPtr
Typedef of LiteralImplPtr as IceInternal::Handle<LiteralImpl> for convenience.