some more ref replacements

This commit is contained in:
Robin Müller 2022-07-25 11:24:13 +02:00
parent 899d021e00
commit 973d4ee8a5
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
8 changed files with 22 additions and 15 deletions

View File

@ -42,11 +42,11 @@ ReturnValue_t Service17Test::initialize() {
if (tmStore == nullptr) { if (tmStore == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
storeHelper.setTmStore(tmStore); storeHelper.setTmStore(*tmStore);
} }
return result; return result;
} }
void Service17Test::setCustomTmStore(StorageManagerIF* tmStore_) { void Service17Test::setCustomTmStore(StorageManagerIF& tmStore_) {
storeHelper.setTmStore(tmStore_); storeHelper.setTmStore(tmStore_);
} }

View File

@ -35,7 +35,7 @@ class Service17Test : public PusServiceBase {
Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId); Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId);
void setCustomTmStore(StorageManagerIF* tmStore); void setCustomTmStore(StorageManagerIF& tmStore);
~Service17Test() override; ~Service17Test() override;
ReturnValue_t handleRequest(uint8_t subservice) override; ReturnValue_t handleRequest(uint8_t subservice) override;

View File

@ -100,7 +100,7 @@ ReturnValue_t Service1TelecommandVerification::initialize() {
if (tmStore == nullptr) { if (tmStore == nullptr) {
return ObjectManager::CHILD_INIT_FAILED; return ObjectManager::CHILD_INIT_FAILED;
} }
storeHelper.setTmStore(tmStore); storeHelper.setTmStore(*tmStore);
} }
return SystemObject::initialize(); return SystemObject::initialize();
} }

View File

@ -96,7 +96,7 @@ ReturnValue_t CommandingServiceBase::initialize() {
if (tmStore == nullptr) { if (tmStore == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
tmStoreHelper.setTmStore(tmStore); tmStoreHelper.setTmStore(*tmStore);
} }
if (errReporter == nullptr) { if (errReporter == nullptr) {
errReporter = errReporter =
@ -419,7 +419,7 @@ void CommandingServiceBase::checkTimeout() {
void CommandingServiceBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; } void CommandingServiceBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; }
void CommandingServiceBase::setCustomTmStore(StorageManagerIF* store) { void CommandingServiceBase::setCustomTmStore(StorageManagerIF& store) {
tmStoreHelper.setTmStore(store); tmStoreHelper.setTmStore(store);
} }
ReturnValue_t CommandingServiceBase::setUpTcReader(store_address_t storeId) { ReturnValue_t CommandingServiceBase::setUpTcReader(store_address_t storeId) {

View File

@ -70,7 +70,7 @@ class CommandingServiceBase : public SystemObject,
size_t queueDepth = 20); size_t queueDepth = 20);
~CommandingServiceBase() override; ~CommandingServiceBase() override;
void setCustomTmStore(StorageManagerIF* store); void setCustomTmStore(StorageManagerIF& store);
/** /**
* This setter can be used to set the packet source individually instead * This setter can be used to set the packet source individually instead
* of using the default static framework ID set in the factory. * of using the default static framework ID set in the factory.

View File

@ -28,16 +28,18 @@ ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice,
StorageManagerIF* TmStoreHelper::getTmStore() { return tmStore; } StorageManagerIF* TmStoreHelper::getTmStore() { return tmStore; }
void TmStoreHelper::setTmStore(StorageManagerIF* store) { tmStore = store; } void TmStoreHelper::setTmStore(StorageManagerIF& store) { tmStore = &store; }
const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAddr; } const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAddr; }
ReturnValue_t TmStoreHelper::deletePacket() { return tmStore->deleteData(currentAddr); } ReturnValue_t TmStoreHelper::deletePacket() { return tmStore->deleteData(currentAddr); }
void TmStoreHelper::setSourceDataRaw(const uint8_t* data, size_t len) { ReturnValue_t TmStoreHelper::setSourceDataRaw(const uint8_t* data, size_t len) {
creator.setRawUserData(data, len); return creator.setRawUserData(data, len);
} }
void TmStoreHelper::setSourceDataSerializable(SerializeIF* serializable) { ReturnValue_t TmStoreHelper::setSourceDataSerializable(SerializeIF* serializable) {
creator.setSerializableUserData(serializable); return creator.setSerializableUserData(serializable);
} }
ReturnValue_t TmStoreHelper::addPacketToStore() { ReturnValue_t TmStoreHelper::addPacketToStore() {

View File

@ -18,11 +18,11 @@ class TmStoreHelper {
PusTmCreator& getCreatorRef(); PusTmCreator& getCreatorRef();
void setTimeStamper(TimeStamperIF& timeStamper); void setTimeStamper(TimeStamperIF& timeStamper);
[[nodiscard]] const store_address_t& getCurrentAddr() const; [[nodiscard]] const store_address_t& getCurrentAddr() const;
void setSourceDataRaw(const uint8_t* data, size_t len); ReturnValue_t setSourceDataRaw(const uint8_t* data, size_t len);
void setSourceDataSerializable(SerializeIF* serializable); ReturnValue_t setSourceDataSerializable(SerializeIF* serializable);
void setApid(uint16_t apid); void setApid(uint16_t apid);
StorageManagerIF* getTmStore(); StorageManagerIF* getTmStore();
void setTmStore(StorageManagerIF* store); void setTmStore(StorageManagerIF& store);
ReturnValue_t addPacketToStore(); ReturnValue_t addPacketToStore();
ReturnValue_t deletePacket(); ReturnValue_t deletePacket();

View File

@ -12,6 +12,7 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") {
SECTION("State") { SECTION("State") {
REQUIRE(storeHelper.getCurrentAddr() == store_address_t::invalid()); REQUIRE(storeHelper.getCurrentAddr() == store_address_t::invalid());
REQUIRE(storeHelper.getTmStore() == &pool);
REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK);
auto& creator = storeHelper.getCreatorRef(); auto& creator = storeHelper.getCreatorRef();
REQUIRE(creator.getApid() == 2); REQUIRE(creator.getApid() == 2);
@ -25,5 +26,9 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") {
REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK);
REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK);
REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid()); REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid());
auto accessor = pool.getData(storeHelper.getCurrentAddr());
REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK);
// Not going to verify individual fields, the creator was unittested separately
REQUIRE(accessor.second.size() == 22);
} }
} }