16 #ifndef SURGSIM_FRAMEWORK_COMPONENTMANAGER_INL_H 17 #define SURGSIM_FRAMEWORK_COMPONENTMANAGER_INL_H 31 std::vector<std::shared_ptr<T>>* container)
33 SURGSIM_ASSERT(component !=
nullptr) <<
"Trying to add a component that is null";
34 SURGSIM_ASSERT(container !=
nullptr) <<
"Trying to use a component container that is null";
35 std::shared_ptr<T> typedComponent = std::dynamic_pointer_cast<T>(component);
36 if (typedComponent !=
nullptr)
38 auto found = std::find(container->cbegin(), container->cend(), typedComponent);
39 if (found == container->cend())
42 container->push_back(typedComponent);
47 typedComponent =
nullptr;
50 return typedComponent;
55 std::vector<std::shared_ptr<T>>* container)
57 SURGSIM_ASSERT(container !=
nullptr) <<
"Trying to use a component container that is null";
59 std::shared_ptr<T> typedComponent = std::dynamic_pointer_cast<T>(component);
60 if (typedComponent !=
nullptr && container->size() != 0)
62 auto found = std::find(container->begin(), container->end(), typedComponent);
63 if (found != container->end())
65 container->erase(found);
73 << typedComponent->getName() <<
". Not found.";
80 void ComponentManager::retireComponents(
const std::vector<std::shared_ptr<T>>& container)
82 static_assert(std::is_base_of<Component, T>::value ==
true,
"Class has to be of type component");
83 for (
const auto& component : container)
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
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
#define SURGSIM_LOG_DEBUG(logger)
Logs a message to the specified logger at the DEBUG level.
Definition: LogMacros.h:76
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger for this thread.
Definition: BasicThread.h:160
#define SURGSIM_CURRENT_FUNCTION
Helper macro to determine the function name currently being compiled.
Definition: Assert.h:61
std::string getName() const
Definition: BasicThread.cpp:233
#define SURGSIM_LOG_INFO(logger)
Logs a message to the specified logger at the INFO level.
Definition: LogMacros.h:86
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