1 /*------------------------------------------------------------------------------
 2 Name:      RouteInfo.cpp
 3 Project:   xmlBlaster.org
 4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
 5 ------------------------------------------------------------------------------*/
 6 
 7 #include <util/cluster/RouteInfo.h>
 8 #include <util/lexical_cast.h>
 9 #include <util/Global.h>
10 
11 
12 
13 using namespace org::xmlBlaster::util;
14 using namespace std;
15 
16 namespace org { namespace xmlBlaster { namespace util { namespace cluster {
17 
18 RouteInfo::RouteInfo(Global& global) : nodeId_(global, "")
19 {
20    stratum_   = 0;
21    timestamp_ = 0;
22    dirtyRead_ = false;
23 }
24 
25 
26 RouteInfo::RouteInfo(const NodeId& nodeId, int stratum, Timestamp timestamp)
27 : nodeId_(nodeId)
28 {
29   stratum_   = stratum;
30   timestamp_ = timestamp;
31   dirtyRead_  = false; //  = NodeDomainInfo.DEFAULT_dirtyRead
32 }
33 
34 void RouteInfo::setNodeId(const NodeId& nodeId)
35 {
36    nodeId_ = nodeId;
37 }
38 
39 NodeId RouteInfo::getNodeId() const
40 {
41    return nodeId_;
42 }
43 
44 string RouteInfo::getId() const
45 {
46    return nodeId_.getId();
47 }
48 
49 void RouteInfo::setStratum(int stratum)
50 {
51    stratum_ = stratum;
52 }
53 
54 int RouteInfo::getStratum() const
55 {
56    return stratum_;
57 }
58 
59 void RouteInfo::setTimestamp(Timestamp timestamp)
60 {
61    timestamp_ = timestamp;
62 }
63 
64 Timestamp RouteInfo::getTimestamp() const
65 {
66    return timestamp_;
67 }
68 
69 void RouteInfo::setDirtyRead(bool dirtyRead)
70 {
71    dirtyRead_ = dirtyRead;
72 }
73 
74 bool RouteInfo::getDirtyRead() const
75 {
76    return dirtyRead_;
77 }
78 
79 string RouteInfo::toXml(const string& extraOffset) const
80 {
81    string ret;
82    string offset = "\n ";
83    offset += extraOffset;
84 
85    ret += offset + " <node id='" + getNodeId().toString();
86    ret += "' stratum='" + lexical_cast<std::string>(getStratum());
87    ret += "' timestamp='"+ lexical_cast<std::string>(getTimestamp()) + "'";
88       //if (dirtyRead != NodeDomainInfo.DEFAULT_dirtyRead)
89    ret += " dirtyRead='" + lexical_cast<std::string>(dirtyRead_) + "'";
90    ret += "/>";
91    return ret;
92 }
93 
94 }}}}


syntax highlighted by Code2HTML, v. 0.9.1