source: trunk/FACT++/src/StateMachineDim.h@ 10808

Last change on this file since 10808 was 10510, checked in by tbretz, 14 years ago
Moved exit handler to DimErrorRedirecter.
File size: 1.9 KB
Line 
1#ifndef FACT_StateMachineDim
2#define FACT_StateMachineDim
3
4#include "MessageDim.h" // MessageDimTX
5#include "StateMachine.h" // StateMachien
6
7// ***************************************************************************
8/**
9 @class DimStart
10
11 @brief Ensures calling DimServer::start() in its constructor and DimServer::stop() in its destructor
12
13**/
14// ***************************************************************************
15#include "DimErrorRedirecter.h"
16
17class DimStart : public DimErrorRedirecter
18{
19protected:
20 DimStart(const std::string &name, MessageImp &imp) : DimErrorRedirecter(imp)
21 {
22 DimServer::start(name.c_str());
23 }
24 ~DimStart()
25 {
26 DimServer::stop();
27 }
28};
29
30class StateMachineDim : public DimCommandHandler, public StateMachine, public DimStart
31{
32private:
33 MessageDimTX fLog; /// Logging to the Dim network
34
35 static const int fVersion; /// Version number
36
37 DimDescribedService fDescriptionStates; /// DimService propagating the state descriptions
38 DimDescribedService fSrvState; /// DimService offering fCurrentState
39// DimService fSrvVersion; /// DimService offering fVersion
40
41
42 void exitHandler(int code); /// Overwritten DimCommand::exitHandler.
43 void commandHandler(); /// Overwritten DimCommand::commandHandler
44
45 /// Redirect our own logging to fLog
46 int Write(const Time &time, const std::string &txt, int qos);
47
48 /// This is an internal function to do some action in case of
49 /// a state change, like updating the corresponding service.
50 std::string SetCurrentState(int state, const char *txt="", const std::string &cmd="");
51
52 EventImp *CreateEvent(int targetstate, const char *name, const char *fmt);
53
54public:
55 StateMachineDim(std::ostream &out=std::cout, const std::string &name="DEFAULT");
56
57 void AddStateName(const int state, const std::string &name, const std::string &doc="");
58};
59
60#endif
Note: See TracBrowser for help on using the repository browser.