Changeset 10314


Ignore:
Timestamp:
Apr 7, 2011, 4:38:02 PM (9 years ago)
Author:
tbretz
Message:
Added descriptions for the default states; added PrintListOfStates member function.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r10309 r10314  
    124124    fRunning(false), fExitRequested(0)
    125125{
    126     AddStateName(kSM_NotReady,   "NotReady");
    127     AddStateName(kSM_Ready,      "Ready");
    128     AddStateName(kSM_Error,      "ERROR");
    129     AddStateName(kSM_FatalError, "FATAL");
     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.");
    130130}
    131131
     
    363363//!    ostream to which the output should be redirected
    364364//
    365 void StateMachineImp::PrintListOfEvents(std::ostream &out)
    366 {
    367     for (vector<EventImp*>::iterator c=fListOfEvents.begin(); c!=fListOfEvents.end(); c++)
     365void StateMachineImp::PrintListOfEvents(std::ostream &out) const
     366{
     367    for (vector<EventImp*>::const_iterator c=fListOfEvents.begin(); c!=fListOfEvents.end(); c++)
    368368        (*c)->Print(out);
    369369}
     
    373373//! Call PrintListOfEvents with fOut as the output stream
    374374//
    375 void StateMachineImp::PrintListOfEvents()
     375void StateMachineImp::PrintListOfEvents() const
    376376{
    377377    PrintListOfEvents(Out());
     378}
     379
     380// --------------------------------------------------------------------------
     381//
     382//! Print a list of all states with descriptions.
     383//!
     384//! @param out
     385//!    ostream to which the output should be redirected
     386//
     387void StateMachineImp::PrintListOfStates(std::ostream &out) const
     388{
     389    out << endl;
     390    out << kBold << "List of available states:" << endl;
     391    out << endl;
     392    for (StateNames::const_iterator i=fStateNames.begin(); i!=fStateNames.end(); i++)
     393        out << kBold << setw(5) << i->first << kReset << " - " << kBold << i->second.first << kReset << ": " << i->second.second << endl;
     394    out << endl;
     395}
     396
     397// --------------------------------------------------------------------------
     398//
     399//! Print a list of all states with descriptions.
     400//
     401void StateMachineImp::PrintListOfStates() const
     402{
     403    PrintListOfStates(Out());
    378404}
    379405
     
    689715{
    690716    const string &str = GetStateName(state);
     717    if (str==Form("%d", state))
     718        return str;
    691719    return str.empty() ? Form("%d", state) : (str+Form("[%d]", state));
    692720}
  • trunk/FACT++/src/StateMachineImp.h

    r10309 r10314  
    119119    const std::vector<std::string> GetEventNames() const;
    120120
    121     void PrintListOfEvents(std::ostream &out);
    122     void PrintListOfEvents();
     121    void PrintListOfEvents(std::ostream &out) const;
     122    void PrintListOfEvents() const;
     123
     124    void PrintListOfStates(std::ostream &out) const;
     125    void PrintListOfStates() const;
    123126
    124127
Note: See TracChangeset for help on using the changeset viewer.