ConditionRoot.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 <mutex>
29#include <string>
30
31#include <IceUtil/Handle.h>
32
34#include <ArmarXCore/interface/observers/Event.h>
35#include <ArmarXCore/interface/observers/VariantBase.h>
38
39namespace armarx
40{
41 class ConditionRoot;
42 class LiteralImpl;
43
44 /**
45 * Typedef of ConditionRootPtr as IceInternal::Handle<ConditionRoot> for convenience.
46 */
49
50 /**
51 * @class ConditionRoot
52 * @brief ConditionRoot Condition roots are top-level nodes of the expression tree.
53 * @ingroup Conditions
54 *
55 * Condition roots are the root node of expression tree. They have an event as member, which is
56 * fires once the expression described by the tree is fulfilled.
57 */
59 virtual public TermImpl,
60 virtual public ConditionRootBase
61 {
62 friend class ConditionHandler;
63 template <class BaseClass, class VariantClass>
64 friend class GenericFactory;
65
66 public:
67 /**
68 * Update state f the ConditionRoot object based on the child.
69 * Fire ConditionRoot::event if value is true.
70 * The event is only fired, if no previous event has been fired.
71 */
72 void update(const Ice::Current& c = Ice::emptyCurrent) override;
73 void updateWithData(const Ice::Current& c = Ice::emptyCurrent) override;
74
75 /**
76 * output to stream. pure virtual.
77 *
78 * @param stream
79 */
80 void output(std::ostream& out) const override;
81
82 protected:
83 /**
84 * Creates an empty ConditionRoot. Used by Ice factory.
85 */
87
88 /**
89 * Creates and initializes a ConditionRoot. Used by ConditionHandler.
90 */
91 ConditionRoot(const EventListenerInterfacePrx& listener,
92 const EventBasePtr& event,
93 const std::string& description,
94 bool onlyFireOnce,
95 const DatafieldRefList& refs);
96
97 public:
98 /**
99 * stream operator for Condition
100 */
101 friend std::ostream&
102 operator<<(std::ostream& stream, const ConditionRoot& rhs)
103 {
104 rhs.output(stream);
105
106 return stream;
107 }
108
109 /**
110 * stream operator for ConditionPtr
111 */
112 friend std::ostream&
113 operator<<(std::ostream& stream, const ConditionRootPtr& rhs)
114 {
115 rhs->output(stream);
116
117 return stream;
118 }
119
120 static std::vector<LiteralImplPtr> ExtractLiterals(const TermImplBasePtr& expression);
121
122
123 private:
124 std::mutex updateMutex;
125 DatafieldRefList refs;
126 };
127} // namespace armarx
std::ostream & operator<<(std::ostream &strm, const AbstractInterface &a)
#define ARMARXCORE_IMPORT_EXPORT
constexpr T c
ConditionRoot Condition roots are top-level nodes of the expression tree.
void update(const Ice::Current &c=Ice::emptyCurrent) override
Update state f the ConditionRoot object based on the child.
friend class GenericFactory
void updateWithData(const Ice::Current &c=Ice::emptyCurrent) override
void output(std::ostream &out) const override
output to stream.
friend class ConditionHandler
ConditionRoot()
Creates an empty ConditionRoot.
LiteralImpls are the basic elements for defining conditional expressions.
Definition LiteralImpl.h:59
TermImpl is the superclass for all implementations of terms in the expression tree,...
Definition TermImpl.h:54
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< ConditionRoot > ConditionRootPtr
Typedef of ConditionRootPtr as IceInternal::Handle<ConditionRoot> for convenience.
IceInternal::Handle< LiteralImpl > LiteralImplPtr
Typedef of LiteralImplPtr as IceInternal::Handle<LiteralImpl> for convenience.