Ignore:
Timestamp:
04/07/11 08:42:34 (14 years ago)
Author:
tbretz
Message:
AddTransitions and AddConfiguration now return a reference; AddStateName now accepts also an explanatory string; Added GetStateDesc to retrieve this string
File:
1 edited

Legend:

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

    r10289 r10294  
    472472//!    received commands is properly extracted. No check is done.
    473473//
    474 EventImp *StateMachineImp::AddTransition(int targetstate, const char *name, const char *states, const char *fmt)
     474EventImp &StateMachineImp::AddTransition(int targetstate, const char *name, const char *states, const char *fmt)
    475475{
    476476    EventImp *evt = CreateEvent(targetstate, name, fmt);
     
    483483    fListOfEvents.push_back(evt);
    484484
    485     return evt;
     485    return *evt;
    486486}
    487487
     
    507507//!    by this command.
    508508//
    509 EventImp *StateMachineImp::AddTransition(int targetstate, const char *name, int s1, int s2, int s3, int s4, int s5)
     509EventImp &StateMachineImp::AddTransition(int targetstate, const char *name, int s1, int s2, int s3, int s4, int s5)
    510510{
    511511    return AddTransition(targetstate, name, Form("%d %d %d %d %d", s1, s2, s3, s4, s5).c_str(), "");
     
    539539//!    by this command.
    540540//
    541 EventImp *StateMachineImp::AddTransition(int targetstate, const char *name, const char *fmt, int s1, int s2, int s3, int s4, int s5)
     541EventImp &StateMachineImp::AddTransition(int targetstate, const char *name, const char *fmt, int s1, int s2, int s3, int s4, int s5)
    542542{
    543543    return AddTransition(targetstate, name, Form("%d %d %d %d %d", s1, s2, s3, s4, s5).c_str(), fmt);
     
    566566//!    received commands is properly extracted. No check is done.
    567567//!
    568 EventImp *StateMachineImp::AddConfiguration(const char *name, const char *states, const char *fmt)
     568EventImp &StateMachineImp::AddConfiguration(const char *name, const char *states, const char *fmt)
    569569{
    570570    return AddTransition(-1, name, states, fmt);
     
    587587//!    by this command.
    588588//
    589 EventImp *StateMachineImp::AddConfiguration(const char *name, int s1, int s2, int s3, int s4, int s5)
     589EventImp &StateMachineImp::AddConfiguration(const char *name, int s1, int s2, int s3, int s4, int s5)
    590590{
    591591    return AddTransition(-1, name, s1, s2, s3, s4, s5);
     
    614614//!    by this command.
    615615//
    616 EventImp *StateMachineImp::AddConfiguration(const char *name, const char *fmt, int s1, int s2, int s3, int s4, int s5)
     616EventImp &StateMachineImp::AddConfiguration(const char *name, const char *fmt, int s1, int s2, int s3, int s4, int s5)
    617617{
    618618    return AddTransition(-1, name, fmt, s1, s2, s3, s4, s5);
     
    634634//! @todo  FIX THE DOCU
    635635//
    636 void StateMachineImp::AddStateName(const int state, const std::string &name)
    637 {
    638     if (fStateNames[state].empty())
    639         fStateNames[state] = name;
     636void StateMachineImp::AddStateName(const int state, const std::string &name, const std::string &doc)
     637{
     638    if (fStateNames[state].first.empty())
     639        fStateNames[state] = make_pair(name, doc);
    640640}
    641641
     
    652652const string StateMachineImp::GetStateName(int state) /*const*/
    653653{
    654     const string &str = fStateNames[state];
     654    const string &str = fStateNames[state].first;
    655655    return str.empty() ? Form("%d", state) : str;
     656}
     657
     658const string StateMachineImp::GetStateDoc(int state) /*const*/
     659{
     660    return fStateNames[state].second;
    656661}
    657662
     
    673678const string StateMachineImp::GetStateDescription(int state) /*const*/
    674679{
    675     const string &str = fStateNames[state];
     680    const string &str = GetStateName(state);
    676681    return str.empty() ? Form("%d", state) : (str+Form("[%d]", state));
    677682}
Note: See TracChangeset for help on using the changeset viewer.