Changeset 10383


Ignore:
Timestamp:
04/18/11 11:01:41 (14 years ago)
Author:
tbretz
Message:
Added functions to signal a state change.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r10373 r10383  
    3737MessageImp::MessageImp(ostream &out) : fOut(out)
    3838{
     39}
     40
     41// --------------------------------------------------------------------------
     42//
     43//! This is a special write function formatting a string when the
     44//! state of a state machine has changed.
     45//!
     46//! If the state is <-1 nothing is done.
     47//!
     48//! Calls the virtual function IndicateStateChange
     49//!
     50//! @param time
     51//!    The time assigned to the message
     52//!
     53//! @param server
     54//!    The server name which is emitting the state change
     55//!
     56//! @param msg
     57//!    The message text
     58//!
     59//! @param state
     60//!    The new state of the system
     61//
     62void MessageImp::StateChanged(const Time &time, const string &server, const string &msg, int state)
     63{
     64    if (state<-1)
     65        return;
     66
     67    ostringstream out;
     68    out << server << ": Changed state to " << state << " '" << msg << "' received.";
     69
     70    Write(time, out.str(), MessageImp::kInfo);
     71
     72    IndicateStateChange(time, server);
    3973}
    4074
  • trunk/FACT++/src/MessageImp.h

    r10373 r10383  
    2828    MessageImp(std::ostream &out=std::cout);
    2929
     30    virtual void IndicateStateChange(const Time &time, const std::string &server) { }
     31    void StateChanged(const Time &time, const std::string &server, const std::string &msg, int state);
    3032    virtual int Write(const Time &time, const std::string &txt, int qos=kInfo);
    3133
Note: See TracChangeset for help on using the changeset viewer.