Changeset 10385


Ignore:
Timestamp:
Apr 18, 2011, 1:56:53 PM (9 years ago)
Author:
tbretz
Message:
Moved setting of default states to a protected memeber function; made AddStateName virtual to allow StateMachineDim to overwrite it; changed color in PrintStateNames
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/StateMachineImp.cc

    r10370 r10385  
    124124    fRunning(false), fExitRequested(0)
    125125{
    126     AddStateName(kSM_NotReady,   "NotReady", "State machine not ready, events are ignored.");
    127     AddStateName(kSM_Ready,      "Ready",    "State machine ready to receive events.");
    128     AddStateName(kSM_Error,      "ERROR",    "Common error state.");
    129     AddStateName(kSM_FatalError, "FATAL",    "A fatal error occured, the eventloop is stopped.");
     126    SetDefaultStateNames();
    130127}
    131128
     
    150147// --------------------------------------------------------------------------
    151148//
     149//! Sets the default state names. This function should be called in
     150//! derived classes again if they overwrite SetStateName().
     151//
     152void StateMachineImp::SetDefaultStateNames()
     153{
     154    AddStateName(kSM_NotReady,   "NotReady", "State machine not ready, events are ignored.");
     155    AddStateName(kSM_Ready,      "Ready",    "State machine ready to receive events.");
     156    AddStateName(kSM_Error,      "ERROR",    "Common error state.");
     157    AddStateName(kSM_FatalError, "FATAL",    "A fatal error occured, the eventloop is stopped.");
     158}
     159
     160// --------------------------------------------------------------------------
     161//
    152162//! Puts the given event into the fifo. The fifo will take over ownership.
    153163//! Access to fEventQueue is encapsulated by fMutex.
     
    400410    out << endl;
    401411    for (StateNames::const_iterator i=fStateNames.begin(); i!=fStateNames.end(); i++)
    402         out << kBold << setw(5) << i->first << kReset << " - " << kBold << i->second.first << kReset << ": " << i->second.second << endl;
     412        out << kBold << setw(5) << i->first << kReset << ": " << kYellow << i->second.first << kBlue << " (" << i->second.second << ")" << endl;
    403413    out << endl;
    404414}
     
    659669//! readable for to the user, a string can be assigned to each state.
    660670//! For each state this function can be called only once, i.e. state name
    661 //! cannot be overwritten. Negative states are ignore.d
     671//! cannot be overwritten.
     672//!
     673//! Be aware that two states should not have the same name!
    662674//!
    663675//! @param state
     
    670682//!    A explanatory text describing the state
    671683//!
    672 //! @todo  FIX THE DOCU
    673 //
    674684void StateMachineImp::AddStateName(const int state, const std::string &name, const std::string &doc)
    675685{
  • trunk/FACT++/src/StateMachineImp.h

    r10344 r10385  
    8080    EventImp &AddConfiguration(const char *name, const char *fmt, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1);
    8181
    82     void AddStateName(const int state, const std::string &name, const std::string &doc="");
     82    virtual void AddStateName(const int state, const std::string &name, const std::string &doc="");
     83
     84    void SetDefaultStateNames();
    8385
    8486public:
Note: See TracChangeset for help on using the changeset viewer.