CCSDSPack
C++ Library for CCSDS Space Packet manipulation. i.e. generation, extraction, analisys and more
|
A singleton factory class responsible for registering and creating instances of SecondaryHeaderAbstract
objects.
More...
#include <CCSDSSecondaryHeaderFactory.h>
Public Types | |
using | CreatorFunc = std::function< std::shared_ptr< SecondaryHeaderAbstract >()> |
Type alias for a function that creates an instance of SecondaryHeaderAbstract . | |
Public Member Functions | |
SecondaryHeaderFactory ()=default | |
Default constructor for the factory. | |
void | registerType (std::shared_ptr< SecondaryHeaderAbstract > header) |
Registers a new header type with its creation function. | |
std::shared_ptr< SecondaryHeaderAbstract > | create (const std::string &type) |
Creates an instance of a registered header type. | |
bool | typeIsRegistered (const std::string &type) |
Checks if a header type is registered. | |
Private Attributes | |
std::unordered_map< std::string, std::shared_ptr< SecondaryHeaderAbstract > > | m_creators |
A map of header types to their corresponding SecondaryHeaderAbstract objects. | |
A singleton factory class responsible for registering and creating instances of SecondaryHeaderAbstract
objects.
This factory allows clients to register new types of headers, check if a header type is registered, and create instances of registered header types.
Definition at line 18 of file CCSDSSecondaryHeaderFactory.h.
Type alias for a function that creates an instance of SecondaryHeaderAbstract
.
Definition at line 29 of file CCSDSSecondaryHeaderFactory.h.
|
default |
Default constructor for the factory.
|
inline |
Creates an instance of a registered header type.
This function searches for the header type by its string identifier and returns a new instance of the registered header.
type | A string representing the header type to create. |
SecondaryHeaderAbstract
object, or nullptr
if the type is not registered. Definition at line 50 of file CCSDSSecondaryHeaderFactory.h.
|
inline |
Registers a new header type with its creation function.
This function adds a new header type to the factory by associating the header's type string with a shared pointer to the header.
header | A shared pointer to a SecondaryHeaderAbstract object to register. |
Definition at line 38 of file CCSDSSecondaryHeaderFactory.h.
|
inline |
Checks if a header type is registered.
This function checks if a given header type is already registered with the factory.
type | A string representing the header type to check. |
true
if the type is registered, false
otherwise. Definition at line 65 of file CCSDSSecondaryHeaderFactory.h.
|
private |
A map of header types to their corresponding SecondaryHeaderAbstract
objects.
This private member stores the registered header types along with their corresponding shared pointers.
Definition at line 78 of file CCSDSSecondaryHeaderFactory.h.