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 
27 #include <map>
28 #include <string>
29 
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  */
53  {
54  using ObjectList = std::map<std::string, ManagedIceObjectPtr>;
55 
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
67  bool addWithOwnAdapter = true,
68  const std::string& objectName = "",
69  bool useOwnScheduleThread = true) override
70  {
71  objects.insert(std::make_pair(object->getName(), object));
72  }
73 
74  /**
75  * Removes an object from the registry.
76  *
77  * This version waits until all calls to this component are finished and
78  * the has been completely removed.
79  *
80  * @param object object to remove
81  */
82  void
83  removeObjectBlocking(const ManagedIceObjectPtr& object) override
84  {
85  objects.erase(object->getName());
86  }
87 
88  /**
89  * Removes an object from the manageregistry.
90  *
91  * This version waits until all calls to this component are finished and
92  * the has been completely removed.
93  *
94  * @param objectName name of the object to remove
95  */
96  void
97  removeObjectBlocking(const std::string& objectName) override
98  {
99  objects.erase(objectName);
100  }
101 
102  /**
103  * Removes an object from the registry.
104  *
105  * This version returns immediatly and does <b>not</b> wait for all call to this
106  * to finish.
107  *
108  * @param object object to remove
109  */
110  void
112  {
113  objects.erase(object->getName());
114  }
115 
116  /**
117  * Removes an object from the registry.
118  *
119  * This version returns immediatly and does <b>not</b> wait for all call to this
120  * to finish.
121  *
122  * @param objectName name of the object to remove
123  */
124  void
125  removeObjectNonBlocking(const std::string& objectName) override
126  {
127  objects.erase(objectName);
128  }
129 
130  /**
131  * Retrieve pointers to all ManagedIceObject.
132  *
133  * @return vector of pointers
134  */
135  std::vector<ManagedIceObjectPtr>
136  getManagedObjects() override
137  {
138  std::vector<ManagedIceObjectPtr> result;
139 
140  ObjectList::iterator iter = objects.begin();
141 
142  while (iter != objects.end())
143  {
144  result.push_back(iter->second);
145  iter++;
146  }
147 
148  return result;
149  }
150 
151  private:
152  // list of added objects
153  ObjectList objects;
154  };
155 } // namespace armarx
armarx::ArmarXDummyManager::removeObjectNonBlocking
void removeObjectNonBlocking(const std::string &objectName) override
Removes an object from the registry.
Definition: ArmarXDummyManager.h:125
armarx::ArmarXDummyManager::removeObjectBlocking
void removeObjectBlocking(const ManagedIceObjectPtr &object) override
Removes an object from the registry.
Definition: ArmarXDummyManager.h:83
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:66
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:111
armarx::ArmarXDummyManager::getManagedObjects
std::vector< ManagedIceObjectPtr > getManagedObjects() override
Retrieve pointers to all ManagedIceObject.
Definition: ArmarXDummyManager.h:136
armarx::ArmarXDummyManager
Handles help and documentation generation but does not provide Ice functionality.
Definition: ArmarXDummyManager.h:52
IceUtil::Handle
Definition: forward_declarations.h:30
ManagedIceObjectRegistryInterface.h
armarx::ArmarXDummyManager::removeObjectBlocking
void removeObjectBlocking(const std::string &objectName) override
Removes an object from the manageregistry.
Definition: ArmarXDummyManager.h:97
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27