1 /*------------------------------------------------------------------------------
2 Name: StatusQosData.h
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 ------------------------------------------------------------------------------*/
6
7 /**
8 * Data container handling of status returned by subscribe(), unSubscribe(), erase() and ping().
9 * <p>
10 * This data holder is accessible through decorators, each of them allowing a specialized view on the data:
11 * </p>
12 * <ul>
13 * <li>SubscribeReturnQos Returned QoS of a subscribe() invocation (Client side)</i>
14 * <li>UnSubscribeReturnQos Returned QoS of a unSubscribe() invocation (Client side)</i>
15 * <li>EraseReturnQos Returned QoS of an erase() invocation (Client side)</i>
16 * </ul>
17 * <p>
18 * For the xml representation see StatusQosSaxFactory.
19 * </p>
20 * @see org.xmlBlaster.util.qos.StatusQosSaxFactory
21 * @see org.xmlBlaster.test.classtest.qos.StatusQosFactoryTest
22 * @author xmlBlaster@marcelruff.info
23 * @author laghi@swissinfo.org
24 */
25
26 #ifndef _UTIL_QOS_STATUSQOSDATA_H
27 #define _UTIL_QOS_STATUSQOSDATA_H
28
29 #include <util/xmlBlasterDef.h>
30 #include <util/Constants.h>
31 #include <string>
32
33
34 namespace org { namespace xmlBlaster { namespace util { namespace qos {
35
36 class Dll_Export StatusQosData
37 {
38 private:
39 std::string ME;
40 org::xmlBlaster::util::Global& global_;
41
42 /** the state of the message, defaults to "OK" if no state is returned */
43 std::string state_; // = Constants::STATE_OK;
44 std::string stateInfo_;
45
46 /** The subscription ID of a subscribe() invocation */
47 std::string subscriptionId_;
48
49 /** The key oid of a publish(), helpful if the oid was generated by xmlBlaster */
50 std::string keyOid_;
51
52 bool persistent_; // = DEFAULT_persistent;
53
54 /**
55 * The receive timestamp (UTC time),
56 * when message arrived in requestBroker.publish() method.<br />
57 * In nanoseconds elapsed since midnight, January 1, 1970 UTC
58 */
59 Timestamp rcvTimestamp_;
60
61 void copy(const StatusQosData& data);
62
63 public:
64
65 /**
66 * Constructs the specialized quality of service object for status informations,
67 * e.g. for a return of a subscribe() call
68 * <p>
69 * The state defaults to Constants::STATE_OK
70 * </p>
71 * @param The factory which knows how to serialize and parse me
72 */
73 StatusQosData(org::xmlBlaster::util::Global& global);
74
75 StatusQosData(const StatusQosData& data);
76
77 StatusQosData operator =(const StatusQosData& data);
78
79 /**
80 * @param state The state of an update message. See Constants::java
81 */
82 void setState(const std::string& state);
83
84 /**
85 * Access state of message on update().
86 * @return "OK", "ERROR" etc. See Constants::java
87 */
88 std::string getState() const;
89
90 /**
91 * True if the message is OK on update().
92 */
93 bool isOk() const;
94
95 /**
96 * True if the message was erased by timer or by a
97 * client invoking erase().
98 */
99 bool isErased() const;
100
101 /**
102 * True if a timeout on this message occurred.
103 * <p />
104 * Timeouts are spanned by the publisher and thrown by xmlBlaster
105 * on timeout to indicate for example
106 * STALE messages or any other user problem domain specific event.
107 */
108 bool isTimeout() const;
109
110 /**
111 * True on cluster forward problems
112 */
113 bool isForwardError() const;
114
115 /**
116 * @param state The human readable state text of an update message
117 */
118 void setStateInfo(const std::string& stateInfo);
119
120 /**
121 * Access state of message on update().
122 * @return The human readable info text
123 */
124 std::string getStateInfo() const;
125
126 /**
127 * If Pub/Sub style update: contains the subscribe ID which caused this update
128 * @param subscriptionId null if PtP message
129 */
130 void setSubscriptionId(const std::string& subscriptionId);
131
132 /**
133 * If Pub/Sub style update: contains the subscribe ID which caused this update
134 * @return subscribeId or null if PtP message
135 */
136 std::string getSubscriptionId() const;
137
138 /**
139 * Access key oid.
140 * @return The unique identifier of a message
141 */
142 std::string getKeyOid() const;
143
144 /**
145 * Access unique oid of a message topic.
146 */
147 void setKeyOid(const std::string& oid);
148
149 /**
150 * The size in bytes of the data in XML form.
151 */
152 int size() const;
153
154 /**
155 * Dump state of this object into a XML ASCII std::string.
156 * <br>
157 * @param extraOffset indenting of tags for nice output
158 * @return internal state of the status as a XML ASCII std::string
159 */
160 std::string toXml(const std::string& extraOffset="") const;
161
162 /**
163 * The approximate receive timestamp (UTC time),
164 * when message arrived in requestBroker.publish() method.<br />
165 * In milliseconds elapsed since midnight, January 1, 1970 UTC
166 */
167 void setRcvTimestamp(Timestamp rcvTimestamp);
168
169 /**
170 * The approximate receive timestamp (UTC time),
171 * when message arrived in requestBroker.publish() method.<br />
172 * In milliseconds elapsed since midnight, January 1, 1970 UTC
173 */
174 Timestamp getRcvTimestamp() const;
175
176 /**
177 * Set timestamp to current time.
178 */
179 void touchRcvTimestamp();
180
181 /**
182 * @param persistent mark a message as persistent
183 */
184 void setPersistent(bool persistent);
185
186 /**
187 * @return true/false
188 */
189 bool isPersistent() const;
190 };
191
192 }}}} // namespace
193
194 #endif
syntax highlighted by Code2HTML, v. 0.9.1