Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
SimpleUpdateLoop.hxx
1
36#ifndef _DCC_SIMPLEUPDATELOOP_HXX_
37#define _DCC_SIMPLEUPDATELOOP_HXX_
38
39#include <algorithm>
40
41#include "dcc/UpdateLoop.hxx"
43
44namespace dcc
45{
46
61class SimpleUpdateLoop : public StateFlow<Buffer<dcc::Packet>, QList<1>>,
62 private UpdateLoopBase
63{
64public:
65 SimpleUpdateLoop(Service *service, TrackIf *track_send);
67
70 dcc::PacketSource *source, unsigned priority) OVERRIDE
71 {
73 AtomicHolder h(this);
74 refreshSources_.push_back(source);
75 return true;
76 }
77
80 {
81 AtomicHolder h(this);
82 refreshSources_.erase(
83 remove(refreshSources_.begin(), refreshSources_.end(), source),
84 refreshSources_.end());
85 }
86
88 void notify_update(PacketSource *source, unsigned code) OVERRIDE
89 {
90 }
91
92 // Entry to the state flow -- when a new packet needs to be sent.
94
95private:
96 // Place where we forward the packets filled in.
97 TrackIf *trackSend_;
98
99 // Packet sources to ask about refreshing data periodically.
100 vector<dcc::PacketSource *> refreshSources_;
101
106};
107}
108
109#endif // _DCC_SIMPLEUPDATELOOP_HXX_
See OSMutexLock in os/OS.hxx.
Definition Atomic.hxx:153
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.
Abstract class for streams of DCC packets.
Implementation of a command station update loop.
size_t nextRefreshIndex_
Offset in the refreshSources_ vector for the next loco to send.
bool add_refresh_source(dcc::PacketSource *source, unsigned priority) OVERRIDE
Adds a new refresh source to the background refresh packets.
void notify_update(PacketSource *source, unsigned code) OVERRIDE
We ignore notifications.
void remove_refresh_source(dcc::PacketSource *source) OVERRIDE
Deletes a packet refresh source.
long long lastCycleStart_
os time for the last time we sent a packet for loco zero.
Action entry() OVERRIDE
Entry into the StateFlow activity.
Base class for implementing update loops.
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
Definition macros.h:180