Robot Devastation
MockState.hpp
1 // Authors: see AUTHORS.md at project root.
2 // CopyPolicy: released under the terms of the LGPLv2.1, see LICENSE at project root.
3 // URL: https://github.com/asrob-uc3m/robotDevastation
4 
5 #ifndef __RD_MOCK_STATE_HPP__
6 #define __RD_MOCK_STATE_HPP__
7 
8 #include <yarp/os/PortReader.h>
9 #include <yarp/os/RpcServer.h>
10 #include <yarp/os/ConnectionReader.h>
11 
12 #include "State.hpp"
13 
14 namespace rd{
15 
26 class MockState : public State, public yarp::os::PortReader, public yarp::os::RpcServer
27 {
28  public:
30  MockState(int id);
31  virtual ~MockState();
32 
34  virtual bool setup();
35 
37  virtual bool loop();
38 
40  virtual bool cleanup();
41 
43  virtual int evaluateConditions();
44 
46  virtual bool read(yarp::os::ConnectionReader & connection);
47 
49  static const int STATE_INITIAL;
50 
52  static const int STATE_SETUP;
53 
55  static const int STATE_LOOP;
56 
58  static const int STATE_CLEANUP;
59 
61  static const int REQUEST_STATE;
62 
63  private:
64  int id;
65  int internal_variable;
66 
69 };
70 
71 
72 }
73 #endif // __RD_MOCK_STATE_HPP__
rd::MockState::STATE_INITIAL
static const int STATE_INITIAL
Indicates that the State has been initialized.
Definition: MockState.hpp:49
rd
The main, catch-all namespace for Robot Devastation.
Definition: groups.dox:4
rd::MockState::cleanup
virtual bool cleanup()
Sets an internal variable indicating that this function has been called.
Definition: MockState.cpp:63
rd::MockState::state_history
int state_history
Bitmask that stores the execution flow stages this State has passed through.
Definition: MockState.hpp:68
rd::MockState::REQUEST_STATE
static const int REQUEST_STATE
Request identifier for RPC communication.
Definition: MockState.hpp:61
rd::MockState::STATE_LOOP
static const int STATE_LOOP
Indicates that the State has called loop()
Definition: MockState.hpp:55
rd::State
Base class for each of the states of a FiniteStateMachine.
Definition: State.hpp:18
rd::MockState::setup
virtual bool setup()
Sets an internal variable indicating that this function has been called.
Definition: MockState.cpp:41
rd::MockState::MockState
MockState(int id)
Creates a MockState and assigns it an id.
Definition: MockState.cpp:22
rd::MockState::read
virtual bool read(yarp::os::ConnectionReader &connection)
Reads an incoming message that changes the internal state of the State.
Definition: MockState.cpp:78
rd::MockState::loop
virtual bool loop()
Sets an internal variable indicating that this function has been called.
Definition: MockState.cpp:51
rd::MockState
Dummy State for testing.
Definition: MockState.hpp:26
rd::MockState::STATE_CLEANUP
static const int STATE_CLEANUP
Indicates that the State has called cleanup()
Definition: MockState.hpp:58
rd::MockState::STATE_SETUP
static const int STATE_SETUP
Indicates that the State has called setup()
Definition: MockState.hpp:52
rd::MockState::evaluateConditions
virtual int evaluateConditions()
Returns the internal variable value as condition evaluation result.
Definition: MockState.cpp:73