util/cluster/RouteInfo.cpp

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 Name:      RouteInfo.cpp
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 ------------------------------------------------------------------------------*/
00006 
00007 #include <util/cluster/RouteInfo.h>
00008 #include <util/lexical_cast.h>
00009 #include <util/Global.h>
00010 
00011 
00012 
00013 using namespace org::xmlBlaster::util;
00014 using namespace std;
00015 
00016 namespace org { namespace xmlBlaster { namespace util { namespace cluster {
00017 
00018 RouteInfo::RouteInfo(Global& global) : nodeId_(global, "")
00019 {
00020    stratum_   = 0;
00021    timestamp_ = 0;
00022    dirtyRead_ = false;
00023 }
00024 
00025 
00026 RouteInfo::RouteInfo(const NodeId& nodeId, int stratum, Timestamp timestamp)
00027 : nodeId_(nodeId)
00028 {
00029   stratum_   = stratum;
00030   timestamp_ = timestamp;
00031   dirtyRead_  = false; //  = NodeDomainInfo.DEFAULT_dirtyRead
00032 }
00033 
00034 void RouteInfo::setNodeId(const NodeId& nodeId)
00035 {
00036    nodeId_ = nodeId;
00037 }
00038 
00039 NodeId RouteInfo::getNodeId() const
00040 {
00041    return nodeId_;
00042 }
00043 
00044 string RouteInfo::getId() const
00045 {
00046    return nodeId_.getId();
00047 }
00048 
00049 void RouteInfo::setStratum(int stratum)
00050 {
00051    stratum_ = stratum;
00052 }
00053 
00054 int RouteInfo::getStratum() const
00055 {
00056    return stratum_;
00057 }
00058 
00059 void RouteInfo::setTimestamp(Timestamp timestamp)
00060 {
00061    timestamp_ = timestamp;
00062 }
00063 
00064 Timestamp RouteInfo::getTimestamp() const
00065 {
00066    return timestamp_;
00067 }
00068 
00069 void RouteInfo::setDirtyRead(bool dirtyRead)
00070 {
00071    dirtyRead_ = dirtyRead;
00072 }
00073 
00074 bool RouteInfo::getDirtyRead() const
00075 {
00076    return dirtyRead_;
00077 }
00078 
00079 string RouteInfo::toXml(const string& extraOffset) const
00080 {
00081    string ret;
00082    string offset = "\n ";
00083    offset += extraOffset;
00084 
00085    ret += offset + " <node id='" + getNodeId().toString();
00086    ret += "' stratum='" + lexical_cast<std::string>(getStratum());
00087    ret += "' timestamp='"+ lexical_cast<std::string>(getTimestamp()) + "'";
00088       //if (dirtyRead != NodeDomainInfo.DEFAULT_dirtyRead)
00089    ret += " dirtyRead='" + lexical_cast<std::string>(dirtyRead_) + "'";
00090    ret += "/>";
00091    return ret;
00092 }
00093 
00094 }}}}
00095