01 solution

This commit is contained in:
Robin Müller 2022-10-04 10:35:03 +02:00
parent 98c6e66b30
commit 96106f096c
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 34 additions and 6 deletions

View File

@ -1,13 +1,12 @@
#include <iostream>
#include "fsfw/objectmanager.h" #include "fsfw/objectmanager.h"
#include <iostream>
#include <iomanip> #include <iomanip>
using namespace std; using namespace std;
class MySystemObject: public SystemObject { class MySystemObject: public SystemObject {
public: public:
MySystemObject(): SystemObject(0x10101010, false) {} MySystemObject(): SystemObject(0x10101010) {}
ReturnValue_t initialize() override { ReturnValue_t initialize() override {
cout << "MySystemObject::initialize: Custom init" << endl; cout << "MySystemObject::initialize: Custom init" << endl;
} }
@ -15,8 +14,9 @@ public:
int main() { int main() {
auto* mySysObj = new MySystemObject(); auto* mySysObj = new MySystemObject();
cout << "Object ID: " << setfill('0') << setw(8) << hex << "0x" << auto* objManager = ObjectManager::instance();
cout << "Object ID: " << setfill('0') << hex << "0x" << setw(8) <<
mySysObj->getObjectId() << endl; mySysObj->getObjectId() << endl;
mySysObj->initialize(); objManager->initialize();
delete mySysObj; return 0;
} }

View File

@ -72,3 +72,9 @@ all its registered objects.
## Subtasks ## Subtasks
1. Register the `MySystemObject` class into the global object manager. You can do this with a
simple tweak of the base class constructor.
2. Remove the `delete` call. The object manager will delete all of its contained objects
automatically in its own destructor
3. Retrieve the global instance of the object manager using its static `instance` method
and use it to initialize all system objects including your custom system object.

View File

@ -0,0 +1,22 @@
#include "fsfw/objectmanager.h"
#include <iostream>
#include <iomanip>
using namespace std;
class MySystemObject: public SystemObject {
public:
MySystemObject(): SystemObject(0x10101010, false) {}
ReturnValue_t initialize() override {
cout << "MySystemObject::initialize: Custom init" << endl;
}
};
int main() {
auto* mySysObj = new MySystemObject();
cout << "Object ID: " << setfill('0') << hex << "0x" << setw(8) <<
mySysObj->getObjectId() << endl;
mySysObj->initialize();
delete mySysObj;
return 0;
}