Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::ModuleManager Class Reference

The module manager is a singleton object, so it can be instantiated only once. It contains all the active software modules which can be accessed in a centralized way. More...

#include <ModuleManager.hpp>

Inheritance diagram for Boardcore::ModuleManager:
Collaboration diagram for Boardcore::ModuleManager:

Public Member Functions

 ModuleManager ()
 
 ~ModuleManager ()
 
template<typename T >
bool insert (T *element)
 Inserts the module inside the array.
 
template<class T >
T * get ()
 Get the Module object if present.
 
- Public Member Functions inherited from Boardcore::Singleton< ModuleManager >
 Singleton (const Singleton &)=delete
 
Singletonoperator= (const Singleton &)=delete
 

Friends

class Singleton< ModuleManager >
 

Additional Inherited Members

- Static Public Member Functions inherited from Boardcore::Singleton< ModuleManager >
static ModuleManagergetInstance ()
 
- Protected Member Functions inherited from Boardcore::Singleton< ModuleManager >
 Singleton ()
 

Detailed Description

The module manager is a singleton object, so it can be instantiated only once. It contains all the active software modules which can be accessed in a centralized way.

Note
Because modules are identified by their type, only one module per type can be inserted into the module manager. This means that every module conceptually behaves like a singleton.

Example:

class SensorsModule : public Module {...};
class Sensors : public SensorsModule {...};
ModuleManager::getInstance().insert<SensorsModule>(new Sensors(args..));
// The user
ModuleManager::getInstance().get<SensorsModule>();
// This way substituting the instance below, the user doesn't actually know
// the difference as far as the upper interface is respected.
static ModuleManager & getInstance()
Definition Singleton.h:52

Definition at line 63 of file ModuleManager.hpp.

Constructor & Destructor Documentation

◆ ModuleManager()

Boardcore::ModuleManager::ModuleManager ( )
inline

Definition at line 68 of file ModuleManager.hpp.

◆ ~ModuleManager()

Boardcore::ModuleManager::~ModuleManager ( )
inline

Definition at line 70 of file ModuleManager.hpp.

Member Function Documentation

◆ get()

template<class T >
T * Boardcore::ModuleManager::get ( )
inline

Get the Module object if present.

Returns
T Software module.
nullptr in case of a non existing software module.
Note
After the get call, no further insertion is allowed.

Definition at line 137 of file ModuleManager.hpp.

◆ insert()

template<typename T >
bool Boardcore::ModuleManager::insert ( T * element)
inline

Inserts the module inside the array.

Parameters
elementModule to be added. T must be subclass of Module.
Returns
false in case an object of the same class has already been inserted or the maximum number of modules has been reached.
Note
Further insertions of modules after the first 'get()' call are not allowed. Please notice also that the module manager from this point handles completely the objects. Therefore at the destruction of the module manager, all the modules will be deleted.

Definition at line 94 of file ModuleManager.hpp.

Friends And Related Symbol Documentation

◆ Singleton< ModuleManager >

friend class Singleton< ModuleManager >
friend

Definition at line 37 of file ModuleManager.hpp.


The documentation for this class was generated from the following file: