Changeset 10294 for trunk/FACT++/src
- Timestamp:
- 04/07/11 08:42:34 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/StateMachineImp.cc
r10289 r10294 472 472 //! received commands is properly extracted. No check is done. 473 473 // 474 EventImp *StateMachineImp::AddTransition(int targetstate, const char *name, const char *states, const char *fmt)474 EventImp &StateMachineImp::AddTransition(int targetstate, const char *name, const char *states, const char *fmt) 475 475 { 476 476 EventImp *evt = CreateEvent(targetstate, name, fmt); … … 483 483 fListOfEvents.push_back(evt); 484 484 485 return evt;485 return *evt; 486 486 } 487 487 … … 507 507 //! by this command. 508 508 // 509 EventImp *StateMachineImp::AddTransition(int targetstate, const char *name, int s1, int s2, int s3, int s4, int s5)509 EventImp &StateMachineImp::AddTransition(int targetstate, const char *name, int s1, int s2, int s3, int s4, int s5) 510 510 { 511 511 return AddTransition(targetstate, name, Form("%d %d %d %d %d", s1, s2, s3, s4, s5).c_str(), ""); … … 539 539 //! by this command. 540 540 // 541 EventImp *StateMachineImp::AddTransition(int targetstate, const char *name, const char *fmt, int s1, int s2, int s3, int s4, int s5)541 EventImp &StateMachineImp::AddTransition(int targetstate, const char *name, const char *fmt, int s1, int s2, int s3, int s4, int s5) 542 542 { 543 543 return AddTransition(targetstate, name, Form("%d %d %d %d %d", s1, s2, s3, s4, s5).c_str(), fmt); … … 566 566 //! received commands is properly extracted. No check is done. 567 567 //! 568 EventImp *StateMachineImp::AddConfiguration(const char *name, const char *states, const char *fmt)568 EventImp &StateMachineImp::AddConfiguration(const char *name, const char *states, const char *fmt) 569 569 { 570 570 return AddTransition(-1, name, states, fmt); … … 587 587 //! by this command. 588 588 // 589 EventImp *StateMachineImp::AddConfiguration(const char *name, int s1, int s2, int s3, int s4, int s5)589 EventImp &StateMachineImp::AddConfiguration(const char *name, int s1, int s2, int s3, int s4, int s5) 590 590 { 591 591 return AddTransition(-1, name, s1, s2, s3, s4, s5); … … 614 614 //! by this command. 615 615 // 616 EventImp *StateMachineImp::AddConfiguration(const char *name, const char *fmt, int s1, int s2, int s3, int s4, int s5)616 EventImp &StateMachineImp::AddConfiguration(const char *name, const char *fmt, int s1, int s2, int s3, int s4, int s5) 617 617 { 618 618 return AddTransition(-1, name, fmt, s1, s2, s3, s4, s5); … … 634 634 //! @todo FIX THE DOCU 635 635 // 636 void StateMachineImp::AddStateName(const int state, const std::string &name )637 { 638 if (fStateNames[state]. empty())639 fStateNames[state] = name;636 void 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); 640 640 } 641 641 … … 652 652 const string StateMachineImp::GetStateName(int state) /*const*/ 653 653 { 654 const string &str = fStateNames[state] ;654 const string &str = fStateNames[state].first; 655 655 return str.empty() ? Form("%d", state) : str; 656 } 657 658 const string StateMachineImp::GetStateDoc(int state) /*const*/ 659 { 660 return fStateNames[state].second; 656 661 } 657 662 … … 673 678 const string StateMachineImp::GetStateDescription(int state) /*const*/ 674 679 { 675 const string &str = fStateNames[state];680 const string &str = GetStateName(state); 676 681 return str.empty() ? Form("%d", state) : (str+Form("[%d]", state)); 677 682 } -
trunk/FACT++/src/StateMachineImp.h
r10276 r10294 32 32 33 33 /// Human readable names associated with the states 34 std::map<const int, std:: string> fStateNames;34 std::map<const int, std::pair<std::string, std::string>> fStateNames; 35 35 36 36 std::vector<EventImp*> fListOfEvents; /// List of available commands as setup by user … … 70 70 virtual std::string SetCurrentState(int state, const char *txt="", const std::string &cmd=""); 71 71 72 EventImp *AddTransition(int targetstate, const char *name, const char *states, const char *fmt);73 EventImp *AddTransition(int targetstate, const char *name, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1);74 EventImp *AddTransition(int targetstate, const char *name, const char *fmt, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1);75 76 EventImp *AddConfiguration(const char *name, const char *states, const char *fmt);77 EventImp *AddConfiguration(const char *name, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1);78 EventImp *AddConfiguration(const char *name, const char *fmt, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1);79 80 void AddStateName(const int state, const std::string &name );72 EventImp &AddTransition(int targetstate, const char *name, const char *states, const char *fmt); 73 EventImp &AddTransition(int targetstate, const char *name, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1); 74 EventImp &AddTransition(int targetstate, const char *name, const char *fmt, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1); 75 76 EventImp &AddConfiguration(const char *name, const char *states, const char *fmt); 77 EventImp &AddConfiguration(const char *name, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1); 78 EventImp &AddConfiguration(const char *name, const char *fmt, int s1=-1, int s2=-1, int s3=-1, int s4=-1, int s5=-1); 79 80 void AddStateName(const int state, const std::string &name, const std::string &doc=""); 81 81 82 82 public: … … 123 123 const std::string GetStateName(int state) /*const*/; 124 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); } 125 128 126 129 const std::string GetStateDescription(int state) /*const*/;
Note:
See TracChangeset
for help on using the changeset viewer.