Changeset 10379


Ignore:
Timestamp:
Apr 18, 2011, 10:56:51 AM (9 years ago)
Author:
tbretz
Message:
Added service to provide the STATE_LIST with the available descriptions of the states.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r10374 r10379  
    6565StateMachineDim::StateMachineDim(ostream &out, const std::string &name)
    6666: StateMachine(out, name), DimStart(name, *this), fLog(name, out),
    67 fSrvState(Form("%s/STATE", name.c_str()).c_str(), const_cast<char*>("")),
    68 fSrvVersion(Form("%s/VERSION", name.c_str()).c_str(), const_cast<int&>(fVersion))
     67    fSrvState(Form("%s/STATE", name.c_str()).c_str(), const_cast<char*>("")),
     68    fSrvVersion(Form("%s/VERSION", name.c_str()).c_str(), const_cast<int&>(fVersion)),
     69    fDescriptionStates(Form("%s/STATE_LIST", name.c_str()).c_str(), const_cast<char*>(""))
    6970{
    7071    // WARNING: This exit handler is GLOBAL!
    7172    DimServer::addExitHandler(this);
     73
     74    for (StateNames::const_iterator i=fStateNames.begin(); i!=fStateNames.end(); i++)
     75        DistStateName(i->first, i->second.first, i->second.second);
    7276}
    7377
     
    8387{
    8488    return new EventDim(targetstate, GetName()+"/"+name, fmt, this);
     89}
     90
     91void StateMachineDim::DistStateName(const int state, const std::string &name, const std::string &doc)
     92{
     93    ostringstream out;
     94    out << reinterpret_cast<char*>(fDescriptionStates.itsData);
     95    out << state << ':' << name << '=' << doc << '\n';
     96
     97    fDescriptionStates.setData(const_cast<char*>(out.str().c_str()));
     98    fDescriptionStates.updateService();
     99}
     100
     101void StateMachineDim::AddStateName(const int state, const std::string &name, const std::string &doc)
     102{
     103    StateMachineImp::AddStateName(state, name, doc);
     104    DistStateName(state, name, doc);
    85105}
    86106
  • trunk/FACT++/src/StateMachineDim.h

    r10373 r10379  
    3333    static const int fVersion;   /// Version number
    3434
    35     DimService fSrvState;        /// DimService offering fCurrentState
    36     DimService fSrvVersion;      /// DimService offering fVersion
     35    DimService fSrvState;          /// DimService offering fCurrentState
     36    DimService fSrvVersion;        /// DimService offering fVersion
     37
     38    DimService fDescriptionStates; /// DimService propagating the state descriptions
    3739
    3840    void exitHandler(int code);  /// Overwritten DimCommand::exitHandler.
     
    5052public:
    5153    StateMachineDim(std::ostream &out=std::cout, const std::string &name="DEFAULT");
     54
     55    void AddStateName(const int state, const std::string &name, const std::string &doc="");
     56    void DistStateName(const int state, const std::string &name, const std::string &doc="");
    5257};
    5358
Note: See TracChangeset for help on using the changeset viewer.