Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
InformationServer.h
Go to the documentation of this file.
1#pragma once
3#include <gii/gen/Variable.h>
4#include <gii/global.h>
5
6namespace sf
7{
8
10{
11 public:
16
21
31 void setup(const std::string& name, const std::string& namePrefix, long vid, long deviceMask, long serverMask);
32
36 void flush();
37
41 enum EState
42 {
44 issOff = 0,
54 issMaxState
55 };
56
60 [[nodiscard]] EState getState() const;
61
65 [[nodiscard]] const char* getStateName(int state) const;
66
71
75 enum EClass
76 {
78 clA = 0,
84 clMaxClass
85 };
86
90 [[nodiscard]] bool isServerId(id_type id) const;
91
96
100 // Removes a variable from the variable vector.
102
103 // Adds a result to the result vector.
108
109 // Removes a result from the result vector.
114
115 // Reports if this server generates results depending on its current state.
120
121 // To be overloaded by a derived class to handle a state change if necessary.
125 virtual void onStateChange(EState prevState, EState nextState) = 0;
126
127 // Clears the committed ranges of the attached results.
128 // This one can be overloaded by the derived class.
129 // When so this function must be called as well.
133 virtual void clearValidations();
134
135 private:
139 void variableEventHandler(Variable::EEvent, const Variable&, Variable&, bool);
140
144 void setWriteFlagForClass(EClass, bool write_enable);
145
149 void setArchiveFlag(bool write_enable);
150
155 void setRecycleFlag(bool recycle_enable);
156
160 typedef void (InformationServer::*VoidFunction)();
161
165 void stateChangeUnknown();
166
170 void stateChangeIllegal();
171
175 void stateChangeStopToRun();
176
180 void stateChangeRunToStop();
181
185 void stateChangeOffToRun();
186
190 void stateChangeRunToRecord();
191
195 void stateChangeRecordToPause();
196
200 void stateChangePauseToStop();
201
205 void stateChangeAnyToOff();
206
210 Variable _vState;
214 EState _prevState;
218 EState _curState;
222 id_type _serverDeviceMask;
226 id_type _serverDeviceId;
230 VoidFunction _jumpTable[issMaxState][issMaxState]{};
234 Variable::PtrVector _variableList[clMaxClass];
238 ResultData::PtrVector _resultList;
243};
244
245}// namespace sf
Definition InformationServer.h:10
virtual ~InformationServer()
void attachResult(ResultData *res)
void detachResult(ResultData *res)
virtual void onStateChange(EState prevState, EState nextState)=0
void flush()
Clears the instance. Also called from setup.
EState getState() const
Gets the current state.
EClass
Variable/parameter class enumerator.
Definition InformationServer.h:76
@ clC
Definition InformationServer.h:82
@ clB
Definition InformationServer.h:80
bool isServerId(id_type id) const
Determines if the passed id belongs to this info server.
virtual void clearValidations()
EState
Enumerate for state of the info server.
Definition InformationServer.h:42
@ issRecord
Definition InformationServer.h:48
@ issPause
Definition InformationServer.h:50
@ issRun
Definition InformationServer.h:46
@ issStop
Definition InformationServer.h:52
InformationServer()
Default constructor.
void setup(const std::string &name, const std::string &namePrefix, long vid, long deviceMask, long serverMask)
When device mask is non-zero, variables are added automatically on creation to this info server.
const char * getStateName(int state) const
Gets the name of the passed state.
void setState(EState)
Sets the current state.
void attachVariable(Variable *var, EClass cls)
Adds a variable to the variables vector.
void detachVariable(Variable *var)
Base class for all generic information objects to be able to put them in a typed list together.
Definition InformationBase.h:25
unsigned long long id_type
Type used for the identifying integer (64-bits).
Definition InformationBase.h:30
Class for creating and referencing global created data called result data. This class allows linking ...
Definition ResultData.h:20
Template for linking pointers of member function to Variable instances.
Definition VariableHandler.h:38
EEvent
Events send to the handler set with sf::Variable::setHandler.
Definition VariableTypes.h:130
Class for creating and referencing global or local created parameters or settings called variables....
Definition Variable.h:16
#define _GII_CLASS
Definition gii/global.h:38
Definition Application.h:10