![]() |
4S Device Communication Module Collection
Version 0.6-SNAPSHOT
Full documentation of the modules in the 4SDC collection (aimed at 4SDC module developers)
|
|
Contains the declaration of the module defining macros and classes. More...
Go to the source code of this file.
Classes | |
class | FSYS::Module |
Base class for all modules. More... | |
class | FSYS::MsgSystemReady |
Message broadcasted when the system is initialised. More... | |
class | FSYS::MsgGoingDown |
Message broadcasted when the system is being terminated. More... | |
class | FSYS::MsgGroupReady |
Message broadcasted when all static modules in a group are ready. More... | |
class | FSYS::MsgDestroy |
Last message broadcasted to threads. More... | |
class | FSYS::MsgAllDestroyed |
Last message broadcasted in system. More... | |
class | FSYS::ModulePrivate::LauncherBase |
The LauncherBase class is the non-template class for other Launchers. More... | |
class | FSYS::ModulePrivate::Launcher< TypeToLaunch, mt > |
The Launcher class is used for dynamically launching the user clases. More... | |
class | FSYS::ModulePrivate::LauncherEnd |
Dummy launcher class to mark the end of the launcher list. More... | |
The macros and classes are used for defining the modules in the system.
A module is in this context defined as an object that needs to be instantiated (potentially in its own thread) and isn't instantiated dynamically or as a static member of or in a different object.
A module must inherit from the FSYS::Module class.
A number of different module types exists:
A "Static" module is one that will be created when the program is launched. A static module can't and won't be deleted/destroyed until the program is terminating.
A "Delayed" module will be instantiated when a message of the type given in its declaration macro is broadcasted in the system.
A "Delayed" module can destroy it self by calling its deleteMe() function.
If a "Delayed" module has destroyed it self it will be instantiated again the next time a message of the type given in the template parameter is broadcasted. (Beware of raceconditions here)
A "Dynamic" and "DynamicThread" module will be instantiated each time a message of MsgType is broadcasted in the system. A DynamicThread module will be spawned in its own thread where a dynamic module will be created in the thread defined by its module group.
"Dynamic" and "DynamicThread" modules must destroy them self when they are done, by calling their deleteMe() function, to avoid resource leaking and CPU cycle leaking.
A Module is defined in the module definition file by using the MODULE* macros.
MODULE_GROUP(GroupName) MODULE_STATIC(ModuleClassName) MODULE_DELAYED(ModuleClassName) MODULE_GROUP_END
MODULE_GROUP(GroupName) MODULE_DYNAMIC(ModuleClassName) MODULE_DYNAMIC_THREAD(ModuleClassName) MODULE_GROUP_END
All modules in a group are guaranteed to run in the same thread, modules in different groups, might or might not run in the same thread, depending on the configuration of the platform that the code is run on (With MODULE_DYNAMIC_THREAD as an obvious exception to this rule)
Currently only MODULE_STATIC is implemented
The ModuleX baseclass will implement and call the following virtual functions that can be used by the module to act, depending on where in its life cycle it is, by overriding the virual functions
This function is called when the module can start to use the message system. It is guarantied that this function is called before any messages are received by the module.
This function is called when all the static modules in the group are ready to use the message system (this means that the module can interact through the message system with the other static modules in the group).
This function is called when all static modules in all groups are ready to use the message system (this means that the module can interact through the message system with all other static modules in the system (in all groups))
This function is called to inform the module that the shutdown sequence of the system has been initiated and that it should release all its system resources.
After this function is called the module can no longer rely on the message system and should prepare for imminent destruction.
The msgSystemReady() and msgGoingDown() function calls will also be broadcasted as standard messages
Broadcasted when all static modules are started. If a module is created after this message is broadcasted, then it won't be able to receive this message, but it will still have its void msgSystemReady( void ) function called.
Broadcasted when the system is shutting down. If a module is created after this message is broadcasted, then it won't be able to receive this message, but it will still have its void msgGointDown( void ) function called.
The following messages are being used internally.
Broadcasted by a group when all of its static modules have launched
Broadcasted when all the threads should terminate
Broadcasted when all threads are destroyed