FACT++  1.0
bool StateMachineImp::PostEvent ( const EventImp evt)

With this function commands are posted to the event queue. If the event loop has not yet been started with Run() the command is directly handled by HandleEvent.

Events posted when the state machine is in a negative state or kSM_FatalError are ignored.

Parameters
evtThe event to be posted. The precise contents depend on what the event should be for.
Returns
false if the event is ignored, true otherwise.
Todo:
  • Shell we check for the validity of a command at the current state, too?
  • should we also get the output stream as an argument here?

Definition at line 343 of file StateMachineImp.cc.

References fBufferEvents, GetCurrentState(), HandleEvent(), IsRunning(), kSM_FatalError, kYellow, MessageImp::Out(), and PushEvent().

344 {
345  if (/*GetCurrentState()<0 ||*/ GetCurrentState()==kSM_FatalError)
346  {
347  Out() << kYellow << "State<0 or FatalError: Event ignored." << endl;
348  return false;
349  }
350 
351  if (IsRunning() || fBufferEvents)
352  PushEvent(new Event(evt));
353  else
354  {
355  // FIXME: Is this thread safe? (Yes, because it is only used
356  // by Dim and this is thread safe) But two handlers could
357  // be called at the same time. Do we need to lock the handlers?
358  HandleEvent(evt);
359  }
360  return true;
361 }
int GetCurrentState() const
return the current state of the machine
Fatal error: stop program.
Set color Yellow.
Definition: WindowLog.h:19
bool HandleEvent(const EventImp &evt)
std::ostream & Out() const
Definition: MessageImp.h:73
virtual void PushEvent(Event *cmd)
This is a flag which is set true if the main loop should stop.
Concerete implementation of an EventImp stroring name, format, data and time.
Definition: Event.h:6
bool IsRunning() const
Used to check if the main loop is already running or still running.
bool fBufferEvents
Conditional to signal run the an event is waiting.

+ Here is the call graph for this function: