Changeset 10373 for trunk


Ignore:
Timestamp:
04/15/11 23:03:39 (13 years ago)
Author:
tbretz
Message:
Changed basis of MessageImp::Write function from const char* to std::string& to be able to boost::bind the function, because boost::bind will hold an internal copy of the string.
Location:
trunk/FACT++/src
Files:
7 edited

Legend:

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

    r10284 r10373  
    2323    // -------- Abbreviations for starting async tasks ---------
    2424
    25 int Connection::Write(const Time &t, const char *txt, int qos)
     25int Connection::Write(const Time &t, const string &txt, int qos)
    2626{
    2727    if (fLog)
  • trunk/FACT++/src/Connection.h

    r10284 r10373  
    6161    void HandleSentData(const boost::system::error_code& error, size_t);
    6262
    63     int Write(const Time &t, const char *txt, int qos=kInfo);
     63    int Write(const Time &t, const std::string &txt, int qos=kInfo);
    6464
    6565    virtual void ConnectionEstablished() { }
  • trunk/FACT++/src/MessageDim.cc

    r10274 r10373  
    6262//! transmitted messages.
    6363//
    64 int MessageDimTX::Write(const Time &t, const char *txt, int qos)
     64int MessageDimTX::Write(const Time &t, const string &txt, int qos)
    6565{
    6666    MessageImp::Write(t, txt, qos);
     
    6969    // hold a local copy of the data.
    7070    setQuality(qos);
    71     setData(const_cast<char*>(txt));
     71    setData(const_cast<char*>(txt.c_str()));
    7272    const int rc = updateService();
    7373
     
    112112MessageDimRX::MessageDimRX(const std::string &name, MessageImp &imp)
    113113: fMsg(imp),
    114 fDimMessage(Form("%s/MESSAGE", name.c_str()).c_str(), const_cast<char*>(""), this)
     114fDimMessage(Form("%s/MESSAGE", name.c_str()).c_str(), const_cast<char*>(""), this),
     115fConnected(false)
    115116{
    116117    fMinLogLevel = 0;
     
    129130
    130131    // The server is diconnected. Do nothing
    131     if (getInfo()->getTimestamp()==0)
     132    if (getInfo()->getTimestamp()==0 || getInfo()->getSize()==1)
    132133    {
     134        fConnected=false;
    133135        fMsg.Message("Disconnected.");
    134136        return;
    135137    }
     138
     139    fConnected=true;
    136140
    137141    // skip all messages with a severity smaller than the minimum log level
  • trunk/FACT++/src/MessageDim.h

    r10274 r10373  
    1717    ~MessageDimTX();
    1818
    19     int Write(const Time &t, const char *txt, int qos=kInfo);
     19    int Write(const Time &t, const std::string &txt, int qos=kInfo);
    2020
    2121    void SetDebug(bool b=true) { fDebug=b; }
     
    3434    DimStampedInfo fDimMessage;
    3535
    36     int fMinLogLevel;
     36    int  fMinLogLevel;
     37    bool fConnected;
    3738
    3839protected:
     
    4344
    4445    void SetMinLogLevel(int min=0) { fMinLogLevel=min; }
     46    bool IsConnected() const { return fConnected; }
    4547};
    4648
  • trunk/FACT++/src/MessageImp.cc

    r10320 r10373  
    6969//!    The severity of the message
    7070//
    71 int MessageImp::Write(const Time &time, const char *txt, int severity)
     71int MessageImp::Write(const Time &time, const string &txt, int severity)
    7272{
    7373    switch (severity)
     
    9696//!    The severity of the message to be passed to Write
    9797//
    98 int MessageImp::Update(const char *txt, int severity)
     98int MessageImp::Update(const string &txt, int severity)
    9999{
    100100    Write(Time(), txt, severity);
  • trunk/FACT++/src/MessageImp.h

    r10315 r10373  
    2828    MessageImp(std::ostream &out=std::cout);
    2929
    30     virtual int Write(const Time &time, const char *txt, int qos=kInfo);
     30    virtual int Write(const Time &time, const std::string &txt, int qos=kInfo);
    3131
    32     int Update(const char *txt, int qos=kInfo);
    33     int Update(const std::string &str, int qos=kInfo) { return Update(str.c_str(), qos); }
     32    int Update(const std::string &str, int qos=kInfo);
     33    int Update(const char *txt, int qos=kInfo) { return Update(std::string(txt), qos); }
    3434    int Update(const std::stringstream &str, int qos=kInfo) { return Update(str.str(), qos); }
    3535    int Update(int qos, const char *fmt, ...);
    3636
    37     int Debug(const char *txt)   { return Update(txt, kDebug); }
    38     int Message(const char *txt) { return Update(txt, kMessage); }
    39     int Info(const char *txt)    { return Update(txt, kInfo);    }
    40     int Warn(const char *txt)    { return Update(txt, kWarn);    }
    41     int Error(const char *txt)   { return Update(txt, kError);   }
    42     int Fatal(const char *txt)   { return Update(txt, kFatal);   }
     37    int Debug(const std::string &str)    { return Update(str, kDebug);  }
     38    int Message(const std::string &str)  { return Update(str, kMessage); }
     39    int Info(const std::string &str)     { return Update(str, kInfo);    }
     40    int Warn(const std::string &str)     { return Update(str, kWarn);    }
     41    int Error(const std::string &str)    { return Update(str, kError);   }
     42    int Fatal(const std::string &str)    { return Update(str, kFatal);   }
    4343
    44     int Debug(const std::string &str)   { return Debug(str.c_str()); }
    45     int Message(const std::string &str) { return Message(str.c_str()); }
    46     int Info(const std::string &str)    { return Info(str.c_str());    }
    47     int Warn(const std::string &str)    { return Warn(str.c_str());    }
    48     int Error(const std::string &str)   { return Error(str.c_str());   }
    49     int Fatal(const std::string &str)   { return Fatal(str.c_str());   }
     44    int Debug(const char *txt)   { return Debug(std::string(txt));  }
     45    int Message(const char *txt) { return Message(std::string(txt)); }
     46    int Info(const char *txt)    { return Info(std::string(txt));    }
     47    int Warn(const char *txt)    { return Warn(std::string(txt));    }
     48    int Error(const char *txt)   { return Error(std::string(txt));   }
     49    int Fatal(const char *txt)   { return Fatal(std::string(txt));   }
    5050
    5151    int Debug(const std::stringstream &str)   { return Debug(str.str()); }
  • trunk/FACT++/src/StateMachineDim.h

    r10183 r10373  
    4040
    4141    /// Redirect our own logging to fLog
    42     int Write(const Time &time, const char *txt, int qos);
     42    int Write(const Time &time, const std::string &txt, int qos);
    4343
    4444    /// This is an internal function to do some action in case of
Note: See TracChangeset for help on using the changeset viewer.