SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
mainModule.hpp
1
12#ifndef __MODULE_HPP__
13#define __MODULE_HPP__
14
15#include "stdlib.h"
16#include <queue>
17#include <variant>
18
19#include "Log.h"
20#include "TeensyThreads.h"
21
22namespace Module {
23
24class Module_t;
25class Manager_t;
26using bitmapVal_t = unsigned short;
27
28const LOG_TAG ID = "Module";
29const size_t maxModules = sizeof(bitmapVal_t) * 8;
30
31extern bitmapVal_t s_id;
32extern Module_t *allModules[maxModules];
33
64class Module_t {
65private:
66 const bitmapVal_t count = 0;
67 const Module_t *dependents[maxModules] = {0}; // IMPROVE: make flexible dependency array
68
69 friend Manager_t;
70
71protected:
72 const bitmapVal_t id;
73
74 virtual void print();
75 virtual void setup();
76
77public:
78 static const int classID = 0;
79 virtual int getClassID() const { return classID; }
80
81 Module_t() : id(1 << s_id++) { allModules[s_id - 1] = this; };
82 template <typename... T>
83 Module_t(T *...mods) : count(sizeof...(mods)), dependents{static_cast<Module_t *>(mods)...}, id(1 << s_id++) { allModules[s_id - 1] = this; };
84};
85
86} // namespace Module
87
88#endif // __MODULE_HPP__
Special logging functionality.
const char * LOG_TAG
Type definition of logging tags This typedef is necessary to allow for easier manipulation of code by...
Definition Log.h:48
Module_t should be used for major components of a framework, it is used to isolate,...