1 /*------------------------------------------------------------------------------
  2 Name:      QueryQosData.h
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 ------------------------------------------------------------------------------*/
  6 
  7 /**
  8  * Data container handling of query / access QoS. 
  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>SubscribeQos QoS of a subscribe() invocation (Client side)</i>
 14  * <li>UnSubscribeQos QoS of a unSubscribe() invocation (Client side)</i>
 15  * <li>EraseQos QoS of an erase() invocation (Client side)</i>
 16  * <li>GetQos QoS of an get() invocation (Client side)</i>
 17  * </ul>
 18  * <p>
 19  * For the xml representation see QueryQosSaxFactory.
 20  * </p>
 21  * @see org.xmlBlaster.util.qos.QueryQosSaxFactory
 22  * @see org.xmlBlaster.test.classtest.qos.QueryQosFactoryTest
 23  * @author xmlBlaster@marcelruff.info
 24  * @author laghi@swissinfo.org
 25  */
 26 
 27 #ifndef _UTIL_QOS_QUERYQOSDATA_H
 28 #define _UTIL_QOS_QUERYQOSDATA_H
 29 
 30 #include <util/xmlBlasterDef.h>
 31 #include <util/qos/QosData.h>
 32 #include <util/qos/AccessFilterQos.h>
 33 #include <util/qos/HistoryQos.h>
 34 #include <vector>
 35 #include <string>
 36 
 37 
 38 
 39 
 40 
 41 
 42 namespace org { namespace xmlBlaster { namespace util { namespace qos {
 43 
 44 typedef std::vector<org::xmlBlaster::util::qos::AccessFilterQos> AccessFilterVector;
 45 
 46 class Dll_Export QueryQosData : public QosData
 47 {
 48    /** A client can force a specific subscription id */
 49    std::string subscriptionId_;
 50 
 51    /** On erase forceDestroy */
 52    bool forceDestroy_;
 53 
 54    /** not yet supported */
 55    bool meta_;
 56 
 57    /** not yet supported */
 58    bool content_;
 59 
 60    bool multiSubscribe_;
 61 
 62    bool local_;
 63 
 64    /** send on subscribe an initial update with the current message */
 65    bool initialUpdate_;
 66 
 67    /** Deliver callback messages with <tt>updateOneway()</tt> */
 68    bool updateOneway_;
 69 
 70    /** for subscribe(): Notify the subscribers on erase? */
 71    bool notify_;
 72 
 73    /** Mime based filter rules */
 74    AccessFilterVector filters_;
 75 
 76    /** Query history messages */
 77    org::xmlBlaster::util::qos::HistoryQos historyQos_;
 78 
 79    /** QueryQos settings */   
 80    int maxEntries_;
 81    bool consumable_;
 82    long timeout_;
 83 
 84    void init();
 85 
 86    void copy(const QueryQosData& data);
 87 
 88 public:
 89 
 90    /**
 91     * Constructs the specialized quality of service object for query informations,
 92     * e.g. for a subscribe() call
 93     * @param The factory which knows how to serialize and parse me
 94     */
 95    QueryQosData(org::xmlBlaster::util::Global& global);
 96 
 97    void setMultiSubscribe(bool multiSubscribe);
 98 
 99    /**
100     * Allow to subscribe multiple times to the same query/oid
101     * @return defaults to true
102     */
103    bool getMultiSubscribe() const;
104 
105    /**
106     * Do we want to have an initial update on subscribe if the message
107     * exists already?
108     *
109     * @return true if initial update wanted
110     *         false if only updates on new publishes are sent
111     * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/engine.qos.subscribe.initialUpdate.html">The engine.qos.subscribe.initialUpdate requirement</a>
112     */
113    void setWantInitialUpdate(bool initialUpdate);
114 
115    bool getWantInitialUpdate() const;
116 
117    /**
118     * Do we want the callback messages of this subscription as oneway with <tt>updateOneway()</tt> or with
119     * the acknowledged <tt>update()</tt>. 
120     * @param updateOneway Defaults to false. 
121     * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/interface.subscribe.html">The interface.subscribe requirement</a>
122     * @see QueryQosData#setWantUpdateOneway(boolean)
123     */
124    void setWantUpdateOneway(bool updateOneway);
125 
126    bool getWantUpdateOneway() const;
127 
128    void setWantNotify(bool notify);
129 
130    bool getWantNotify() const;
131 
132    /**
133     * false Inhibit the delivery of messages to myself if i have published it.
134     */
135    void setWantLocal(bool local);
136 
137    /**
138     * false Inhibit the delivery of messages to myself if i have published it.
139     */
140    bool getWantLocal() const;
141 
142    /**
143     * @param meta false: Don't send me the meta information of a message key
144     */
145    void setWantMeta(bool meta);
146 
147    /**
148     * @return false: Don't send me the meta information of a message key
149     */
150    bool getWantMeta() const;
151 
152    /**
153     * If false, the update contains not the content (it is a notify of change only)
154     * TODO: Implement in server!!!
155     */
156    void setWantContent(bool content);
157 
158    bool getWantContent() const;
159 
160    /**
161     * @param forceDestroy
162     */
163    void setForceDestroy(bool forceDestroy);
164 
165    /**
166     * @return for erase behaviour
167     */
168    bool getForceDestroy() const;
169 
170    /**
171     * Adds your subplied subscribe filter
172     */
173    void addAccessFilter(const org::xmlBlaster::util::qos::AccessFilterQos& filter);
174 
175    AccessFilterVector getAccessFilters() const;
176 
177    /**
178     * Set the QoS which describes the history query settings. 
179     */
180    void setHistoryQos(const org::xmlBlaster::util::qos::HistoryQos& historyQos);
181    
182    void setQueryQos(int maxEntries, long timeout, bool consumable);
183 
184    /**
185     * Get the QoS which describes the history query settings. 
186     * @return never null
187     */
188    org::xmlBlaster::util::qos::HistoryQos getHistoryQos() const;
189 
190    /**
191     * Get the identifier (unique handle) for this subscription. 
192     * @return The id or null if not specified by client.
193     * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/engine.qos.subscribe.id.html">The engine.qos.subscribe.id requirement</a>
194     */
195    std::string getSubscriptionId() const;
196 
197    /**
198     * Force the identifier (unique handle) for this subscription. 
199     * Usually you let the identifier be generated by xmlBlaster.
200     * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/engine.qos.subscribe.id.html">The engine.qos.subscribe.id requirement</a>
201     */
202    void setSubscriptionId(const std::string& subscriptionId);
203 
204    /**
205     * Dump state of this object into a XML ASCII std::string.
206     * <br>
207     * @param extraOffset indenting of tags for nice output
208     * @return internal state of the query as a XML ASCII std::string
209     */
210    std::string toXml(const std::string& extraOffset="") const;
211 
212    /**
213     * Allocate a clone. 
214     * @return The caller needs to free it with 'delete'.
215     */
216    QueryQosData* getClone() const;
217 };
218 
219 }}}} // namespace
220 
221 #endif


syntax highlighted by Code2HTML, v. 0.9.1