some object managerIF security measures

objectmanager get function checks whether global object manager was
initialized now.
New returnvalues, which are also used for local pool init
This commit is contained in:
Robin Müller 2020-05-06 14:35:30 +02:00
parent 6b205e166b
commit e950051b4a
5 changed files with 24 additions and 36 deletions

View File

@ -89,17 +89,9 @@ uint32_t FixedSlotSequence::getLengthMs() const {
ReturnValue_t FixedSlotSequence::checkSequence() const {
if(slotList.empty()) {
<<<<<<< HEAD
sif::error << "Fixed Slot Sequence: Slot list is empty!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
// Iterate through slotList and check successful creation.
// Checks if timing is ok (must be ascending) and if all handlers were found.
=======
error << "Fixed Slot Sequence: Slot list is empty!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
>>>>>>> master
auto slotIt = slotList.begin();
uint32_t count = 0;
uint32_t time = 0;

View File

@ -12,16 +12,6 @@ using SlotListIter = std::multiset<FixedSequenceSlot>::iterator;
/**
* @brief This class is the representation of a Polling Sequence Table in software.
*
<<<<<<< HEAD
* @details The FixedSlotSequence object maintains the dynamic execution of device handler objects.
* The main idea is to create a list of device handlers, to announce all handlers to the
* polling sequence and to maintain a list of polling slot objects. This slot list represents the
* Polling Sequence Table in software. Each polling slot contains information to indicate when and
* which device handler shall be executed within a given polling period.
* The sequence is then executed by iterating through this slot list.
* Handlers are invoking by calling a certain function stored in the handler list.
=======
* @details
* The FixedSlotSequence object maintains the dynamic execution of
* device handler objects.
@ -35,7 +25,6 @@ using SlotListIter = std::multiset<FixedSequenceSlot>::iterator;
* which device handler shall be executed within a given polling period.
* The sequence is then executed by iterating through this slot list.
* Handlers are invoking by calling a certain function stored in the handler list.
>>>>>>> master
*/
class FixedSlotSequence {
public:
@ -128,16 +117,13 @@ public:
*/
SlotListIter current;
<<<<<<< HEAD
virtual ReturnValue_t checkSequence() const;
=======
/**
* Iterate through slotList and check successful creation.
* Checks if timing is ok (must be ascending) and if all handlers were found.
* @return
*/
ReturnValue_t checkSequence() const;
>>>>>>> master
protected:
/**

View File

@ -12,6 +12,7 @@
#include <config/objects/systemObjectList.h>
#include <framework/objectmanager/SystemObjectIF.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
/**
* @brief This class provides an interface to the global object manager.
@ -24,9 +25,12 @@
*/
class ObjectManagerIF : public HasReturnvaluesIF {
public:
static const uint8_t INTERFACE_ID = CLASS_ID::OBJECT_MANAGER_IF;
static const ReturnValue_t INSERTION_FAILED = MAKE_RETURN_CODE( 1 );
static const ReturnValue_t NOT_FOUND = MAKE_RETURN_CODE( 2 );
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 );
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
@ -79,16 +83,21 @@ public:
};
/*Documentation can be found in the class method declaration above.*/
template <typename T>
T* ObjectManagerIF::get( object_id_t id ) {
SystemObjectIF* temp = this->getSystemObject(id);
return dynamic_cast<T*>(temp);
}
/**
* @brief This is the forward declaration of the global objectManager instance.
*/
extern ObjectManagerIF *objectManager;
/*Documentation can be found in the class method declaration above.*/
template <typename T>
T* ObjectManagerIF::get( object_id_t id ) {
if(objectManager == nullptr) {
sif::error << "ObjectManagerIF: Global object manager has not "
"been initialized yet!" << std::endl;
std::exit(0);
}
SystemObjectIF* temp = this->getSystemObject(id);
return dynamic_cast<T*>(temp);
}
#endif /* OBJECTMANAGERIF_H_ */

View File

@ -242,8 +242,8 @@ inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::initialize() {
}
internalErrorReporter = objectManager->get<InternalErrorReporterIF>(
objects::INTERNAL_ERROR_REPORTER);
if (internalErrorReporter == NULL){
return RETURN_FAILED;
if (internalErrorReporter == nullptr){
return ObjectManagerIF::INTERNAL_ERR_REPORTER_UNINIT;
}
//Check if any pool size is large than the maximum allowed.
@ -251,7 +251,7 @@ inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::initialize() {
if (element_sizes[count] >= STORAGE_FREE) {
sif::error << "LocalPool::initialize: Pool is too large! "
"Max. allowed size is: " << (STORAGE_FREE - 1) << std::endl;
return RETURN_FAILED;
return StorageManagerIF::POOL_TOO_LARGE;
}
}
return RETURN_OK;

View File

@ -71,6 +71,7 @@ public:
static const ReturnValue_t ILLEGAL_STORAGE_ID = MAKE_RETURN_CODE(3); //!< This return code indicates that data was requested with an illegal storage ID.
static const ReturnValue_t DATA_DOES_NOT_EXIST = MAKE_RETURN_CODE(4); //!< This return code indicates that the requested ID was valid, but no data is stored there.
static const ReturnValue_t ILLEGAL_ADDRESS = MAKE_RETURN_CODE(5);
static const ReturnValue_t POOL_TOO_LARGE = MAKE_RETURN_CODE(6); //!< Pool size too large on initialization.
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::OBSW;
static const Event GET_DATA_FAILED = MAKE_EVENT(0, SEVERITY::LOW);