Go to the documentation of this file.
16 #ifndef SURGSIM_FRAMEWORK_COMPONENTMANAGER_H
17 #define SURGSIM_FRAMEWORK_COMPONENTMANAGER_H
23 #include <boost/thread/mutex.hpp>
82 std::shared_ptr<T>
tryAddComponent(std::shared_ptr<SurgSim::Framework::Component> component,
83 std::vector<std::shared_ptr<T>>* container);
92 std::vector<std::shared_ptr<T>>* container);
105 virtual int getType()
const = 0;
111 std::vector<std::shared_ptr<Component>>* inflightRemovals,
112 std::vector<std::shared_ptr<SceneElement>>* inflightElements);
115 std::shared_ptr<SurgSim::Framework::Logger>
getLogger()
const;
131 std::vector<std::shared_ptr<SurgSim::Framework::Behavior>>
m_behaviors;
143 virtual bool executeAdditions(
const std::shared_ptr<Component>& component) = 0;
149 virtual bool executeRemovals(
const std::shared_ptr<Component>& component) = 0;
158 void removeComponents(
const std::vector<std::shared_ptr<Component>>::const_iterator& beginIt,
159 const std::vector<std::shared_ptr<Component>>::const_iterator& endIt);
166 const std::vector<std::shared_ptr<Component>>::const_iterator& beginIt,
167 const std::vector<std::shared_ptr<Component>>::const_iterator& endIt,
168 std::vector<std::shared_ptr<Component>>* actualAdditions);
176 void wakeUpComponents(
const std::vector<std::shared_ptr<Component>>::const_iterator& beginIt,
177 const std::vector<std::shared_ptr<Component>>::const_iterator& endIt);
187 #endif // SURGSIM_FRAMEWORK_COMPONENTMANAGER_H
bool tryRemoveComponent(std::shared_ptr< SurgSim::Framework::Component > component, std::vector< std::shared_ptr< T >> *container)
Template version of the removeComponent method.
Definition: ComponentManager-inl.h:54
void doBeforeStop() override
Prepares the thread for its execution to be stopped.
Definition: ComponentManager.cpp:217
bool enqueueAddComponent(const std::shared_ptr< Component > &component)
Queues a component to be added later.
Definition: ComponentManager.cpp:43
bool enqueueRemoveComponent(const std::shared_ptr< Component > &component)
Queues a component to be removed.
Definition: ComponentManager.cpp:50
std::shared_ptr< SurgSim::Framework::Logger > getLogger() const
Returns this manager's logger.
Definition: ComponentManager.cpp:226
virtual bool executeRemovals(const std::shared_ptr< Component > &component)=0
Handle representations, override for each thread.
boost::mutex m_componentMutex
Blocks protects addition and removal queues.
Definition: ComponentManager.h:118
void addComponents(const std::vector< std::shared_ptr< Component >>::const_iterator &beginIt, const std::vector< std::shared_ptr< Component >>::const_iterator &endIt, std::vector< std::shared_ptr< Component >> *actualAdditions)
Delegates to doAddComponent and calls initialize on all the components.
Definition: ComponentManager.cpp:177
Base Component Manager class.
Definition: ComponentManager.h:49
ComponentManager(const std::string &name="Unknown Component Manager")
Definition: ComponentManager.cpp:28
Definition: CompoundShapeToGraphics.cpp:29
bool executeInitialization() override
Overridden from BasicThread, extends the initialization to contain component initialization including...
Definition: ComponentManager.cpp:100
std::vector< std::shared_ptr< Component > > m_componentRemovals
Definition: ComponentManager.h:124
std::shared_ptr< Runtime > getRuntime() const
Definition: ComponentManager.cpp:58
std::weak_ptr< Runtime > m_runtime
Definition: ComponentManager.h:179
Basic thread implementation, tries to maintain a constant rate, supplies startup an initialization,...
Definition: BasicThread.h:48
void wakeUpComponents(const std::vector< std::shared_ptr< Component >>::const_iterator &beginIt, const std::vector< std::shared_ptr< Component >>::const_iterator &endIt)
Wake all the components up, only the components that were successfully initialized get the wakeup cal...
Definition: ComponentManager.cpp:200
virtual bool executeAdditions(const std::shared_ptr< Component > &component)=0
Adds a component.
void processBehaviors(const double dt)
Processes behaviors This needs to be called inside doUpdate() function in each 'sub' manager.
Definition: ComponentManager.cpp:87
void setRuntime(std::shared_ptr< Runtime > val)
Definition: ComponentManager.cpp:38
std::shared_ptr< T > tryAddComponent(std::shared_ptr< SurgSim::Framework::Component > component, std::vector< std::shared_ptr< T >> *container)
Template version of the addComponent method.
Definition: ComponentManager-inl.h:30
virtual ~ComponentManager()
Definition: ComponentManager.cpp:33
void removeComponents(const std::vector< std::shared_ptr< Component >>::const_iterator &beginIt, const std::vector< std::shared_ptr< Component >>::const_iterator &endIt)
Delegates to doRemoveComponent to remove all the components in the indicated array.
Definition: ComponentManager.cpp:165
std::vector< std::shared_ptr< Component > > m_componentAdditions
Definition: ComponentManager.h:123
void copyScheduledComponents(std::vector< std::shared_ptr< Component >> *inflightAdditions, std::vector< std::shared_ptr< Component >> *inflightRemovals, std::vector< std::shared_ptr< SceneElement >> *inflightElements)
Helper, blocks access to the additions and removal queue and copies the components from there to the ...
Definition: ComponentManager.cpp:147
void retireComponents(const std::vector< std::shared_ptr< T >> &container)
Definition: ComponentManager-inl.h:80
virtual int getType() const =0
Returns the type of Manager.
std::vector< std::shared_ptr< SceneElement > > m_elementCache
Definition: ComponentManager.h:125
std::vector< std::shared_ptr< SurgSim::Framework::Behavior > > m_behaviors
Collection of behaviors.
Definition: ComponentManager.h:131
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
void processComponents()
Processes all the components that are scheduled for addition or removal, this needs to be called insi...
Definition: ComponentManager.cpp:63