1 /*------------------------------------------------------------------------------
  2 Name:      GetReturnQos.h
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 ------------------------------------------------------------------------------*/
  6 
  7 /**
  8  * QoS (quality of service) informations sent from server to client<br />
  9  * via the return value of the get() method. 
 10  * <p />
 11  * If you are a Java client you may use this class to parse the QoS argument.
 12  * <p />
 13  * Example:
 14  * <pre>
 15  *   &lt;qos> &lt;!-- GetReturnQos -->
 16  *     &lt;state id='OK'/>
 17  *     &lt;sender>Tim&lt;/sender>
 18  *     &lt;priority>5&lt;/priority>
 19  *     &lt;rcvTimestamp nanos='1007764305862000002'> &lt;!-- UTC time when message was created in xmlBlaster server with a publish() call, in nanoseconds since 1970 -->
 20  *           2001-12-07 23:31:45.862000002   &lt;!-- The nanos from above but human readable -->
 21  *     &lt;/rcvTimestamp>
 22  *     &lt;expiration lifeTime='1200'/> &lt;!-- The overall life time of the message [milliseconds] -->
 23  *     &lt;route>
 24  *        &lt;node id='heron'/>
 25  *     &lt;/route>
 26  *  &lt;/qos>
 27  * </pre>
 28  * @author xmlBlaster@marcelruff.info
 29  * @author laghi@swissinfo.org
 30  */
 31 
 32 
 33 #ifndef _CLIENT_QOS_GETRETURNQOS_H
 34 #define _CLIENT_QOS_GETRETURNQOS_H
 35 
 36 #include <util/qos/MsgQosData.h>
 37 
 38 namespace org { namespace xmlBlaster { namespace client { namespace qos {
 39 
 40 class Dll_Export GetReturnQos
 41 {
 42 protected:
 43    std::string     ME;
 44    org::xmlBlaster::util::Global&    global_;
 45    org::xmlBlaster::util::I_Log&       log_;
 46    org::xmlBlaster::util::qos::MsgQosData data_;
 47 
 48 public:
 49 
 50    GetReturnQos(org::xmlBlaster::util::Global& global, const org::xmlBlaster::util::qos::MsgQosData& data);
 51 
 52    GetReturnQos(const GetReturnQos& data);
 53 
 54    GetReturnQos& operator=(const GetReturnQos&);
 55 
 56    org::xmlBlaster::util::qos::MsgQosData& getData() { return data_; }
 57 
 58    /**
 59     * @return true/false
 60     */
 61    bool isVolatile() const;
 62 
 63    /**
 64     * @return true/false
 65     */
 66    bool isPersistent() const;
 67 
 68    /**
 69     * @return true/false
 70     */
 71    bool isReadonly() const;
 72 
 73    /**
 74     * Access sender unified naming object.
 75     * @return sessionName of sender or null if not known
 76     */
 77    org::xmlBlaster::util::SessionNameRef getSender();
 78 
 79    /**
 80     * Message priority.
 81     * @return priority 0-9
 82     * @see org.xmlBlaster.util.def.PriorityEnum
 83     */
 84    org::xmlBlaster::util::PriorityEnum getPriority() const;
 85 
 86    /**
 87     * This is the value delivered in the QoS (as it was calculated by the server on sending)
 88     * and is NOT dynamically recalculated.
 89     * So trust this value only if your client clock is out of date (or not trusted) and
 90     * if you know the message sending latency is not too big.
 91     * @return Milliseconds until message expiration (from now) or -1L if forever
 92     *         if 0L the message is expired
 93     */
 94    long getRemainingLifeStatic() const;
 95 
 96    /**
 97     * Dump state of this object into a XML ASCII std::string.
 98     * <br>
 99     * @param extraOffset indenting of tags for nice output
100     * @return internal state of the message QoS as a XML ASCII std::string
101     */
102    std::string toXml(const std::string& extraOffset="", bool clearText = false);
103 
104 
105    /**
106     * Access state of message on update().
107     * @return OK (Other values are not yet supported)
108     */
109    std::string getState() const;
110 
111    /**
112     * True if the message is OK on update(). 
113     */
114    bool isOk() const;
115 
116    /**
117     * True if the message was erased by timer or by a
118     * client invoking erase(). 
119     */
120    bool isErased() const;
121 
122    /**
123     * True if a timeout on this message occurred. 
124     * <p />
125     * Timeouts are spanned by the publisher and thrown by xmlBlaster
126     * on timeout to indicate for example
127     * STALE messages or any other user problem domain specific event.
128     */
129    bool isTimeout() const;
130 
131    /** 
132     * The approximate receive timestamp (UTC time),
133     * when message arrived in requestBroker.publish() method.<br />
134     * In milliseconds elapsed since midnight, January 1, 1970 UTC
135     */
136    org::xmlBlaster::util::Timestamp getRcvTimestamp() const;
137 
138     // the following where not present before ...
139    org::xmlBlaster::util::qos::RouteVector getRouteNodes();
140 
141    std::string getRcvTime() const;
142 
143    /**
144     * Get a map containing all send client properties
145     */
146    const org::xmlBlaster::util::qos::QosData::ClientPropertyMap& getClientProperties() const;
147 
148    bool hasClientProperty(const std::string& name) const {
149       return data_.hasClientProperty(name);
150    }
151 
152    /**
153     * Access the value for the given name, if not found returns the defaultValue. 
154     * @return A copy of the given defaultValue if none was found
155     */
156    template <typename T_VALUE> T_VALUE getClientProperty(
157             const std::string& name,
158             const T_VALUE& defaultValue) {
159       return data_.getClientProperty(name, defaultValue);
160    }
161 
162 };
163 
164 }}}}
165 
166 #endif


syntax highlighted by Code2HTML, v. 0.9.1