Skip to content

Commit dee8472

Browse files
committed
[occ] Document RuntimeControlledObject
1 parent 1c24f98 commit dee8472

1 file changed

Lines changed: 144 additions & 12 deletions

File tree

occ/occlib/RuntimeControlledObject.h

Lines changed: 144 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,157 @@ class RuntimeControlledObjectPrivate;
3333

3434
class OCC_EXPORT RuntimeControlledObject {
3535
public:
36+
/**
37+
* Creates a new RuntimeControlledObject instance, should be called by implementer's constructor.
38+
*
39+
* @param objectName A descriptive name for the state machine driven task. Should be
40+
* alphanumeric, as it's a potentially user-visible string to identify the program. It does not
41+
* have to be unique to this instance.
42+
*/
3643
explicit RuntimeControlledObject(const std::string objectName);
44+
45+
/**
46+
* Default destructor.
47+
*/
3748
virtual ~RuntimeControlledObject();
3849

50+
/**
51+
* Returns the name of the RuntimeControlledObject as set in the constructor.
52+
*
53+
* @return a std::string with the object's name.
54+
*/
3955
const std::string getName();
4056

57+
/**
58+
* Returns the current state of the controlled state machine.
59+
*
60+
* @return a t_State representing the state of the machine.
61+
*
62+
* @see OccState.h
63+
*/
4164
t_State getState();
4265

43-
virtual int executeConfigure(const PropertyMap& properties); // to go from standby to configured
44-
virtual int executeReset(); // to go from configured to standby
45-
virtual int executeRecover(); // to go from error to standby
46-
virtual int executeStart(); // to go from configured to running
47-
virtual int executeStop(); // to go from running/paused to configured
48-
virtual int executePause(); // to go from running to paused
49-
virtual int executeResume(); // to go from paused to running
50-
virtual int executeExit(); // to go from standby/configured to done
51-
52-
// ↓ called by event loop in OccServer
53-
virtual int iterateRunning(); // called continuously in state 'running'
54-
virtual int iterateCheck(); // called periodically in any state
66+
/**
67+
* Transition from standby to configured.
68+
*
69+
* @param properties a string-string map of key-values pushed by the control agent, containing
70+
* deployment-specific configuration (i.e. outbound channel configuration and similar).
71+
* @return 0 if the transition completed successfully, any non-zero value immediately triggers
72+
* a transition to the error state.
73+
*
74+
* The implementer should use this transition to move the machine from an unconfigured, bare
75+
* state into a state where the dataflow may be initiated at any time.
76+
* It is ok for this step to take some time if necessary.
77+
*
78+
* @note Only one of the transition functions will be called at any given time, and during a
79+
* transition all checks (iterateRunning/iterateCheck) are blocked until the transition
80+
* finishes and returns success or error.
81+
*/
82+
virtual int executeConfigure(const PropertyMap& properties);
83+
84+
/**
85+
* Transition from configured to standby.
86+
*
87+
* @return 0 if the transition completed successfully, any non-zero value immediately triggers
88+
* a transition to the error state.
89+
*
90+
* The implementer should use this transition to move the machine from a configured state where
91+
* the dataflow is ready to start (or has recently ended) into a bare, unconfigured state.
92+
* Care should be taken to either correctly clear all configuration in this transition, or to
93+
* make the (opposite) Configure transition idempotent in order to avoid keeping hidden state
94+
* data.
95+
*/
96+
virtual int executeReset();
97+
98+
/**
99+
* Transition from error to standby.
100+
*
101+
* @return 0 if the transition completed successfully, any non-zero value immediately triggers
102+
* a transition to the error state.
103+
*
104+
* The implementer should use this transition to recover from the error state.
105+
*/
106+
virtual int executeRecover();
107+
108+
/**
109+
* Transition from configured to running.
110+
*
111+
* @return 0 if the transition completed successfully, any non-zero value immediately triggers
112+
* a transition to the error state.
113+
*
114+
* The implementer should use this transition to initiate the data flow. When this function
115+
* exits successfully, the running state is reached, in which iterateRunning is called
116+
* periodically to drive the data processing.
117+
*/
118+
virtual int executeStart();
119+
120+
/**
121+
* Transition from running or paused to configured.
122+
*
123+
* @return 0 if the transition completed successfully, any non-zero value immediately triggers
124+
* a transition to the error state.
125+
*
126+
* The implementer should use this transition to terminate the data flow.
127+
*/
128+
virtual int executeStop();
129+
130+
/**
131+
* Transition from running to paused.
132+
*
133+
* @return 0 if the transition completed successfully, any non-zero value immediately triggers
134+
* a transition to the error state.
135+
*
136+
* The implementer should use this transition to temporarily pause data processing. The paused
137+
* state should not imply a change in configuration, the only difference compared with the
138+
* running state is the absence of periodic iterateRunning calls.
139+
*/
140+
virtual int executePause();
141+
142+
/**
143+
* Transition from paused to running.
144+
*
145+
* @return 0 if the transition completed successfully, any non-zero value immediately triggers
146+
* a transition to the error state.
147+
*
148+
* The implementer should use this transition to resume data processing after a temporary pause.
149+
*/
150+
virtual int executeResume();
151+
152+
/**
153+
* Transition from standby or configured to done.
154+
*
155+
* @return 0 if the transition completed successfully, any non-zero value immediately triggers
156+
* a transition to the error state.
157+
*
158+
* The implementer should use this transition to safely release all resources in preparation for
159+
* process exit.
160+
*/
161+
virtual int executeExit();
162+
163+
164+
/**
165+
* Execute periodic actions, as required by the running state.
166+
*
167+
* @return 0 if the operation completed successfully and the machine can stay in the running state,
168+
* 1 if all data processing is done and the implementer wishes to notify the machine control
169+
* mechanism of this condition, or any other value which immediately triggers a transition to
170+
* the error state.
171+
*
172+
* This function is called continuously by OccServer::runChecker if the state machine is in the
173+
* state t_State::running. It is never called outside this state.
174+
*/
175+
virtual int iterateRunning();
176+
177+
/**
178+
* Perform periodic checks during every state.
179+
*
180+
* @return 0 if the check completed successfully and the machine can stay in the current state,
181+
* or any other value to immediately trigger a transition to the error state.
182+
*
183+
* This function is called continuously by OccServer::runChecker in any state. Its purpose is for
184+
* the implementer to report an unusual condition in order to trigger a transition to error.
185+
*/
186+
virtual int iterateCheck();
55187

56188
private:
57189
RuntimeControlledObjectPrivate *dPtr;

0 commit comments

Comments
 (0)