1 /*------------------------------------------------------------------------------
 2 Name:      HistoryQos.h
 3 Project:   xmlBlaster.org
 4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
 5 ------------------------------------------------------------------------------*/
 6 
 7 /**
 8  * Helper class holding QoS settings to acces historical message. 
 9  * <p />
10  * <pre>
11  *   &lt;history numEntries='20' newestFirst='true'/>
12  * </pre>
13  * <p>
14  * Default is to deliver the most current entry (numEntries='1'),
15  * '-1' would deliver all history entries available.
16  * </p>
17  * A future version could extend the query possibilities to e.g.
18  * <pre>
19  *   &lt;history>
20  *      &lt;time from='yesterday' to='now'>
21  *   &lt;/history>
22  * </pre>
23  */
24 
25 #ifndef _UTIL_QOS_HISTORYQOS_H
26 #define _UTIL_QOS_HISTORYQOS_H
27 
28 # include <util/xmlBlasterDef.h>
29 # include <util/Log.h>
30 # include <util/Property.h>
31 
32 
33 
34         
35 namespace org { namespace xmlBlaster { namespace util { namespace qos {
36 
37 extern Dll_Export const long DEFAULT_numEntries;
38 extern Dll_Export const bool DEFAULT_newestFirst;
39 
40 
41 class Dll_Export HistoryQos
42 {
43 private:
44    const std::string ME; //  = "HistoryQos";
45    org::xmlBlaster::util::Global&      global_;
46    org::xmlBlaster::util::I_Log&         log_;
47 
48    long numEntries_; // = DEFAULT_numEntries;
49    bool newestFirst_; // = DEFAULT_newestFirst;
50 
51 public:
52    /**
53     * @param glob The global handle holding environment and logging objects
54     */
55    HistoryQos(org::xmlBlaster::util::Global& global, long numOfEntries=-1); 
56 
57    HistoryQos(const HistoryQos& qos);
58 
59    HistoryQos& operator =(const HistoryQos& qos);
60 
61    /**
62     * @param numEntries The number of history entries
63     */
64    void setNumEntries(long numOfEntries);
65  
66    /**
67     * Returns the number of history entries.
68     * @return e.g. 1
69     */
70    long getNumEntries() const;
71  
72    /**
73     * The sorting order in which the history entries are delivered. 
74     * The higher priority messages are always delivered first.
75     * In one priority the newest message is delivered first with 'true', setting 'false'
76     * reverts the delivery sequence in this priority.
77     * @param newestFirst defaults to true. 
78     */
79    void setNewestFirst(bool newestFirst);
80  
81    /**
82     * @return defaults to true
83     * @see #setNewestFirst(boolean)
84     */
85    bool getNewestFirst() const;
86  
87    /**
88     * Dump state of this object into a XML ASCII std::string.
89     * <br>
90     * Only none default values are dumped for performance reasons
91     * @param extraOffset indenting of tags for nice output
92     * @return The xml representation or "" if all settings are default
93     */
94    std::string toXml(const std::string& extraOffset="") const;
95 };
96 
97 }}}} //namespace
98 
99 #endif


syntax highlighted by Code2HTML, v. 0.9.1