1 /*-----------------------------------------------------------------------------
  2 Name:      Destination.h
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 Comment:   Holding destination address attributes
  6 -----------------------------------------------------------------------------*/
  7 
  8 #ifndef _UTIL_DESTINATION_H
  9 #define _UTIL_DESTINATION_H
 10  
 11 #include <util/xmlBlasterDef.h>
 12 #include <util/SessionName.h>
 13 #include <util/I_Log.h>
 14 #include <string>
 15 
 16 namespace org { namespace xmlBlaster { namespace util {
 17 
 18 /**
 19  * Holding destination address attributes.
 20  * <p />
 21  * This class corresponds to the QOS destination tag
 22  */
 23 class Dll_Export Destination
 24 {
 25 
 26 private:
 27 
 28    std::string ME;
 29    org::xmlBlaster::util::Global& global_;
 30    org::xmlBlaster::util::I_Log& log_;
 31 
 32    /** The destination address (==login name) or the XPath query std::string */
 33    org::xmlBlaster::util::SessionNameRef sessionName_;
 34    /** EXACT is default */
 35    std::string queryType_;
 36    /** No queuing is default */
 37    bool forceQueuing_;
 38 
 39    void copy(const Destination& dest)
 40    {
 41       SessionName *p = new SessionName(global_, dest.sessionName_->getAbsoluteName());
 42       SessionNameRef r(p);
 43       sessionName_ = r;
 44 
 45       queryType_    = dest.queryType_;
 46       forceQueuing_ = dest.forceQueuing_;
 47    }
 48 
 49 public:
 50 
 51    /**
 52     * Constructs the specialized quality of service destination object.
 53     */
 54    Destination(org::xmlBlaster::util::Global& global,
 55                const org::xmlBlaster::util::SessionName& sessionName,
 56                const std::string &queryType="EXACT",
 57                bool forceQueuing=false);
 58 
 59    Destination(org::xmlBlaster::util::Global& global,
 60                const std::string& address="",
 61                const std::string &queryType="EXACT",
 62                bool forceQueuing=false);
 63 
 64     Destination(const Destination& dest);
 65 
 66     Destination& operator =(const Destination& dest);
 67 
 68    /**
 69     * @return true/false
 70     */
 71    bool isXPathQuery() const;
 72 
 73    /**
 74     * @return true/false
 75     */
 76    bool isExactAddress() const;
 77 
 78    /**
 79     * @return true/false
 80     */
 81    bool forceQueuing() const;
 82 
 83    /**
 84     * Set queuing of messages.
 85     * <p />
 86     * true: If client is not logged in, messages will be queued until he
 87     *       comes. <br />
 88     * false: Default is that on PtP messages when the destination address is
 89     *        not online, an Exception is thrown
 90     */
 91    void forceQueuing(bool forceQueuing);
 92 
 93    /*
 94     * Set the destination address or the destination query std::string.
 95     * @param destination The destination address or the query std::string
 96    void setDestination(const org::xmlBlaster::util::SessionName& sessionName);
 97     */
 98 
 99    /**
100     * @param The destination address or XPath query std::string
101     */
102    org::xmlBlaster::util::SessionNameRef getDestination() const;
103 
104    /**
105     * @param queryType The query type, one of "EXACT" | "XPATH"
106     */
107    void setQueryType(const std::string &queryType);
108 
109    /**
110     * Dump state of this object into a XML ASCII std::string.
111     * <br>
112     * @param extraOffset indenting of tags for nice output
113     * @return The Destination as a XML ASCII std::string
114     */
115    std::string toXml(const std::string &extraOffset="") const;
116 };
117 
118 }}} // namespace
119 
120 #endif


syntax highlighted by Code2HTML, v. 0.9.1