ArmarXDummyManager.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 ArmarXCore::core
19  * @author Kai Welke (kai dot 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 
29 
30 #include <string>
31 #include <map>
32 
33 namespace armarx
34 {
35  /**
36  * ArmarXDummyManager smart pointer type
37  */
38  class ArmarXDummyManager;
40 
41  /**
42  * @class ArmarXDummyManager
43  * @brief Handles help and documentation generation but does not provide Ice functionality.
44  * @ingroup DistributedProcessingSub
45  *
46  * The ArmarXDummyManager implements the ManagedIceObjectRegistryInterface and thus provides all ManagedIceObject adding and removal
47  * functionality. In contrast to the ArmarXManager, no Ice setup is performed and the objects are not started.
48  *
49  * This manager is used in order to parse the options of all ManagedIceObject added to the ArmarXManager for the help and
50  * automatic documentation generation.
51  */
54  {
55  using ObjectList = std::map<std::string, ManagedIceObjectPtr>;
56  public:
57  /**
58  * Add a ManagedIceObject to the dummy manager. Takes care of the ManagedIceObject
59  * lifcycle using and ArmarXObjectScheduler. addObject is
60  * thread-safe and can be called from any method in order to dynamically
61  * add ManagedIceObjects (as e.g. required for GUI).
62  *
63  * @param object object to add
64  */
65  void addObject(const ManagedIceObjectPtr& object, bool addWithOwnAdapter = true, const std::string& objectName = "", bool useOwnScheduleThread = true) override
66  {
67  objects.insert(std::make_pair(object->getName(), object));
68  }
69 
70 
71  /**
72  * Removes an object from the registry.
73  *
74  * This version waits until all calls to this component are finished and
75  * the has been completely removed.
76  *
77  * @param object object to remove
78  */
79  void removeObjectBlocking(const ManagedIceObjectPtr& object) override
80  {
81  objects.erase(object->getName());
82  }
83 
84  /**
85  * Removes an object from the manageregistry.
86  *
87  * This version waits until all calls to this component are finished and
88  * the has been completely removed.
89  *
90  * @param objectName name of the object to remove
91  */
92  void removeObjectBlocking(const std::string& objectName) override
93  {
94  objects.erase(objectName);
95  }
96 
97  /**
98  * Removes an object from the registry.
99  *
100  * This version returns immediatly and does <b>not</b> wait for all call to this
101  * to finish.
102  *
103  * @param object object to remove
104  */
105  void removeObjectNonBlocking(const ManagedIceObjectPtr& object) override
106  {
107  objects.erase(object->getName());
108  }
109 
110  /**
111  * Removes an object from the registry.
112  *
113  * This version returns immediatly and does <b>not</b> wait for all call to this
114  * to finish.
115  *
116  * @param objectName name of the object to remove
117  */
118  void removeObjectNonBlocking(const std::string& objectName) override
119  {
120  objects.erase(objectName);
121  }
122 
123  /**
124  * Retrieve pointers to all ManagedIceObject.
125  *
126  * @return vector of pointers
127  */
128  std::vector<ManagedIceObjectPtr> getManagedObjects() override
129  {
130  std::vector<ManagedIceObjectPtr> result;
131 
132  ObjectList::iterator iter = objects.begin();
133 
134  while (iter != objects.end())
135  {
136  result.push_back(iter->second);
137  iter++;
138  }
139 
140  return result;
141  }
142 
143  private:
144  // list of added objects
145  ObjectList objects;
146 
147  };
148 }
149 
armarx::ArmarXDummyManager::removeObjectNonBlocking
void removeObjectNonBlocking(const std::string &objectName) override
Removes an object from the registry.
Definition: ArmarXDummyManager.h:118
armarx::ArmarXDummyManager::removeObjectBlocking
void removeObjectBlocking(const ManagedIceObjectPtr &object) override
Removes an object from the registry.
Definition: ArmarXDummyManager.h:79
IceInternal::Handle< ManagedIceObject >
ManagedIceObject.h
armarx::ArmarXDummyManager::addObject
void addObject(const ManagedIceObjectPtr &object, bool addWithOwnAdapter=true, const std::string &objectName="", bool useOwnScheduleThread=true) override
Add a ManagedIceObject to the dummy manager.
Definition: ArmarXDummyManager.h:65
armarx::ManagedIceObjectRegistryInterface
The registery interface is implemented by ArmarXManagers.
Definition: ManagedIceObjectRegistryInterface.h:48
armarx::ArmarXDummyManager::removeObjectNonBlocking
void removeObjectNonBlocking(const ManagedIceObjectPtr &object) override
Removes an object from the registry.
Definition: ArmarXDummyManager.h:105
armarx::ArmarXDummyManager::getManagedObjects
std::vector< ManagedIceObjectPtr > getManagedObjects() override
Retrieve pointers to all ManagedIceObject.
Definition: ArmarXDummyManager.h:128
armarx::ArmarXDummyManager
Handles help and documentation generation but does not provide Ice functionality.
Definition: ArmarXDummyManager.h:52
IceUtil::Handle
Definition: forward_declarations.h:29
ManagedIceObjectRegistryInterface.h
armarx::ArmarXDummyManager::removeObjectBlocking
void removeObjectBlocking(const std::string &objectName) override
Removes an object from the manageregistry.
Definition: ArmarXDummyManager.h:92
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28