Changeset 10439


Ignore:
Timestamp:
Apr 21, 2011, 9:50:11 AM (9 years ago)
Author:
tbretz
Message:
Added new class DimNetworkInfo which initialized members secs and millisecs which remain uninitialized by Dim; set the default size of the nolink argument to 0, in this way we can distinguish between an empty string and nolink.
Location:
trunk/FACT++/src
Files:
4 edited

Legend:

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

    r10420 r10439  
    33StateClient::StateClient(const std::string &name, MessageImp &imp) :
    44    MessageDimRX(name, imp), fState(-2),
    5     fInfoState((name + "/STATE").c_str(), const_cast<char*>(""), this)
     5    fInfoState((name + "/STATE").c_str(), const_cast<char*>(""), 0, this)
    66{
    77}
     
    2020    if (curr==&fInfoState)
    2121    {
    22         const char *txt = fInfoState.getString();
     22        const bool disconnected = fInfoState.getSize()==0;
    2323
    24         fState     = strlen(txt)==0 ? -2 : fInfoState.getQuality();
     24        fState     = disconnected ? -2 : fInfoState.getQuality();
    2525        fStateTime = Time(fInfoState.getTimestamp(),
    2626                          fInfoState.getTimestampMillisecs()*1000);
     
    2828        const string name = fInfoState.getName();
    2929
    30         fMsg.StateChanged(fStateTime, name.substr(0, name.length()-6), txt, fState);
     30        fMsg.StateChanged(fStateTime, name.substr(0, name.length()-6),
     31                          disconnected ? "" : fInfoState.getString(), fState);
    3132
    3233        return;
  • trunk/FACT++/src/DimNetwork.h

    r10419 r10439  
    2222    int  fState;               /// -2 not initialized, -1 not connected, 0>= state of client
    2323
    24     DimStampedInfo fInfoState; /// The dim service subscription
     24    DimNetworkInfo fInfoState; /// The dim service subscription
    2525
    2626protected:
     
    3333    int  GetState() const    { return fState;    }
    3434
    35     const char *GetName() const { return const_cast<DimStampedInfo&>(fInfoState).getName(); }
     35    const char *GetName() const { return const_cast<DimNetworkInfo&>(fInfoState).getName(); }
    3636};
    3737
  • trunk/FACT++/src/MessageDim.cc

    r10422 r10439  
    112112MessageDimRX::MessageDimRX(const std::string &name, MessageImp &imp)
    113113: fMinLogLevel(0), fConnected(false), fMsg(imp),
    114 fDimMessage((name+"/MESSAGE").c_str(), const_cast<char*>(""), this)
     114fDimMessage((name+"/MESSAGE").c_str(), const_cast<char*>(""), 0, this)
    115115{
    116116}
     
    127127        return;
    128128
     129    fConnected = getInfo()->getSize()!=0;
     130
    129131    // The server is diconnected. Do nothing
    130     if (getInfo()->getTimestamp()==0 || getInfo()->getSize()==1)
     132    if (!fConnected)
    131133    {
    132         fConnected=false;
    133134        fMsg.Message("Disconnected.");
    134135        return;
    135136    }
    136 
    137     fConnected=true;
    138137
    139138    // skip all messages with a severity smaller than the minimum log level
  • trunk/FACT++/src/MessageDim.h

    r10422 r10439  
    2626#include <dic.hxx> // DimStampedInfo
    2727
     28class DimNetworkInfo : public DimStampedInfo
     29{
     30public:
     31    DimNetworkInfo(const char *name, const char *nolink, int size, DimInfoHandler *ptr)
     32        : DimStampedInfo(name, const_cast<char*>(nolink), size, ptr)
     33    {
     34        secs      = 0;
     35        millisecs = 0;
     36    }
     37};
     38
    2839class MessageDimRX : public DimInfoHandler
    2940{
     
    3647
    3748private:
    38     DimStampedInfo fDimMessage;
     49    DimNetworkInfo fDimMessage;
    3950
    4051protected:
     
    4960
    5061#endif
     62
     63// **************************************************************************
     64/** @class DimNetworkInfo
     65
     66@brief Direct derivative of DimStampedInfo
     67
     68Since secs and millisecs are not initialized in the base class
     69valgrind throws a couple of warnings debugging applications.
     70
     71This derivative just initialized them with 0. It will be removed as
     72soon as the initialization was done in Dim itself.
     73
     74**/
     75// **************************************************************************
Note: See TracChangeset for help on using the changeset viewer.