reapply clang format
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
@ -9,137 +10,133 @@
|
||||
ObjectManager* ObjectManager::objManagerInstance = nullptr;
|
||||
|
||||
ObjectManager* ObjectManager::instance() {
|
||||
if(objManagerInstance == nullptr) {
|
||||
objManagerInstance = new ObjectManager();
|
||||
}
|
||||
return objManagerInstance;
|
||||
if (objManagerInstance == nullptr) {
|
||||
objManagerInstance = new ObjectManager();
|
||||
}
|
||||
return objManagerInstance;
|
||||
}
|
||||
|
||||
void ObjectManager::setObjectFactoryFunction(produce_function_t objFactoryFunc, void *factoryArgs) {
|
||||
this->objectFactoryFunction = objFactoryFunc;
|
||||
this->factoryArgs = factoryArgs;
|
||||
void ObjectManager::setObjectFactoryFunction(produce_function_t objFactoryFunc, void* factoryArgs) {
|
||||
this->objectFactoryFunction = objFactoryFunc;
|
||||
this->factoryArgs = factoryArgs;
|
||||
}
|
||||
|
||||
|
||||
ObjectManager::ObjectManager() {}
|
||||
|
||||
|
||||
ObjectManager::~ObjectManager() {
|
||||
for (auto const& iter : objectList) {
|
||||
delete iter.second;
|
||||
}
|
||||
for (auto const& iter : objectList) {
|
||||
delete iter.second;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) {
|
||||
auto returnPair = objectList.emplace(id, object);
|
||||
if (returnPair.second) {
|
||||
ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) {
|
||||
auto returnPair = objectList.emplace(id, object);
|
||||
if (returnPair.second) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// sif::debug << "ObjectManager::insert: Object " << std::hex
|
||||
// << (int)id << std::dec << " inserted." << std::endl;
|
||||
// sif::debug << "ObjectManager::insert: Object " << std::hex
|
||||
// << (int)id << std::dec << " inserted." << std::endl;
|
||||
#endif
|
||||
return this->RETURN_OK;
|
||||
} else {
|
||||
return this->RETURN_OK;
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::insert: Object ID " << std::hex <<
|
||||
static_cast<uint32_t>(id) << std::dec << " is already in use!" << std::endl;
|
||||
sif::error << "Terminating program" << std::endl;
|
||||
sif::error << "ObjectManager::insert: Object ID " << std::hex << static_cast<uint32_t>(id)
|
||||
<< std::dec << " is already in use!" << std::endl;
|
||||
sif::error << "Terminating program" << std::endl;
|
||||
#else
|
||||
sif::printError("ObjectManager::insert: Object ID 0x%08x is already in use!\n",
|
||||
static_cast<unsigned int>(id));
|
||||
sif::printError("Terminating program");
|
||||
sif::printError("ObjectManager::insert: Object ID 0x%08x is already in use!\n",
|
||||
static_cast<unsigned int>(id));
|
||||
sif::printError("Terminating program");
|
||||
#endif
|
||||
//This is very severe and difficult to handle in other places.
|
||||
std::exit(INSERTION_FAILED);
|
||||
}
|
||||
// This is very severe and difficult to handle in other places.
|
||||
std::exit(INSERTION_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t ObjectManager::remove( object_id_t id ) {
|
||||
if ( this->getSystemObject(id) != NULL ) {
|
||||
this->objectList.erase( id );
|
||||
ReturnValue_t ObjectManager::remove(object_id_t id) {
|
||||
if (this->getSystemObject(id) != NULL) {
|
||||
this->objectList.erase(id);
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
//sif::debug << "ObjectManager::removeObject: Object " << std::hex
|
||||
// << (int)id << std::dec << " removed." << std::endl;
|
||||
// sif::debug << "ObjectManager::removeObject: Object " << std::hex
|
||||
// << (int)id << std::dec << " removed." << std::endl;
|
||||
#endif
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::removeObject: Requested object "
|
||||
<< std::hex << (int)id << std::dec << " not found." << std::endl;
|
||||
sif::error << "ObjectManager::removeObject: Requested object " << std::hex << (int)id
|
||||
<< std::dec << " not found." << std::endl;
|
||||
#endif
|
||||
return NOT_FOUND;
|
||||
}
|
||||
return NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
SystemObjectIF* ObjectManager::getSystemObject( object_id_t id ) {
|
||||
auto listIter = this->objectList.find( id );
|
||||
if (listIter == this->objectList.end() ) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return listIter->second;
|
||||
}
|
||||
SystemObjectIF* ObjectManager::getSystemObject(object_id_t id) {
|
||||
auto listIter = this->objectList.find(id);
|
||||
if (listIter == this->objectList.end()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return listIter->second;
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectManager::initialize() {
|
||||
if(objectFactoryFunction == nullptr) {
|
||||
if (objectFactoryFunction == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::initialize: Passed produceObjects "
|
||||
"functions is nullptr!" << std::endl;
|
||||
sif::error << "ObjectManager::initialize: Passed produceObjects "
|
||||
"functions is nullptr!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printError("ObjectManager::initialize: Passed produceObjects functions is nullptr!\n");
|
||||
sif::printError("ObjectManager::initialize: Passed produceObjects functions is nullptr!\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
objectFactoryFunction(factoryArgs);
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
uint32_t errorCount = 0;
|
||||
for (auto const& it : objectList) {
|
||||
result = it.second->initialize();
|
||||
if ( result != RETURN_OK ) {
|
||||
return;
|
||||
}
|
||||
objectFactoryFunction(factoryArgs);
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
uint32_t errorCount = 0;
|
||||
for (auto const& it : objectList) {
|
||||
result = it.second->initialize();
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
object_id_t var = it.first;
|
||||
sif::error << "ObjectManager::initialize: Object 0x" << std::hex <<
|
||||
std::setw(8) << std::setfill('0')<< var << " failed to "
|
||||
"initialize with code 0x" << result << std::dec <<
|
||||
std::setfill(' ') << std::endl;
|
||||
object_id_t var = it.first;
|
||||
sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8)
|
||||
<< std::setfill('0') << var
|
||||
<< " failed to "
|
||||
"initialize with code 0x"
|
||||
<< result << std::dec << std::setfill(' ') << std::endl;
|
||||
#endif
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
if (errorCount > 0) {
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
if (errorCount > 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::ObjectManager: Counted " << errorCount
|
||||
<< " failed initializations." << std::endl;
|
||||
sif::error << "ObjectManager::ObjectManager: Counted " << errorCount
|
||||
<< " failed initializations." << std::endl;
|
||||
#endif
|
||||
}
|
||||
//Init was successful. Now check successful interconnections.
|
||||
errorCount = 0;
|
||||
for (auto const& it : objectList) {
|
||||
result = it.second->checkObjectConnections();
|
||||
if ( result != RETURN_OK ) {
|
||||
}
|
||||
// Init was successful. Now check successful interconnections.
|
||||
errorCount = 0;
|
||||
for (auto const& it : objectList) {
|
||||
result = it.second->checkObjectConnections();
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::ObjectManager: Object 0x" << std::hex <<
|
||||
(int) it.first << " connection check failed with code 0x" << result <<
|
||||
std::dec << std::endl;
|
||||
sif::error << "ObjectManager::ObjectManager: Object 0x" << std::hex << (int)it.first
|
||||
<< " connection check failed with code 0x" << result << std::dec << std::endl;
|
||||
#endif
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
if (errorCount > 0) {
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
if (errorCount > 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::ObjectManager: Counted " << errorCount
|
||||
<< " failed connection checks." << std::endl;
|
||||
sif::error << "ObjectManager::ObjectManager: Counted " << errorCount
|
||||
<< " failed connection checks." << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectManager::printList() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "ObjectManager: Object List contains:" << std::endl;
|
||||
for (auto const& it : objectList) {
|
||||
sif::debug << std::hex << it.first << " | " << it.second << std::endl;
|
||||
|
||||
}
|
||||
sif::debug << "ObjectManager: Object List contains:" << std::endl;
|
||||
for (auto const& it : objectList) {
|
||||
sif::debug << std::hex << it.first << " | " << it.second << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef FSFW_OBJECTMANAGER_OBJECTMANAGER_H_
|
||||
#define FSFW_OBJECTMANAGER_OBJECTMANAGER_H_
|
||||
|
||||
#include "ObjectManagerIF.h"
|
||||
#include "SystemObjectIF.h"
|
||||
#include <map>
|
||||
|
||||
#include "ObjectManagerIF.h"
|
||||
#include "SystemObjectIF.h"
|
||||
|
||||
/**
|
||||
* @brief This class implements a global object manager.
|
||||
@ -20,59 +20,59 @@
|
||||
* @author Bastian Baetz
|
||||
*/
|
||||
class ObjectManager : public ObjectManagerIF {
|
||||
public:
|
||||
public:
|
||||
using produce_function_t = void (*)(void* args);
|
||||
|
||||
using produce_function_t = void (*) (void* args);
|
||||
/**
|
||||
* Returns the single instance of TaskFactory.
|
||||
* The implementation of #instance is found in its subclasses.
|
||||
* Thus, we choose link-time variability of the instance.
|
||||
*/
|
||||
static ObjectManager* instance();
|
||||
|
||||
/**
|
||||
* Returns the single instance of TaskFactory.
|
||||
* The implementation of #instance is found in its subclasses.
|
||||
* Thus, we choose link-time variability of the instance.
|
||||
*/
|
||||
static ObjectManager* instance();
|
||||
void setObjectFactoryFunction(produce_function_t prodFunc, void* args);
|
||||
|
||||
void setObjectFactoryFunction(produce_function_t prodFunc, void* args);
|
||||
template <typename T>
|
||||
T* get(object_id_t id);
|
||||
|
||||
template <typename T> T* get( object_id_t id );
|
||||
/**
|
||||
* @brief In the class's destructor, all objects in the list are deleted.
|
||||
*/
|
||||
virtual ~ObjectManager();
|
||||
ReturnValue_t insert(object_id_t id, SystemObjectIF* object) override;
|
||||
ReturnValue_t remove(object_id_t id) override;
|
||||
void initialize() override;
|
||||
void printList() override;
|
||||
|
||||
/**
|
||||
* @brief In the class's destructor, all objects in the list are deleted.
|
||||
*/
|
||||
virtual ~ObjectManager();
|
||||
ReturnValue_t insert(object_id_t id, SystemObjectIF* object) override;
|
||||
ReturnValue_t remove(object_id_t id) override;
|
||||
void initialize() override;
|
||||
void printList() override;
|
||||
protected:
|
||||
SystemObjectIF* getSystemObject(object_id_t id) override;
|
||||
/**
|
||||
* @brief This attribute is initialized with the factory function
|
||||
* that creates new objects.
|
||||
* @details The function is called if an object was requested with
|
||||
* getSystemObject, but not found in objectList.
|
||||
* @param The id of the object to be created.
|
||||
* @return Returns a pointer to the newly created object or NULL.
|
||||
*/
|
||||
produce_function_t objectFactoryFunction = nullptr;
|
||||
void* factoryArgs = nullptr;
|
||||
|
||||
protected:
|
||||
SystemObjectIF* getSystemObject(object_id_t id) override;
|
||||
/**
|
||||
* @brief This attribute is initialized with the factory function
|
||||
* that creates new objects.
|
||||
* @details The function is called if an object was requested with
|
||||
* getSystemObject, but not found in objectList.
|
||||
* @param The id of the object to be created.
|
||||
* @return Returns a pointer to the newly created object or NULL.
|
||||
*/
|
||||
produce_function_t objectFactoryFunction = nullptr;
|
||||
void* factoryArgs = nullptr;
|
||||
private:
|
||||
ObjectManager();
|
||||
|
||||
private:
|
||||
ObjectManager();
|
||||
|
||||
/**
|
||||
* @brief This is the map of all initialized objects in the manager.
|
||||
* @details Objects in the List must inherit the SystemObjectIF.
|
||||
*/
|
||||
std::map<object_id_t, SystemObjectIF*> objectList;
|
||||
static ObjectManager* objManagerInstance;
|
||||
/**
|
||||
* @brief This is the map of all initialized objects in the manager.
|
||||
* @details Objects in the List must inherit the SystemObjectIF.
|
||||
*/
|
||||
std::map<object_id_t, SystemObjectIF*> objectList;
|
||||
static ObjectManager* objManagerInstance;
|
||||
};
|
||||
|
||||
// Documentation can be found in the class method declaration above
|
||||
template <typename T>
|
||||
T* ObjectManager::get( object_id_t id ) {
|
||||
SystemObjectIF* temp = this->getSystemObject(id);
|
||||
return dynamic_cast<T*>(temp);
|
||||
T* ObjectManager::get(object_id_t id) {
|
||||
SystemObjectIF* temp = this->getSystemObject(id);
|
||||
return dynamic_cast<T*>(temp);
|
||||
}
|
||||
|
||||
#endif /* FSFW_OBJECTMANAGER_OBJECTMANAGER_H_ */
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_
|
||||
#define FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_
|
||||
|
||||
#include "frameworkObjects.h"
|
||||
#include "SystemObjectIF.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "SystemObjectIF.h"
|
||||
#include "frameworkObjects.h"
|
||||
|
||||
/**
|
||||
* @brief This class provides an interface to the global object manager.
|
||||
@ -17,52 +17,53 @@
|
||||
* @ingroup system_objects
|
||||
*/
|
||||
class ObjectManagerIF : public HasReturnvaluesIF {
|
||||
public:
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::OBJECT_MANAGER_IF;
|
||||
static constexpr ReturnValue_t INSERTION_FAILED = MAKE_RETURN_CODE( 1 );
|
||||
static constexpr ReturnValue_t NOT_FOUND = MAKE_RETURN_CODE( 2 );
|
||||
//!< Can be used if the initialization of a SystemObject failed.
|
||||
static constexpr ReturnValue_t CHILD_INIT_FAILED = MAKE_RETURN_CODE( 3 );
|
||||
static constexpr ReturnValue_t INTERNAL_ERR_REPORTER_UNINIT = MAKE_RETURN_CODE( 4 );
|
||||
public:
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::OBJECT_MANAGER_IF;
|
||||
static constexpr ReturnValue_t INSERTION_FAILED = MAKE_RETURN_CODE(1);
|
||||
static constexpr ReturnValue_t NOT_FOUND = MAKE_RETURN_CODE(2);
|
||||
//!< Can be used if the initialization of a SystemObject failed.
|
||||
static constexpr ReturnValue_t CHILD_INIT_FAILED = MAKE_RETURN_CODE(3);
|
||||
static constexpr ReturnValue_t INTERNAL_ERR_REPORTER_UNINIT = MAKE_RETURN_CODE(4);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief This method is used to hide the template-based get call from
|
||||
* a specific implementation.
|
||||
* @details So, an implementation only has to implement this call.
|
||||
* @param id The object id of the requested object.
|
||||
* @return The method returns a pointer to an object implementing (at
|
||||
* least) the SystemObjectIF, or NULL.
|
||||
*/
|
||||
virtual SystemObjectIF* getSystemObject( object_id_t id ) = 0;
|
||||
public:
|
||||
/**
|
||||
* @brief This is the empty virtual destructor as requested by C++ interfaces.
|
||||
*/
|
||||
virtual ~ObjectManagerIF( void ) {};
|
||||
/**
|
||||
* @brief With this call, new objects are inserted to the list.
|
||||
* @details The implementation shall return an error code in case the
|
||||
* object can't be added (e.g. the id is already in use).
|
||||
* @param id The new id to be added to the list.
|
||||
* @param object A pointer to the object to be added.
|
||||
* @return @li INSERTION_FAILED in case the object could not be inserted.
|
||||
* @li RETURN_OK in case the object was successfully inserted
|
||||
*/
|
||||
virtual ReturnValue_t insert( object_id_t id, SystemObjectIF* object ) = 0;
|
||||
/**
|
||||
* @brief With this call, an object is removed from the list.
|
||||
* @param id The object id of the object to be removed.
|
||||
* @return @li NOT_FOUND in case the object was not found
|
||||
* @li RETURN_OK in case the object was successfully removed
|
||||
*/
|
||||
virtual ReturnValue_t remove( object_id_t id ) = 0;
|
||||
virtual void initialize() = 0;
|
||||
/**
|
||||
* @brief This is a debug function, that prints the current content of the
|
||||
* object list.
|
||||
*/
|
||||
virtual void printList() = 0;
|
||||
protected:
|
||||
/**
|
||||
* @brief This method is used to hide the template-based get call from
|
||||
* a specific implementation.
|
||||
* @details So, an implementation only has to implement this call.
|
||||
* @param id The object id of the requested object.
|
||||
* @return The method returns a pointer to an object implementing (at
|
||||
* least) the SystemObjectIF, or NULL.
|
||||
*/
|
||||
virtual SystemObjectIF* getSystemObject(object_id_t id) = 0;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief This is the empty virtual destructor as requested by C++ interfaces.
|
||||
*/
|
||||
virtual ~ObjectManagerIF(void){};
|
||||
/**
|
||||
* @brief With this call, new objects are inserted to the list.
|
||||
* @details The implementation shall return an error code in case the
|
||||
* object can't be added (e.g. the id is already in use).
|
||||
* @param id The new id to be added to the list.
|
||||
* @param object A pointer to the object to be added.
|
||||
* @return @li INSERTION_FAILED in case the object could not be inserted.
|
||||
* @li RETURN_OK in case the object was successfully inserted
|
||||
*/
|
||||
virtual ReturnValue_t insert(object_id_t id, SystemObjectIF* object) = 0;
|
||||
/**
|
||||
* @brief With this call, an object is removed from the list.
|
||||
* @param id The object id of the object to be removed.
|
||||
* @return @li NOT_FOUND in case the object was not found
|
||||
* @li RETURN_OK in case the object was successfully removed
|
||||
*/
|
||||
virtual ReturnValue_t remove(object_id_t id) = 0;
|
||||
virtual void initialize() = 0;
|
||||
/**
|
||||
* @brief This is a debug function, that prints the current content of the
|
||||
* object list.
|
||||
*/
|
||||
virtual void printList() = 0;
|
||||
};
|
||||
|
||||
#endif /* OBJECTMANAGERIF_H_ */
|
||||
|
@ -1,37 +1,31 @@
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/events/EventManagerIF.h"
|
||||
|
||||
SystemObject::SystemObject(object_id_t setObjectId, bool doRegister) :
|
||||
objectId(setObjectId), registered(doRegister) {
|
||||
if (registered) {
|
||||
ObjectManager::instance()->insert(objectId, this);
|
||||
}
|
||||
#include "fsfw/events/EventManagerIF.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
|
||||
SystemObject::SystemObject(object_id_t setObjectId, bool doRegister)
|
||||
: objectId(setObjectId), registered(doRegister) {
|
||||
if (registered) {
|
||||
ObjectManager::instance()->insert(objectId, this);
|
||||
}
|
||||
}
|
||||
|
||||
SystemObject::~SystemObject() {
|
||||
if (registered) {
|
||||
ObjectManager::instance()->remove(objectId);
|
||||
}
|
||||
if (registered) {
|
||||
ObjectManager::instance()->remove(objectId);
|
||||
}
|
||||
}
|
||||
|
||||
object_id_t SystemObject::getObjectId() const {
|
||||
return objectId;
|
||||
object_id_t SystemObject::getObjectId() const { return objectId; }
|
||||
|
||||
void SystemObject::triggerEvent(Event event, uint32_t parameter1, uint32_t parameter2) {
|
||||
EventManagerIF::triggerEvent(objectId, event, parameter1, parameter2);
|
||||
}
|
||||
|
||||
void SystemObject::triggerEvent(Event event, uint32_t parameter1,
|
||||
uint32_t parameter2) {
|
||||
EventManagerIF::triggerEvent(objectId, event, parameter1, parameter2);
|
||||
}
|
||||
ReturnValue_t SystemObject::initialize() { return HasReturnvaluesIF::RETURN_OK; }
|
||||
|
||||
ReturnValue_t SystemObject::initialize() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t SystemObject::checkObjectConnections() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
ReturnValue_t SystemObject::checkObjectConnections() { return HasReturnvaluesIF::RETURN_OK; }
|
||||
|
||||
void SystemObject::forwardEvent(Event event, uint32_t parameter1, uint32_t parameter2) const {
|
||||
EventManagerIF::triggerEvent(objectId, event, parameter1, parameter2);
|
||||
EventManagerIF::triggerEvent(objectId, event, parameter1, parameter2);
|
||||
}
|
||||
|
@ -16,43 +16,41 @@
|
||||
* @author Ulrich Mohr
|
||||
* @ingroup system_objects
|
||||
*/
|
||||
class SystemObject: public SystemObjectIF {
|
||||
private:
|
||||
/**
|
||||
* @brief This is the id the class instant got assigned.
|
||||
*/
|
||||
const object_id_t objectId;
|
||||
const bool registered;
|
||||
public:
|
||||
class SystemObject : public SystemObjectIF {
|
||||
private:
|
||||
/**
|
||||
* @brief This is the id the class instant got assigned.
|
||||
*/
|
||||
const object_id_t objectId;
|
||||
const bool registered;
|
||||
|
||||
/**
|
||||
* Helper function to send Event Messages to the Event Manager
|
||||
* @param event
|
||||
* @param parameter1
|
||||
* @param parameter2
|
||||
*/
|
||||
virtual void triggerEvent(Event event, uint32_t parameter1 = 0,
|
||||
uint32_t parameter2 = 0);
|
||||
public:
|
||||
/**
|
||||
* Helper function to send Event Messages to the Event Manager
|
||||
* @param event
|
||||
* @param parameter1
|
||||
* @param parameter2
|
||||
*/
|
||||
virtual void triggerEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0);
|
||||
|
||||
/**
|
||||
* @brief The class's constructor.
|
||||
* @details In the constructor, the object id is set and the class is
|
||||
* inserted in the object manager.
|
||||
* @param setObjectId The id the object shall have.
|
||||
* @param doRegister Determines if the object is registered in
|
||||
* the global object manager.
|
||||
*/
|
||||
SystemObject(object_id_t setObjectId, bool doRegister = true);
|
||||
/**
|
||||
* @brief On destruction, the object removes itself from the list.
|
||||
*/
|
||||
virtual ~SystemObject();
|
||||
object_id_t getObjectId() const override;
|
||||
virtual ReturnValue_t initialize() override;
|
||||
virtual ReturnValue_t checkObjectConnections();
|
||||
/**
|
||||
* @brief The class's constructor.
|
||||
* @details In the constructor, the object id is set and the class is
|
||||
* inserted in the object manager.
|
||||
* @param setObjectId The id the object shall have.
|
||||
* @param doRegister Determines if the object is registered in
|
||||
* the global object manager.
|
||||
*/
|
||||
SystemObject(object_id_t setObjectId, bool doRegister = true);
|
||||
/**
|
||||
* @brief On destruction, the object removes itself from the list.
|
||||
*/
|
||||
virtual ~SystemObject();
|
||||
object_id_t getObjectId() const override;
|
||||
virtual ReturnValue_t initialize() override;
|
||||
virtual ReturnValue_t checkObjectConnections();
|
||||
|
||||
virtual void forwardEvent(Event event, uint32_t parameter1 = 0,
|
||||
uint32_t parameter2 = 0) const;
|
||||
virtual void forwardEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0) const;
|
||||
};
|
||||
|
||||
#endif /* FSFW_OBJECTMANAGER_SYSTEMOBJECT_H_ */
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef FSFW_OBJECTMANAGER_SYSTEMOBJECTIF_H_
|
||||
#define FSFW_OBJECTMANAGER_SYSTEMOBJECTIF_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "../events/EventReportingProxyIF.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include <cstdint>
|
||||
/**
|
||||
* @defgroup system_objects Software System Object Management
|
||||
* The classes to create System Objects and classes to manage these are
|
||||
@ -26,37 +27,37 @@ typedef uint32_t object_id_t;
|
||||
* @ingroup system_objects
|
||||
*/
|
||||
class SystemObjectIF : public EventReportingProxyIF {
|
||||
public:
|
||||
/**
|
||||
* This is a simple getter to return the object identifier.
|
||||
* @return Returns the object id of this object.
|
||||
*/
|
||||
virtual object_id_t getObjectId() const = 0;
|
||||
/**
|
||||
* The empty virtual destructor as required for C++ interfaces.
|
||||
*/
|
||||
virtual ~SystemObjectIF() {}
|
||||
/**
|
||||
* @brief Initializes the object.
|
||||
* There are initialization steps which can also be done in the constructor.
|
||||
* However, there is no clean way to get a returnvalue from a constructor.
|
||||
* Furthermore some components require other system object to be created
|
||||
* which might not have been built yet.
|
||||
* Therefore, a two-step initialization resolves this problem and prevents
|
||||
* circular dependencies of not-fully initialized objects on start up.
|
||||
* @return - @c RETURN_OK in case the initialization was successful
|
||||
* - @c RETURN_FAILED otherwise
|
||||
*/
|
||||
virtual ReturnValue_t initialize() = 0;
|
||||
/**
|
||||
* @brief Checks if all object-object interconnections are satisfying
|
||||
* for operation.
|
||||
* Some objects need certain other objects (or a certain number), to be
|
||||
* registered as children. These checks can be done in this method.
|
||||
* @return - @c RETURN_OK in case the check was successful
|
||||
* - @c any other code otherwise
|
||||
*/
|
||||
virtual ReturnValue_t checkObjectConnections() = 0;
|
||||
public:
|
||||
/**
|
||||
* This is a simple getter to return the object identifier.
|
||||
* @return Returns the object id of this object.
|
||||
*/
|
||||
virtual object_id_t getObjectId() const = 0;
|
||||
/**
|
||||
* The empty virtual destructor as required for C++ interfaces.
|
||||
*/
|
||||
virtual ~SystemObjectIF() {}
|
||||
/**
|
||||
* @brief Initializes the object.
|
||||
* There are initialization steps which can also be done in the constructor.
|
||||
* However, there is no clean way to get a returnvalue from a constructor.
|
||||
* Furthermore some components require other system object to be created
|
||||
* which might not have been built yet.
|
||||
* Therefore, a two-step initialization resolves this problem and prevents
|
||||
* circular dependencies of not-fully initialized objects on start up.
|
||||
* @return - @c RETURN_OK in case the initialization was successful
|
||||
* - @c RETURN_FAILED otherwise
|
||||
*/
|
||||
virtual ReturnValue_t initialize() = 0;
|
||||
/**
|
||||
* @brief Checks if all object-object interconnections are satisfying
|
||||
* for operation.
|
||||
* Some objects need certain other objects (or a certain number), to be
|
||||
* registered as children. These checks can be done in this method.
|
||||
* @return - @c RETURN_OK in case the check was successful
|
||||
* - @c any other code otherwise
|
||||
*/
|
||||
virtual ReturnValue_t checkObjectConnections() = 0;
|
||||
};
|
||||
|
||||
#endif /* #ifndef FSFW_OBJECTMANAGER_SYSTEMOBJECTIF_H_ */
|
||||
|
@ -5,39 +5,37 @@
|
||||
|
||||
// The objects will be instantiated in the ID order
|
||||
namespace objects {
|
||||
enum framework_objects: object_id_t {
|
||||
FSFW_OBJECTS_START = 0x53000000,
|
||||
// Default verification reporter.
|
||||
PUS_SERVICE_1_VERIFICATION = 0x53000001,
|
||||
PUS_SERVICE_2_DEVICE_ACCESS = 0x53000002,
|
||||
PUS_SERVICE_3_HOUSEKEEPING = 0x53000003,
|
||||
PUS_SERVICE_5_EVENT_REPORTING = 0x53000005,
|
||||
PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008,
|
||||
PUS_SERVICE_9_TIME_MGMT = 0x53000009,
|
||||
PUS_SERVICE_17_TEST = 0x53000017,
|
||||
PUS_SERVICE_20_PARAMETERS = 0x53000020,
|
||||
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
||||
PUS_SERVICE_201_HEALTH = 0x53000201,
|
||||
enum framework_objects : object_id_t {
|
||||
FSFW_OBJECTS_START = 0x53000000,
|
||||
// Default verification reporter.
|
||||
PUS_SERVICE_1_VERIFICATION = 0x53000001,
|
||||
PUS_SERVICE_2_DEVICE_ACCESS = 0x53000002,
|
||||
PUS_SERVICE_3_HOUSEKEEPING = 0x53000003,
|
||||
PUS_SERVICE_5_EVENT_REPORTING = 0x53000005,
|
||||
PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008,
|
||||
PUS_SERVICE_9_TIME_MGMT = 0x53000009,
|
||||
PUS_SERVICE_17_TEST = 0x53000017,
|
||||
PUS_SERVICE_20_PARAMETERS = 0x53000020,
|
||||
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
||||
PUS_SERVICE_201_HEALTH = 0x53000201,
|
||||
|
||||
/* CFDP Distributer */
|
||||
CFDP_PACKET_DISTRIBUTOR = 0x53001000,
|
||||
/* CFDP Distributer */
|
||||
CFDP_PACKET_DISTRIBUTOR = 0x53001000,
|
||||
|
||||
//Generic IDs for IPC, modes, health, events
|
||||
HEALTH_TABLE = 0x53010000,
|
||||
// MODE_STORE = 0x53010100,
|
||||
EVENT_MANAGER = 0x53030000,
|
||||
INTERNAL_ERROR_REPORTER = 0x53040000,
|
||||
IPC_STORE = 0x534f0300,
|
||||
//IDs for PUS Packet Communication
|
||||
TC_STORE = 0x534f0100,
|
||||
TM_STORE = 0x534f0200,
|
||||
TIME_STAMPER = 0x53500010,
|
||||
// Generic IDs for IPC, modes, health, events
|
||||
HEALTH_TABLE = 0x53010000,
|
||||
// MODE_STORE = 0x53010100,
|
||||
EVENT_MANAGER = 0x53030000,
|
||||
INTERNAL_ERROR_REPORTER = 0x53040000,
|
||||
IPC_STORE = 0x534f0300,
|
||||
// IDs for PUS Packet Communication
|
||||
TC_STORE = 0x534f0100,
|
||||
TM_STORE = 0x534f0200,
|
||||
TIME_STAMPER = 0x53500010,
|
||||
|
||||
FSFW_OBJECTS_END = 0x53ffffff,
|
||||
NO_OBJECT = 0xFFFFFFFF
|
||||
FSFW_OBJECTS_END = 0x53ffffff,
|
||||
NO_OBJECT = 0xFFFFFFFF
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_OBJECTMANAGER_FRAMEWORKOBJECTS_H_ */
|
||||
|
Reference in New Issue
Block a user