diff options
| author | Ted Ross <tross@apache.org> | 2011-01-10 14:06:16 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2011-01-10 14:06:16 +0000 |
| commit | 120ea440ef9d048d3bb31e6118027f5c9e890fca (patch) | |
| tree | 34e14880765c6b79c77c4fb24e834b8d67260149 /cpp/include | |
| parent | 598e5eacac716a9a3a812e9cf72b14bde57ed45a (diff) | |
| download | qpid-python-120ea440ef9d048d3bb31e6118027f5c9e890fca.tar.gz | |
Updates to the C++ implementation of QMFv2:
1) Consolidated string constants for the protocol into a definition file.
2) Added hooks for subscription handling.
3) Added checks to validate properties and arguments against the schema (if there is a schema).
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1057199 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/include')
| -rw-r--r-- | cpp/include/qmf/Agent.h | 7 | ||||
| -rw-r--r-- | cpp/include/qmf/AgentSession.h | 9 | ||||
| -rw-r--r-- | cpp/include/qmf/ConsoleEvent.h | 6 | ||||
| -rw-r--r-- | cpp/include/qmf/ConsoleSession.h | 11 | ||||
| -rw-r--r-- | cpp/include/qmf/Data.h | 4 | ||||
| -rw-r--r-- | cpp/include/qmf/Subscription.h | 82 |
6 files changed, 113 insertions, 6 deletions
diff --git a/cpp/include/qmf/Agent.h b/cpp/include/qmf/Agent.h index 8d427ab2fb..8c0f48b8b1 100644 --- a/cpp/include/qmf/Agent.h +++ b/cpp/include/qmf/Agent.h @@ -23,6 +23,7 @@ #include <qmf/ImportExport.h> #include "qmf/Handle.h" +//#include "qmf/Subscription.h" #include "qmf/exceptions.h" #include "qpid/messaging/Duration.h" #include "qpid/types/Variant.h" @@ -61,6 +62,12 @@ namespace qmf { QMF_EXTERN uint32_t queryAsync(const Query&); QMF_EXTERN uint32_t queryAsync(const std::string&); + /** + * Create a subscription to this agent + */ + //QMF_EXTERN Subscription subscribe(const Query&, const std::string& options = ""); + //QMF_EXTERN Subscription subscribe(const std::string&, const std::string& options = ""); + QMF_EXTERN ConsoleEvent callMethod(const std::string&, const qpid::types::Variant::Map&, const DataAddr&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); QMF_EXTERN uint32_t callMethodAsync(const std::string&, const qpid::types::Variant::Map&, const DataAddr&); diff --git a/cpp/include/qmf/AgentSession.h b/cpp/include/qmf/AgentSession.h index 4ac2b2f3ed..090017779f 100644 --- a/cpp/include/qmf/AgentSession.h +++ b/cpp/include/qmf/AgentSession.h @@ -57,11 +57,16 @@ namespace qmf { * The options string is of the form "{key:value,key:value}". The following keys are supported: * * interval:N - Heartbeat interval in seconds [default: 60] - * external:{True,False} - Use external data storage (queries are pass-through) [default: False] + * external:{True,False} - Use external data storage (queries and subscriptions are pass-through) [default: False] * allow-queries:{True,False} - If True: automatically allow all queries [default] * If False: generate an AUTH_QUERY event to allow per-query authorization * allow-methods:{True,False} - If True: automatically allow all methods [default] * If False: generate an AUTH_METHOD event to allow per-method authorization + * max-subscriptions:N - Maximum number of concurrent subscription queries permitted [default: 64] + * min-sub-interval:N - Minimum publish interval (in milliseconds) permitted for a subscription [default: 3000] + * sub-lifetime:N - Lifetime (in seconds with no keepalive) for a subscription [default: 300] + * public-events:{True,False} - If True: QMF events are sent to the topic exchange [default] + * If False: QMF events are only sent to authorized subscribers */ QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); @@ -143,7 +148,7 @@ namespace qmf { * authReject - Reject/forbid an authorization request. * raiseException - indicate failure of an operation (i.e. query or method call). * response - Provide data in response to a query (only for option: external:True) - * complete - Indicate that the response to a query is complete (external:true only) + * complete - Indicate that the response to a query is complete (external:True only) * methodSuccess - Indicate the successful completion of a method call. */ QMF_EXTERN void authAccept(AgentEvent&); diff --git a/cpp/include/qmf/ConsoleEvent.h b/cpp/include/qmf/ConsoleEvent.h index 3e75631a61..54272334a4 100644 --- a/cpp/include/qmf/ConsoleEvent.h +++ b/cpp/include/qmf/ConsoleEvent.h @@ -46,8 +46,10 @@ namespace qmf { CONSOLE_QUERY_RESPONSE = 7, CONSOLE_METHOD_RESPONSE = 8, CONSOLE_EXCEPTION = 9, - CONSOLE_SUBSCRIBE_UPDATE = 10, - CONSOLE_THREAD_FAILED = 11 + CONSOLE_SUBSCRIBE_ADD = 10, + CONSOLE_SUBSCRIBE_UPDATE = 11, + CONSOLE_SUBSCRIBE_DEL = 12, + CONSOLE_THREAD_FAILED = 13 }; enum AgentDelReason { diff --git a/cpp/include/qmf/ConsoleSession.h b/cpp/include/qmf/ConsoleSession.h index c17f4510f1..ba8b3de92f 100644 --- a/cpp/include/qmf/ConsoleSession.h +++ b/cpp/include/qmf/ConsoleSession.h @@ -24,6 +24,7 @@ #include <qmf/ImportExport.h> #include "qmf/Handle.h" #include "qmf/Agent.h" +#include "qmf/Subscription.h" #include "qpid/messaging/Duration.h" #include "qpid/messaging/Connection.h" #include <string> @@ -67,6 +68,16 @@ namespace qmf { QMF_EXTERN Agent getAgent(uint32_t) const; QMF_EXTERN Agent getConnectedBrokerAgent() const; + /** + * Create a subscription that involves a subset of the known agents. The set of known agents is defined by + * the session's agent-filter (see setAgentFilter). The agentFilter argument to the subscribe method is used + * to further refine the set of agents. If agentFilter is the empty string (i.e. match-all) the subscription + * will involve all known agents. If agentFilter is non-empty, it will be applied only to the set of known + * agents. A subscription cannot be created that involves an agent not known by the session. + */ + QMF_EXTERN Subscription subscribe(const Query&, const std::string& agentFilter = "", const std::string& options = ""); + QMF_EXTERN Subscription subscribe(const std::string&, const std::string& agentFilter = "", const std::string& options = ""); + #ifndef SWIG private: friend class qmf::PrivateImplRef<ConsoleSession>; diff --git a/cpp/include/qmf/Data.h b/cpp/include/qmf/Data.h index 27af1c4b04..82f1569a0b 100644 --- a/cpp/include/qmf/Data.h +++ b/cpp/include/qmf/Data.h @@ -34,6 +34,7 @@ namespace qmf { #endif class DataImpl; + class Schema; class SchemaId; class DataAddr; class Agent; @@ -45,8 +46,7 @@ namespace qmf { QMF_EXTERN Data& operator=(const Data&); QMF_EXTERN ~Data(); - QMF_EXTERN Data(const SchemaId&); - QMF_EXTERN void setSchema(const SchemaId&); + QMF_EXTERN Data(const Schema&); QMF_EXTERN void setAddr(const DataAddr&); QMF_EXTERN void setProperty(const std::string&, const qpid::types::Variant&); QMF_EXTERN void overwriteProperties(const qpid::types::Variant::Map&); diff --git a/cpp/include/qmf/Subscription.h b/cpp/include/qmf/Subscription.h new file mode 100644 index 0000000000..4e60eb984e --- /dev/null +++ b/cpp/include/qmf/Subscription.h @@ -0,0 +1,82 @@ +#ifndef QMF_SUBSCRIPTION_H +#define QMF_SUBSCRIPTION_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include <qmf/ImportExport.h> +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" +#include <string> + +namespace qmf { + +#ifndef SWIG + template <class> class PrivateImplRef; +#endif + + class SubscriptionImpl; + class Data; + + class Subscription : public qmf::Handle<SubscriptionImpl> { + public: + QMF_EXTERN Subscription(SubscriptionImpl* impl = 0); + QMF_EXTERN Subscription(const Subscription&); + QMF_EXTERN Subscription& operator=(const Subscription&); + QMF_EXTERN ~Subscription(); + + /** + * Construction: A subscription is created by calling ConsoleSession::subscribe. + */ + + /** + * Cancel subscriptions to all subscribed agents. After this is called, the subscription + * shall be inactive. + */ + QMF_EXTERN void cancel(); + + /** + * Check to see if this subscription is active. It is active if it has a live subscription + * on at least one agent. If it is not active, there is nothing that can be done to make it + * active, it can only be deleted. + */ + QMF_EXTERN bool isActive() const; + + /** + * lock and unlock should be used to bracket a traversal of the data set. After lock is called, + * the subscription will not change its set of available data objects. Between calls to getDataCount + * and getData, no data objects will be added or removed. After unlock is called, the set of data + * will catch up to any activity that occurred while the lock was in effect. + */ + QMF_EXTERN void lock(); + QMF_EXTERN void unlock(); + QMF_EXTERN uint32_t getDataCount() const; + QMF_EXTERN Data getData(uint32_t) const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef<Subscription>; + friend class SubscriptionImplAccess; +#endif + }; + +} + +#endif |
