Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
FakeTrackIf.hxx
Go to the documentation of this file.
1
36#ifndef _DCC_FAKETRACKIF_HXX_
37#define _DCC_FAKETRACKIF_HXX_
38
39#include "executor/Executor.hxx"
41#include "dcc/Packet.hxx"
42
43namespace dcc
44{
45
47class FakeTrackIf : public StateFlow<Buffer<dcc::Packet>, QList<1>>
48{
49public:
54 FakeTrackIf(Service *service, int pool_size)
55 : StateFlow<Buffer<dcc::Packet>, QList<1>>(service)
56 , pool_(sizeof(Buffer<dcc::Packet>), pool_size)
57 {
58 }
59
61 {
62 return &pool_;
63 }
64
65protected:
67 {
68 return sleep_and_call(&timer_, MSEC_TO_NSEC(10), STATE(finish));
69 }
70
73 {
74 return release_and_exit();
75 }
76
80 StateFlowTimer timer_{this};
81};
82
83} // namespace dcc
84
85#endif // _DCC_FAKETRACKIF_HXX_
#define STATE(_fn)
Turns a function name into an argument to be supplied to functions expecting a state.
Definition StateFlow.hxx:61
Base class for all QMember types that hold data in an expandable format.
Definition Buffer.hxx:195
Pool of fixed number of items which can be allocated up on request.
Definition Buffer.hxx:573
A list of queues.
Definition Queue.hxx:466
Collection of related state machines that pend on incoming messages.
State flow with a given typed input queue.
Base::Action Action
Allows using Action without having StateFlowBase:: prefix in front of it.
StateFlow that accepts dcc::Packet structures and drops them to the floor.
StateFlowTimer timer_
Helper object for timing.
FixedPool * pool() OVERRIDE
Action entry() OVERRIDE
Entry into the StateFlow activity.
FixedPool pool_
Pool of unallocated packets.
FakeTrackIf(Service *service, int pool_size)
Constructor.
Action finish()
Do nothing.
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
Definition macros.h:180
#define MSEC_TO_NSEC(_msec)
Convert a millisecond value to a nanosecond value.
Definition os.h:268
Represents a command to be sent to the track driver.
Definition Packet.hxx:52