ConditionHandler.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 2011
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24 
25 #pragma once
26 
29 
31 #include <ArmarXCore/interface/observers/ObserverInterface.h>
32 #include <ArmarXCore/interface/observers/ConditionHandlerInterface.h>
34 
35 #include <vector>
36 #include <string>
37 #include <mutex>
38 
39 
40 namespace armarx
41 {
48  {
49  public:
51  };
52 
66  virtual public ConditionHandlerInterface,
67  virtual public Component
68  {
69  public:
81  ConditionIdentifier installCondition(const EventListenerInterfacePrx& listener, const TermImplBasePtr& expression, const EventBasePtr& e, bool onlyFireOnce, bool reportDatafields, const DatafieldRefList& refs, const Ice::Current& c = Ice::emptyCurrent) override;
82 
95  ConditionIdentifier installConditionWithDescription(const EventListenerInterfacePrx& listener, const TermImplBasePtr& expression, const EventBasePtr& e, const std::string& desc, bool onlyFireOnce, bool reportDatafields, const DatafieldRefList& refs, const Ice::Current& c = Ice::emptyCurrent) override;
96 
102  void removeCondition(const ConditionIdentifier& id, const Ice::Current& c = Ice::emptyCurrent) override;
103 
108  void removeAllConditions(const Ice::Current& c = Ice::emptyCurrent) override;
109 
115  Ice::StringSeq getObserverNames(const Ice::Current& c = Ice::emptyCurrent) override;
116 
122  ConditionRegistry getActiveConditions(const Ice::Current& c = Ice::emptyCurrent) override;
123 
130  ConditionRegistry getPastConditions(const Ice::Current& c = Ice::emptyCurrent) override;
131 
132  ConditionRootBasePtr getCondition(Ice::Int id, const Ice::Current& c = Ice::emptyCurrent) override;
133 
134  std::string getDefaultName() const override;
135 
136  protected:
140  virtual void onInitConditionHandler() { }
141 
145  virtual void onStartConditionHandler() { }
146 
150  PropertyDefinitionsPtr createPropertyDefinitions() override;
151 
152  // inherited from Component
153  void onInitComponent() override;
154  void onConnectComponent() override;
155 
156  private:
157  // active checks and associated events
158  std::mutex idMutex;
159  std::mutex iceManagerMutex;
160  std::mutex conditionRegistryMutex;
161  ConditionRegistry conditionRegistry;
162  std::mutex conditionHistoryMutex;
163  ConditionRegistry conditionHistory;
164  int historyLength;
165 
166  // utility methods for observers
167  void useObservers(std::vector<std::string>& names);
168  void preCacheObservers(std::vector<std::string>& names);
169  ObserverInterfacePrx getObserver(std::string observerName);
170 
171  // utility methods for check handling
172  void installChecks(std::vector<LiteralImplPtr>& literals, const Ice::Current& c);
173  void removeChecks(std::vector<LiteralImplPtr>& literals, const Ice::Current& c);
174 
175  Ice::StringSeq observerNames;
176 
177  int generateId();
178  int currentId;
179  };
180 }
181 
LiteralImpl.h
Properties.h
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::ConditionHandler
Definition: ConditionHandler.h:65
armarx::ConditionHandler::onStartConditionHandler
virtual void onStartConditionHandler()
Framework hook.
Definition: ConditionHandler.h:145
armarx::ConditionHandlerPropertyDefinitions::ConditionHandlerPropertyDefinitions
ConditionHandlerPropertyDefinitions(std::string prefix)
Definition: ConditionHandler.cpp:36
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
armarx::viz::data::ElementFlags::names
const simox::meta::IntEnumNames names
Definition: json_elements.cpp:14
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
ImportExport.h
ARMARXCORE_IMPORT_EXPORT
#define ARMARXCORE_IMPORT_EXPORT
Definition: ImportExport.h:38
armarx::ConditionHandler::onInitConditionHandler
virtual void onInitConditionHandler()
Framework hook.
Definition: ConditionHandler.h:140
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::ConditionHandlerPropertyDefinitions
Definition: ConditionHandler.h:46