Changeset 10309 for trunk/FACT++


Ignore:
Timestamp:
04/07/11 15:46:15 (14 years ago)
Author:
tbretz
Message:
Added typedef for StateNames; changed the getter such that they can now be declared const.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r10300 r10309  
    650650//!    as string.
    651651//!
    652 const string StateMachineImp::GetStateName(int state) /*const*/
    653 {
    654     const string &str = fStateNames[state].first;
    655     return str.empty() ? Form("%d", state) : str;
     652const string StateMachineImp::GetStateName(int state) const
     653{
     654    const StateNames::const_iterator i = fStateNames.find(state);
     655    return i==fStateNames.end() || i->second.first.empty() ? Form("%d", state) : i->second.first;
    656656}
    657657
     
    666666//!    returned.
    667667//!
    668 const string StateMachineImp::GetStateDesc(int state) /*const*/
    669 {
    670     return fStateNames[state].second;
     668const string StateMachineImp::GetStateDesc(int state) const
     669{
     670    const StateNames::const_iterator i = fStateNames.find(state);
     671    return i==fStateNames.end() ? "" : i->second.second;
    671672}
    672673
     
    685686//!
    686687//
    687 const string StateMachineImp::GetStateDescription(int state) /*const*/
     688const string StateMachineImp::GetStateDescription(int state) const
    688689{
    689690    const string &str = GetStateName(state);
  • trunk/FACT++/src/StateMachineImp.h

    r10294 r10309  
    3131    int fCurrentState;   /// Current state of the state machine
    3232
     33    typedef std::map<const int, std::pair<std::string, std::string>> StateNames;
     34
    3335    /// Human readable names associated with the states
    34     std::map<const int, std::pair<std::string, std::string>> fStateNames;
     36    StateNames fStateNames;
    3537
    3638    std::vector<EventImp*> fListOfEvents; /// List of available commands as setup by user
     
    121123
    122124
    123     const std::string GetStateName(int state) /*const*/;
    124     const std::string GetStateName() { return GetStateName(fCurrentState); }
    125 
    126     const std::string GetStateDesc(int state) /*const*/;
    127     const std::string GetStateDesc() { return GetStateDesc(fCurrentState); }
    128 
    129     const std::string GetStateDescription(int state) /*const*/;
    130     const std::string GetStateDescription() { return GetStateDescription(fCurrentState); }
     125    const std::string GetStateName(int state) const;
     126    const std::string GetStateName() const { return GetStateName(fCurrentState); }
     127
     128    const std::string GetStateDesc(int state) const;
     129    const std::string GetStateDesc() const { return GetStateDesc(fCurrentState); }
     130
     131    const std::string GetStateDescription(int state) const;
     132    const std::string GetStateDescription() const { return GetStateDescription(fCurrentState); }
    131133};
    132134
Note: See TracChangeset for help on using the changeset viewer.