37#ifndef _OPENLCB_CONFIGUPDATEFLOW_HXX_
38#define _OPENLCB_CONFIGUPDATEFLOW_HXX_
43#include "openlcb/NodeInitializeFlow.hxx"
46#if OPENMRN_FEATURE_REBOOT
90 void TEST_set_fd(
int fd)
94 bool TEST_is_terminated()
98 bool TEST_get_needs_reboot()
102 bool TEST_get_needs_reinit()
123 Action call_next_listener()
135 return call_listener(l,
false);
142 DIE(
"CONFIG_FILENAME not specified, or init() was not called, but "
143 "there are configuration listeners.");
167 Action do_initial_load()
182 return call_listener(l,
true);
190#if OPENMRN_FEATURE_REBOOT
#define STATE(_fn)
Turns a function name into an argument to be supplied to functions expecting a state.
See OSMutexLock in os/OS.hxx.
Lightweight locking class for protecting small critical sections.
A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish.
BarrierNotifiable * reset(Notifiable *done)
Resets the barrier. Returns &*this. Asserts that is_done().
Abstract class for components that need to receive configuration from EEPROM.
UpdateAction
Specifies what additional steps are needed to apply the new configuration.
@ REINIT_NEEDED
Need to perform application-level reinitialization.
@ UPDATED
No additional step is necessary.
@ REBOOT_NEEDED
Need to reboot the hardware.
virtual UpdateAction apply_configuration(int fd, bool initial_load, BarrierNotifiable *done)=0
Notifies the component that there is new configuration available for loading.
Virtual interface for the config update listeners to register themselves for receiving configuration ...
STL-compatible iterator for TypedQueue.
Return type for a state flow callback.
Base class for state machines.
Service * service()
Return a pointer to the service I am bound to.
StateFlowBase()
Default constructor.
Action exit()
Terminate current StateFlow activity.
void start_flow(Callback c)
Resets the flow to the specified state and starts it.
Action wait()
Wait for an asynchronous call.
Action call_immediately(Callback c)
Imediately call the next state upon return.
bool is_state(Callback c)
A simple, fast, type-safe single-linked queue class with non-virtual methods.
T * pop_front()
Removes the entry at the front of the queue.
void push_front(T *entry)
Inserts an entry to the front of the queue.
Implementation of the ConfigUpdateService: state flow issuing all the calls to the registered ConfigU...
int open_file(const char *path)
Must be called once (only) before calling anything else.
queue_type pendingListeners_
All listeners that have not yet been added to listeners_ and their initial load needs to be called.
void trigger_update() override
Executes an update in response to the configuration having changed.
queue_type listeners_
All registered update listeners. Protected by Atomic *this.
unsigned needsReboot_
did anybody request a reboot to happen?
void init_flow()
Asynchronously invokes all update listeners with the config FD.
void register_update_listener(ConfigUpdateListener *listener) override
Adds a config update listener to be called upon configuration updates.
void unregister_update_listener(ConfigUpdateListener *listener) override
Removes a config update listener.
void factory_reset()
Synchronously invokes all update listeners to factory reset.
unsigned needsReInit_
did anybody request a node reinit to happen?
queue_type::iterator nextRefresh_
Where are we in the refresh cycle.
Abstract class representing an OpenLCB Interface.
StateFlow that iterates through all local nodes and sends out node initialization complete for each o...
#define DIE(MSG)
Unconditionally terminates the current process with a message.