1 /*------------------------------------------------------------------------------
2 Name: AccessFilterQos.h
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 Comment: Holding filter address std::string and protocol std::string
6 ------------------------------------------------------------------------------*/
7
8 /**
9 * Helper class holding filter markup from a subscribe() or get() QoS.
10 * <p />
11 * <pre>
12 * <filter type='ContentLength' version='1.0'>
13 * 800
14 * </filter>
15 * </pre>
16 * This example addresses the plugin in xmlBlaster.properties file
17 * <pre>
18 * MimeAccessPlugin[ContentLenFilter][1.0]=org.xmlBlaster.engine.mime.demo.ContentLenFilter
19 * </pre>
20 * The filter rules apply for cluster configuration as well.
21 *
22 * @see <a href="http://www.xmlblaster.org/xmlBlaster/doc/requirements/mime.plugin.accessfilter.html">MIME based access filter plugin framework</a>
23 */
24
25 #ifndef _UTIL_QOS_ACCESSFILTERQOS_H
26 #define _UTIL_QOS_ACCESSFILTERQOS_H
27
28 #include <util/xmlBlasterDef.h>
29 #include <util/qos/Query.h>
30 #include <util/I_Log.h>
31 #include <util/Property.h>
32
33 #include <string>
34
35 namespace org { namespace xmlBlaster { namespace util { namespace qos {
36
37 extern Dll_Export const char* ACCESSFILTER_DEFAULT_version;
38 extern Dll_Export const char* ACCESSFILTER_DEFAULT_type;
39
40 class Dll_Export AccessFilterQos
41 {
42 const std::string ME;
43 org::xmlBlaster::util::Global& global_;
44 org::xmlBlaster::util::I_Log& log_;
45
46 /** The filter rule std::string and an object to hold the prepared query on demand */
47 Query query_;
48
49 /** The plugin name e.g. "ContentLength" */
50 std::string type_;
51
52 /** The version of the plugin */
53 std::string version_; // = DEFAULT_version;
54
55 void copy(const AccessFilterQos& qos);
56
57 public:
58 /**
59 */
60 AccessFilterQos(org::xmlBlaster::util::Global& global);
61
62 /**
63 * @param glob The global handle holding environment and logging objects
64 * @param type The plugin name, as used in xmlBlaster.properties e.g. "ContentLenFilter".
65 * @param version The plugin version, defaults to "1.0"
66 * @param query Your filter rule
67 */
68 AccessFilterQos(org::xmlBlaster::util::Global& global, const std::string& type, const std::string& version, const std::string& query);
69
70 /**
71 * @param glob The global handle holding environment and logging objects
72 * @param type The plugin name, as used in xmlBlaster.properties e.g. "ContentLenFilter".
73 * @param version The plugin version, defaults to "1.0"
74 * @param query Your filter rule
75 */
76 AccessFilterQos(org::xmlBlaster::util::Global& global, const std::string& type, const std::string& version, const Query& query);
77
78 AccessFilterQos(const AccessFilterQos& qos);
79
80 AccessFilterQos& operator =(const AccessFilterQos& qos);
81
82
83 /**
84 * @param type The plugin name, as used in xmlBlaster.properties e.g. "ContentLenFilter".
85 */
86 void setType(const std::string& type);
87
88 /**
89 * Returns the plugins name.
90 * @return e.g. "ContentLenFilter"
91 */
92 std::string getType() const;
93
94 /**
95 * @param version The version of the plugin, defaults to "1.0", but can anything you like.
96 */
97 void setVersion(const std::string& version);
98
99 /**
100 * Returns the plugins version.
101 * @return e.g. "1.0"
102 */
103 std::string getVersion() const;
104
105 /**
106 * Set the filter query, it should fit to the protocol-type.
107 *
108 * @param query The filter query, e.g. "8000" for max length of a content with "ContentLenFilter" plugin
109 */
110 void setQuery(const Query& query);
111
112 /**
113 * Returns the query, the syntax is depending on what your plugin supports.
114 * @return e.g. "a>12 AND b<15"
115 */
116 Query getQuery() const;
117
118 /**
119 * Dump state of this object into a XML ASCII std::string.
120 * <br>
121 * Only none default values are dumped for performance reasons
122 * @param extraOffset indenting of tags for nice output
123 * @return The xml representation
124 */
125 std::string toXml(const std::string& extraOffset="") const;
126 };
127
128 }}}}
129
130 #endif
syntax highlighted by Code2HTML, v. 0.9.1