4S Device Communication Module Collection  Version 0.6-SNAPSHOT
Full documentation of the modules in the 4SDC collection (aimed at 4SDC module developers)
modulerunner.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2015 The 4S Foundation (www.4s-online.dk)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef MODULERUNNER_H
17 #define MODULERUNNER_H
18 
24 #include "FSYS/moduledeclare.h"
25 #include "FSYS/msgreceiver.h"
26 #include "FSYS/msgsender.h"
27 
28 #include <initializer_list>
29 #include <list>
30 #include <string>
31 
32 namespace FSYS
33 {
34 
35  namespace ModulePrivate
36  {
37  class LauncherBase;
38  class Runner : public MsgSender<Runner>,
39  public MsgReceiver<Runner, MsgSystemReady>,
40  public MsgReceiver<Runner, MsgGoingDown>,
41  public MsgReceiver<Runner, MsgDestroy>
42  {
43  private:
44  std::string groupName;
45  std::list<LauncherBase*> groupModuleList;
46  bool terminateMsgLoop = {false};
47 
48  public:
63  Runner(std::string groupName,
64  std::initializer_list<LauncherBase*> moduleList);
65 
71  void startStaticModules( void );
72 
79  void runMsgLoop( void );
80 
86  void shutdown( void );
87 
94  void receive(MsgSystemReady);
95 
102  void receive(MsgGoingDown);
103 
110  void receive(MsgDestroy);
111 
112  };
113  }
114 }
115 
116 #endif // MODULERUNNER_H
117 
Contains interface declaration for the FSYS::MsgSender class.
Contains interface declaration for the FSYS::MsgReceiver class.
Template class allowing other classes to receive messages.
Definition: msgreceiver.h:78
void runMsgLoop(void)
Calling this function will run the message loop for this thread.
Definition: modulerunner.cpp:77
Message broadcasted when the system is initialised.
Definition: moduledeclare.h:193
void receive(MsgSystemReady)
Receiver function for the MsgSystemReady broadcast.
Definition: modulerunner.cpp:102
void shutdown(void)
Function that stops and delete all modules owned by this runner.
Definition: modulerunner.cpp:87
void startStaticModules(void)
Function to start all static modules.
Definition: modulerunner.cpp:55
Last message broadcasted to threads.
Definition: moduledeclare.h:218
Contains the declaration of the module defining macros and classes.
Definition: basemsg.h:38
Runner(std::string groupName, std::initializer_list< LauncherBase * > moduleList)
Constructor for the Runner class.
Definition: modulerunner.cpp:42
Definition: modulerunner.h:38
Class enabling other classes to send messages.
Definition: msgsender.h:60
Message broadcasted when the system is being terminated.
Definition: moduledeclare.h:202