1 /*------------------------------------------------------------------------------
  2 Name:      TopicProperty.h
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 ------------------------------------------------------------------------------*/
  6 
  7 /**
  8  * Data container handling properties of a message topic. 
  9  * <p />
 10  * QoS Informations sent from the client to the server via the publish() method and back via the update() method<br />
 11  * They are needed to control xmlBlaster and inform the client.
 12  * <p />
 13  * <p>
 14  * This data holder is accessible through decorators, each of them allowing a specialized view on the data
 15  * </p>
 16  * @see org.xmlBlaster.util.qos.MsgQosSaxFactory
 17  * @see org.xmlBlaster.test.classtest.qos.MsgQosFactoryTest
 18  * @author xmlBlaster@marcelruff.info
 19  * @author laghi@swissinfo.org
 20  */
 21 
 22 #ifndef _UTIL_QOS_TOPICPROPERTY_H
 23 #define _UTIL_QOS_TOPICPROPERTY_H
 24 
 25 #include <util/xmlBlasterDef.h>
 26 #include <string>
 27 #include <util/I_Log.h>
 28 #include <util/qos/storage/MsgUnitStoreProperty.h>
 29 #include <util/qos/storage/HistoryQueueProperty.h>
 30 #include <util/Prop.h>
 31 
 32 namespace org { namespace xmlBlaster { namespace util { namespace qos {
 33 
 34 /**
 35  * A topic is destroyed 60 sec after state=UNREFERENCED is reached
 36  * This default can be modified in xmlBlaster.properties:
 37  * <pre>
 38  *    topic.destroyDelay=3600000 # One hour [millisec]
 39  * </pre>
 40  * Every message can set the destroyDelay value between 1 and destroyDelay_DEFAULT,
 41  * -1L sets the life cycle on forever.
 42  */ // TODO: Change to use glob instead of org::xmlBlaster::util::Global singleton! What about performance? Put variable into org::xmlBlaster::util::Global?
 43 extern Dll_Export const long destroyDelay_DEFAULT_DEFAULT;
 44 /** Is readonly allows only one initial message */
 45 extern Dll_Export const bool DEFAULT_readonly;
 46 
 47 class Dll_Export TopicProperty
 48 {
 49 private:
 50    std::string ME;
 51    org::xmlBlaster::util::Global& global_;
 52    org::xmlBlaster::util::I_Log& log_;
 53    org::xmlBlaster::util::qos::storage::MsgUnitStoreProperty* msgUnitStoreProperty_;
 54    org::xmlBlaster::util::qos::storage::HistoryQueueProperty* historyQueueProperty_;
 55 
 56    /* If Pub/Sub style update: contains the subscribe ID which caused this topic */
 57    //std::string subscriptionId;
 58 
 59    bool readonly_; //  = DEFAULT_readonly;
 60 
 61    /** 
 62     * A topic is destroyed 60 sec after state=UNREFERENCED is reached
 63     * This is the configured destroyDelay in millis
 64     */
 65    long destroyDelay_;
 66 
 67    long destroyDelay_DEFAULT; // = org::xmlBlaster::util::Global.instance().getProperty().get("topic.destroyDelay", destroyDelay_DEFAULT_DEFAULT);
 68 
 69    Prop<bool> createDomEntry_;
 70 
 71    void copy(const TopicProperty& prop);
 72 
 73 public:
 74    /**
 75     * Constructs the specialized quality of service object for a publish() or update() call.
 76     */
 77    TopicProperty(org::xmlBlaster::util::Global& global);
 78 
 79    TopicProperty(const TopicProperty& prop);
 80    TopicProperty& operator =(const TopicProperty& prop);
 81 
 82    ~TopicProperty();
 83 
 84    /**
 85     * @return readonly Once published the message can't be changed. 
 86     */
 87    void setReadonly(bool readonly);
 88 
 89    /**
 90     * @return true/false
 91     */
 92    bool isReadonly();
 93 
 94    /**
 95     * The life time of the message topic in state UNREFERENCED
 96     */
 97    long getDestroyDelay();
 98 
 99    /**
100     * The life time of the message topic in state UNREFERENCED
101     */
102    void setDestroyDelay(long destroyDelay);
103 
104    /**
105     * Is the topic available in the internal DOM tree? 
106     * @return true This is default and the topic is queryable with XPATH<br />
107     *    false: No DOM tree is created for the topic and the topic is onvisible to XPATH queries
108     */
109    bool createDomEntry() const;
110 
111    /**
112     * Set if the topic is available in the internal DOM tree. 
113     * @param true This is default and the topic is queryable with XPATH<br />
114     *    false: No DOM tree is created for the topic and the topic is onvisible to XPATH queries
115     */
116    void setCreateDomEntry(bool createDomEntry);
117 
118    bool hasMsgUnitStoreProperty();
119 
120    /**
121     * @return the configuration of the message store, is never null
122     */
123    org::xmlBlaster::util::qos::storage::MsgUnitStoreProperty getMsgUnitStoreProperty();
124 
125    void setMsgUnitStoreProperty(const org::xmlBlaster::util::qos::storage::MsgUnitStoreProperty& msgUnitStoreProperty);
126 
127    bool hasHistoryQueueProperty();
128 
129    /**
130     * @return the configuration of the history queue, is never null
131     */
132    org::xmlBlaster::util::qos::storage::HistoryQueueProperty getHistoryQueueProperty();
133 
134    void setHistoryQueueProperty(const org::xmlBlaster::util::qos::storage::HistoryQueueProperty& historyQueueProperty);
135 
136    /**
137     * Dump state of this object into a XML ASCII std::string.
138     * <br>
139     * @param extraOffset indenting of tags for nice output
140     * @return internal state of the message QoS as a XML ASCII std::string, never null but "" if all values are default
141     */
142    std::string toXml(const std::string& extraOffset="");
143 };
144 
145 }}}}
146 #endif


syntax highlighted by Code2HTML, v. 0.9.1