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 " already added to " <<
getName();
48 typedComponent =
nullptr;
51 return typedComponent;
56 std::vector<std::shared_ptr<T>>* container)
58 SURGSIM_ASSERT(container !=
nullptr) <<
"Trying to use a component container that is null";
60 std::shared_ptr<T> typedComponent = std::dynamic_pointer_cast<T>(component);
61 if (typedComponent !=
nullptr && container->size() != 0)
63 auto found = std::find(container->begin(), container->end(), typedComponent);
64 if (found != container->end())
66 container->erase(found);
73 typedComponent->getName() <<
". Not found.";
Definition: DriveElementFromInputBehavior.cpp:27
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:55
#define SURGSIM_LOG_DEBUG(logger)
Logs a message to the specified logger at the DEBUG level.
Definition: LogMacros.h:76
std::string getName() const
Definition: BasicThread.cpp:186
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
#define SURGSIM_CURRENT_FUNCTION
Helper macro to determine the function name currently being compiled.
Definition: Assert.h:61
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger for this class.
Definition: ComponentManager.h:126
#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