diff options
author | Stephen D. Huston <shuston@apache.org> | 2011-10-21 14:42:12 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2011-10-21 14:42:12 +0000 |
commit | f83677056891e436bf5ba99e79240df2a44528cd (patch) | |
tree | 625bfd644b948e89105630759cf6decb0435354d /cpp/include | |
parent | ebfd9ff053b04ab379acfc0fefedee5a31b6d8a5 (diff) | |
download | qpid-python-QPID-2519.tar.gz |
Merged out from trunkQPID-2519
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/QPID-2519@1187375 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/include')
84 files changed, 730 insertions, 414 deletions
diff --git a/cpp/include/qmf/Agent.h b/cpp/include/qmf/Agent.h index 8c0f48b8b1..94083be4f3 100644 --- a/cpp/include/qmf/Agent.h +++ b/cpp/include/qmf/Agent.h @@ -42,7 +42,7 @@ namespace qmf { class SchemaId; class Schema; - class Agent : public qmf::Handle<AgentImpl> { + class QMF_CLASS_EXTERN Agent : public qmf::Handle<AgentImpl> { public: QMF_EXTERN Agent(AgentImpl* impl = 0); QMF_EXTERN Agent(const Agent&); diff --git a/cpp/include/qmf/AgentEvent.h b/cpp/include/qmf/AgentEvent.h index 59a41c3267..0f93a9bb0a 100644 --- a/cpp/include/qmf/AgentEvent.h +++ b/cpp/include/qmf/AgentEvent.h @@ -46,7 +46,7 @@ namespace qmf { AGENT_THREAD_FAILED = 8 }; - class AgentEvent : public qmf::Handle<AgentEventImpl> { + class QMF_CLASS_EXTERN AgentEvent : public qmf::Handle<AgentEventImpl> { public: QMF_EXTERN AgentEvent(AgentEventImpl* impl = 0); QMF_EXTERN AgentEvent(const AgentEvent&); diff --git a/cpp/include/qmf/AgentSession.h b/cpp/include/qmf/AgentSession.h index 9e29d6b54b..589d364bcc 100644 --- a/cpp/include/qmf/AgentSession.h +++ b/cpp/include/qmf/AgentSession.h @@ -40,7 +40,7 @@ namespace qmf { class Data; class DataAddr; - class AgentSession : public qmf::Handle<AgentSessionImpl> { + class QMF_CLASS_EXTERN AgentSession : public qmf::Handle<AgentSessionImpl> { public: QMF_EXTERN AgentSession(AgentSessionImpl* impl = 0); QMF_EXTERN AgentSession(const AgentSession&); @@ -71,15 +71,20 @@ namespace qmf { * If False: Listen only on the routable direct address * strict-security:{True,False} - If True: Cooperate with the broker to enforce strict access control to the network * - If False: Operate more flexibly with regard to use of messaging facilities [default] + * max-thread-wait-time:N - Time (in seconds) the session thread will wait for messages from the network between + * periodic background processing passes. [default: 5] + * Must not be greater than 'interval'. Larger numbers will cause fewer wake-ups but will + * increase the time it takes to shut down the process. This setting will not affect the + * agent's response time for queries or method invocation. */ - QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); + QMF_EXTERN AgentSession(qpid::messaging::Connection& conn, const std::string& options=""); /** * setDomain - Change the QMF domain that this agent will operate in. If this is not called, * the domain will be "default". Agents in a domain can be seen only by consoles in the same domain. * This must be called prior to opening the agent session. */ - QMF_EXTERN void setDomain(const std::string&); + QMF_EXTERN void setDomain(const std::string& domain); /** * Set identifying attributes of this agent. @@ -88,16 +93,16 @@ namespace qmf { * setInstance - Set the unique instance name (if not set, a UUID will be assigned) * These must be called prior to opening the agent session. */ - QMF_EXTERN void setVendor(const std::string&); - QMF_EXTERN void setProduct(const std::string&); - QMF_EXTERN void setInstance(const std::string&); + QMF_EXTERN void setVendor(const std::string& vendor); + QMF_EXTERN void setProduct(const std::string& product); + QMF_EXTERN void setInstance(const std::string& instance); /** * setAttribute - Set an arbitrary attribute for this agent. The attributes are not used * to uniquely identify the agent but can be used as a search criteria when looking for agents. * This must be called prior to opening the agent session. */ - QMF_EXTERN void setAttribute(const std::string&, const qpid::types::Variant&); + QMF_EXTERN void setAttribute(const std::string& key, const qpid::types::Variant& value); /** * Get the identifying name of the agent. @@ -119,13 +124,19 @@ namespace qmf { * Get the next event from the agent session. Events represent actions that must be acted upon by the * agent application. This method blocks for up to the timeout if there are no events to be handled. * This method will typically be the focus of the agent application's main execution loop. + * If the timeout is set to Duration::IMMEDIATE, the call will not block. */ - QMF_EXTERN bool nextEvent(AgentEvent&, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + QMF_EXTERN bool nextEvent(AgentEvent& outEvent, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + + /** + * Return the number of events pending for nextEvent. This method will never block. + */ + QMF_EXTERN int pendingEvents() const; /** * Register a schema to be exposed by this agent. */ - QMF_EXTERN void registerSchema(Schema&); + QMF_EXTERN void registerSchema(Schema& schema); /** * Add data to be managed internally by the agent. If the option external:True is selected, this call @@ -138,12 +149,12 @@ namespace qmf { * across different sessions. If persistent, it is the agent application's * responsibility to ensure the name is the same each time it is added. */ - QMF_EXTERN DataAddr addData(Data&, const std::string& name="", bool persistent=false); + QMF_EXTERN DataAddr addData(Data& data, const std::string& name="", bool persistent=false); /** * Delete data from internal agent management. */ - QMF_EXTERN void delData(const DataAddr&); + QMF_EXTERN void delData(const DataAddr& dataAddr); /** * The following methods are used to respond to events received in nextEvent. @@ -155,13 +166,13 @@ namespace qmf { * 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&); - QMF_EXTERN void authReject(AgentEvent&, const std::string& diag=""); - QMF_EXTERN void raiseException(AgentEvent&, const std::string&); - QMF_EXTERN void raiseException(AgentEvent&, const Data&); - QMF_EXTERN void response(AgentEvent&, const Data&); - QMF_EXTERN void complete(AgentEvent&); - QMF_EXTERN void methodSuccess(AgentEvent&); + QMF_EXTERN void authAccept(AgentEvent& event); + QMF_EXTERN void authReject(AgentEvent& event, const std::string& diag=""); + QMF_EXTERN void raiseException(AgentEvent& event, const std::string& errorText); + QMF_EXTERN void raiseException(AgentEvent& event, const Data& errorData); + QMF_EXTERN void response(AgentEvent& event, const Data& responseData); + QMF_EXTERN void complete(AgentEvent& event); + QMF_EXTERN void methodSuccess(AgentEvent& event); /** * Raise an event to be sent into the QMF network. @@ -177,6 +188,7 @@ namespace qmf { #ifndef SWIG private: friend class qmf::PrivateImplRef<AgentSession>; + friend struct AgentSessionImplAccess; #endif }; diff --git a/cpp/include/qmf/ConsoleEvent.h b/cpp/include/qmf/ConsoleEvent.h index b836b629af..94600f9357 100644 --- a/cpp/include/qmf/ConsoleEvent.h +++ b/cpp/include/qmf/ConsoleEvent.h @@ -57,7 +57,7 @@ namespace qmf { AGENT_DEL_FILTER = 2 }; - class ConsoleEvent : public qmf::Handle<ConsoleEventImpl> { + class QMF_CLASS_EXTERN ConsoleEvent : public qmf::Handle<ConsoleEventImpl> { public: QMF_EXTERN ConsoleEvent(ConsoleEventImpl* impl = 0); QMF_EXTERN ConsoleEvent(const ConsoleEvent&); diff --git a/cpp/include/qmf/ConsoleSession.h b/cpp/include/qmf/ConsoleSession.h index 0c73e7a6db..022485cfa7 100644 --- a/cpp/include/qmf/ConsoleSession.h +++ b/cpp/include/qmf/ConsoleSession.h @@ -38,7 +38,7 @@ namespace qmf { class ConsoleSessionImpl; class ConsoleEvent; - class ConsoleSession : public qmf::Handle<ConsoleSessionImpl> { + class QMF_CLASS_EXTERN ConsoleSession : public qmf::Handle<ConsoleSessionImpl> { public: QMF_EXTERN ConsoleSession(ConsoleSessionImpl* impl = 0); QMF_EXTERN ConsoleSession(const ConsoleSession&); @@ -61,15 +61,53 @@ namespace qmf { * If False: Listen only on the routable direct address * strict-security:{True,False} - If True: Cooperate with the broker to enforce strict access control to the network * - If False: Operate more flexibly with regard to use of messaging facilities [default] + * max-thread-wait-time:N - Time (in seconds) the session thread will wait for messages from the network between + * periodic background processing passes. + * Must not be greater than 60. Larger numbers will cause fewer wake-ups but will + * increase the time it takes to shut down the process. [default: 5] + */ + QMF_EXTERN ConsoleSession(qpid::messaging::Connection& conn, const std::string& options=""); + + /** + * setDomain - Change the QMF domain that this console will operate in. If this is not called, + * the domain will be "default". Agents in a domain can be seen only by consoles in the same domain. + * This must be called prior to opening the console session. + */ + QMF_EXTERN void setDomain(const std::string& domain); + QMF_EXTERN void setAgentFilter(const std::string& filter); + + /** + * Open the console session. After opening the session, the domain cannot be changed. */ - QMF_EXTERN ConsoleSession(qpid::messaging::Connection&, const std::string& options=""); - QMF_EXTERN void setDomain(const std::string&); - QMF_EXTERN void setAgentFilter(const std::string&); QMF_EXTERN void open(); + + /** + * Close the session. Once closed, the session no longer communicates on the messaging network. + */ QMF_EXTERN void close(); - QMF_EXTERN bool nextEvent(ConsoleEvent&, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + + /** + * Get the next event from the console session. Events represent actions that must be acted upon by the + * console application. This method blocks for up to the timeout if there are no events to be handled. + * This method will typically be the focus of the console application's main execution loop. + * If the timeout is set to Duration::IMMEDIATE, the call will not block. + */ + QMF_EXTERN bool nextEvent(ConsoleEvent& outEvent, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + + /** + * Return the number of events pending for nextEvent. This method will never block. + */ + QMF_EXTERN int pendingEvents() const; + + /** + * getAgentCount, getAgent - Retrieve the set of agents that match the console session's agent filter. + */ QMF_EXTERN uint32_t getAgentCount() const; - QMF_EXTERN Agent getAgent(uint32_t) const; + QMF_EXTERN Agent getAgent(uint32_t agentIndex) const; + + /** + * Get the agent for the connected broker (i.e. the agent embedded in the broker to which we have a connection). + */ QMF_EXTERN Agent getConnectedBrokerAgent() const; /** @@ -79,12 +117,13 @@ namespace qmf { * 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 = ""); + QMF_EXTERN Subscription subscribe(const Query& query, const std::string& agentFilter = "", const std::string& options = ""); + QMF_EXTERN Subscription subscribe(const std::string& query, const std::string& agentFilter = "", const std::string& options = ""); #ifndef SWIG private: friend class qmf::PrivateImplRef<ConsoleSession>; + friend struct ConsoleSessionImplAccess; #endif }; diff --git a/cpp/include/qmf/Data.h b/cpp/include/qmf/Data.h index 82f1569a0b..487a02fe95 100644 --- a/cpp/include/qmf/Data.h +++ b/cpp/include/qmf/Data.h @@ -39,7 +39,7 @@ namespace qmf { class DataAddr; class Agent; - class Data : public qmf::Handle<DataImpl> { + class QMF_CLASS_EXTERN Data : public qmf::Handle<DataImpl> { public: QMF_EXTERN Data(DataImpl* impl = 0); QMF_EXTERN Data(const Data&); diff --git a/cpp/include/qmf/DataAddr.h b/cpp/include/qmf/DataAddr.h index 72de0c986a..20c469081e 100644 --- a/cpp/include/qmf/DataAddr.h +++ b/cpp/include/qmf/DataAddr.h @@ -34,7 +34,7 @@ namespace qmf { class DataAddrImpl; - class DataAddr : public qmf::Handle<DataAddrImpl> { + class QMF_CLASS_EXTERN DataAddr : public qmf::Handle<DataAddrImpl> { public: QMF_EXTERN DataAddr(DataAddrImpl* impl = 0); QMF_EXTERN DataAddr(const DataAddr&); @@ -51,6 +51,9 @@ namespace qmf { QMF_EXTERN uint32_t getAgentEpoch() const; QMF_EXTERN qpid::types::Variant::Map asMap() const; + QMF_EXTERN bool operator==(const DataAddr&) const; + QMF_EXTERN bool operator<(const DataAddr&) const; + #ifndef SWIG private: friend class qmf::PrivateImplRef<DataAddr>; diff --git a/cpp/include/qmf/Handle.h b/cpp/include/qmf/Handle.h index 510e2993aa..50971ea626 100644 --- a/cpp/include/qmf/Handle.h +++ b/cpp/include/qmf/Handle.h @@ -39,22 +39,22 @@ template <class T> class Handle { public: /**@return true if handle is valid, i.e. not null. */ - QMF_EXTERN bool isValid() const { return impl; } + QMF_INLINE_EXTERN bool isValid() const { return impl; } /**@return true if handle is null. It is an error to call any function on a null handle. */ - QMF_EXTERN bool isNull() const { return !impl; } + QMF_INLINE_EXTERN bool isNull() const { return !impl; } /** Conversion to bool supports idiom if (handle) { handle->... } */ - QMF_EXTERN operator bool() const { return impl; } + QMF_INLINE_EXTERN operator bool() const { return impl; } /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ - QMF_EXTERN bool operator !() const { return !impl; } + QMF_INLINE_EXTERN bool operator !() const { return !impl; } void swap(Handle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; } protected: typedef T Impl; - QMF_EXTERN Handle() :impl() {} + QMF_INLINE_EXTERN Handle() :impl() {} // Not implemented,subclasses must implement. QMF_EXTERN Handle(const Handle&); diff --git a/cpp/include/qmf/ImportExport.h b/cpp/include/qmf/ImportExport.h index f5e1d9127c..7405c15259 100644 --- a/cpp/include/qmf/ImportExport.h +++ b/cpp/include/qmf/ImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -# if defined(QMF_EXPORT) || defined (qmfcommon_EXPORTS) -# define QMF_EXTERN __declspec(dllexport) -# else -# define QMF_EXTERN __declspec(dllimport) -# endif +#include "qpid/ImportExport.h" + +#if defined(QMF_EXPORT) || defined (qmf2_EXPORTS) +# define QMF_EXTERN QPID_EXPORT +# define QMF_CLASS_EXTERN QPID_CLASS_EXPORT +# define QMF_INLINE_EXTERN QPID_INLINE_EXPORT #else -# define QMF_EXTERN +# define QMF_EXTERN QPID_IMPORT +# define QMF_CLASS_EXTERN QPID_CLASS_IMPORT +# define QMF_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif diff --git a/cpp/include/qmf/Query.h b/cpp/include/qmf/Query.h index fec4660bd7..c1264f8901 100644 --- a/cpp/include/qmf/Query.h +++ b/cpp/include/qmf/Query.h @@ -43,7 +43,7 @@ namespace qmf { QUERY_SCHEMA_ID = 4 }; - class Query : public qmf::Handle<QueryImpl> { + class QMF_CLASS_EXTERN Query : public qmf::Handle<QueryImpl> { public: QMF_EXTERN Query(QueryImpl* impl = 0); QMF_EXTERN Query(const Query&); @@ -65,7 +65,7 @@ namespace qmf { #ifndef SWIG private: friend class qmf::PrivateImplRef<Query>; - friend class QueryImplAccess; + friend struct QueryImplAccess; #endif }; diff --git a/cpp/include/qmf/Schema.h b/cpp/include/qmf/Schema.h index cf316138c1..6cfd2e2a56 100644 --- a/cpp/include/qmf/Schema.h +++ b/cpp/include/qmf/Schema.h @@ -38,7 +38,7 @@ namespace qmf { class SchemaProperty; class SchemaMethod; - class Schema : public qmf::Handle<SchemaImpl> { + class QMF_CLASS_EXTERN Schema : public qmf::Handle<SchemaImpl> { public: QMF_EXTERN Schema(SchemaImpl* impl = 0); QMF_EXTERN Schema(const Schema&); diff --git a/cpp/include/qmf/SchemaId.h b/cpp/include/qmf/SchemaId.h index 13fb1cb902..2dafc1c091 100644 --- a/cpp/include/qmf/SchemaId.h +++ b/cpp/include/qmf/SchemaId.h @@ -35,7 +35,7 @@ namespace qmf { class SchemaIdImpl; - class SchemaId : public qmf::Handle<SchemaIdImpl> { + class QMF_CLASS_EXTERN SchemaId : public qmf::Handle<SchemaIdImpl> { public: QMF_EXTERN SchemaId(SchemaIdImpl* impl = 0); QMF_EXTERN SchemaId(const SchemaId&); diff --git a/cpp/include/qmf/SchemaMethod.h b/cpp/include/qmf/SchemaMethod.h index 47302b62b9..b5944dc29e 100644 --- a/cpp/include/qmf/SchemaMethod.h +++ b/cpp/include/qmf/SchemaMethod.h @@ -36,7 +36,7 @@ namespace qmf { class SchemaMethodImpl; class SchemaProperty; - class SchemaMethod : public qmf::Handle<SchemaMethodImpl> { + class QMF_CLASS_EXTERN SchemaMethod : public qmf::Handle<SchemaMethodImpl> { public: QMF_EXTERN SchemaMethod(SchemaMethodImpl* impl = 0); QMF_EXTERN SchemaMethod(const SchemaMethod&); diff --git a/cpp/include/qmf/SchemaProperty.h b/cpp/include/qmf/SchemaProperty.h index a3a328b60b..bbb603fa50 100644 --- a/cpp/include/qmf/SchemaProperty.h +++ b/cpp/include/qmf/SchemaProperty.h @@ -36,7 +36,7 @@ namespace qmf { class SchemaPropertyImpl; - class SchemaProperty : public Handle<SchemaPropertyImpl> { + class QMF_CLASS_EXTERN SchemaProperty : public Handle<SchemaPropertyImpl> { public: QMF_EXTERN SchemaProperty(SchemaPropertyImpl* impl = 0); QMF_EXTERN SchemaProperty(const SchemaProperty&); diff --git a/cpp/include/qmf/Subscription.h b/cpp/include/qmf/Subscription.h index 4e60eb984e..398a45b922 100644 --- a/cpp/include/qmf/Subscription.h +++ b/cpp/include/qmf/Subscription.h @@ -35,7 +35,7 @@ namespace qmf { class SubscriptionImpl; class Data; - class Subscription : public qmf::Handle<SubscriptionImpl> { + class QMF_CLASS_EXTERN Subscription : public qmf::Handle<SubscriptionImpl> { public: QMF_EXTERN Subscription(SubscriptionImpl* impl = 0); QMF_EXTERN Subscription(const Subscription&); @@ -73,7 +73,7 @@ namespace qmf { #ifndef SWIG private: friend class qmf::PrivateImplRef<Subscription>; - friend class SubscriptionImplAccess; + friend struct SubscriptionImplAccess; #endif }; diff --git a/cpp/include/qmf/engine/QmfEngineImportExport.h b/cpp/include/qmf/engine/QmfEngineImportExport.h index 373617e046..cf8fffdb17 100644 --- a/cpp/include/qmf/engine/QmfEngineImportExport.h +++ b/cpp/include/qmf/engine/QmfEngineImportExport.h @@ -26,8 +26,17 @@ # else # define QMFE_EXTERN __declspec(dllimport) # endif +# ifdef _MSC_VER +# define QMFE_CLASS_EXTERN +# define QMFE_INLINE_EXTERN QMFE_EXTERN +# else +# define QMFE_CLASS_EXTERN QMFE_EXTERN +# define QMFE_INLINE_EXTERN +# endif #else # define QMFE_EXTERN +# define QMFE_CLASS_EXTERN +# define QMFE_INLINE_EXTERN #endif #endif diff --git a/cpp/include/qmf/exceptions.h b/cpp/include/qmf/exceptions.h index 7959499d63..c7ffa68ce2 100644 --- a/cpp/include/qmf/exceptions.h +++ b/cpp/include/qmf/exceptions.h @@ -31,24 +31,24 @@ namespace qmf { /** \ingroup qmf */ - struct QmfException : public qpid::types::Exception { + struct QMF_CLASS_EXTERN QmfException : public qpid::types::Exception { QMF_EXTERN QmfException(const std::string& msg); QMF_EXTERN virtual ~QmfException() throw(); qpid::types::Variant::Map detail; }; - struct KeyNotFound : public QmfException { + struct QMF_CLASS_EXTERN KeyNotFound : public QmfException { QMF_EXTERN KeyNotFound(const std::string& msg); QMF_EXTERN virtual ~KeyNotFound() throw(); }; - struct IndexOutOfRange : public QmfException { + struct QMF_CLASS_EXTERN IndexOutOfRange : public QmfException { QMF_EXTERN IndexOutOfRange(); QMF_EXTERN virtual ~IndexOutOfRange() throw(); }; - struct OperationTimedOut : public QmfException { + struct QMF_CLASS_EXTERN OperationTimedOut : public QmfException { QMF_EXTERN OperationTimedOut(); QMF_EXTERN virtual ~OperationTimedOut() throw(); }; diff --git a/cpp/include/qmf/posix/EventNotifier.h b/cpp/include/qmf/posix/EventNotifier.h new file mode 100644 index 0000000000..ebc1cb5364 --- /dev/null +++ b/cpp/include/qmf/posix/EventNotifier.h @@ -0,0 +1,63 @@ +#ifndef __QMF_POSIX_EVENT_NOTIFIER_H +#define __QMF_POSIX_EVENT_NOTIFIER_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 "qmf/AgentSession.h" +#include "qmf/ConsoleSession.h" + +namespace qmf { + + class PosixEventNotifierImpl; + class PosixEventNotifierImplAccess; + +namespace posix { + +#ifndef SWIG + template <class> class PrivateImplRef; +#endif + + class QMF_CLASS_EXTERN EventNotifier : public qmf::Handle<qmf::PosixEventNotifierImpl> { + public: + QMF_EXTERN EventNotifier(PosixEventNotifierImpl* impl = 0); + QMF_EXTERN EventNotifier(::qmf::AgentSession& agentSession); + QMF_EXTERN EventNotifier(::qmf::ConsoleSession& consoleSession); + QMF_EXTERN EventNotifier(const EventNotifier& that); + + QMF_EXTERN ~EventNotifier(); + + QMF_EXTERN EventNotifier& operator=(const EventNotifier& that); + + QMF_EXTERN int getHandle() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef<EventNotifier>; + friend struct qmf::PosixEventNotifierImplAccess; +#endif + + }; + +}} + +#endif + diff --git a/cpp/include/qpid/Address.h b/cpp/include/qpid/Address.h index 57c9139f87..f5b19d0532 100755 --- a/cpp/include/qpid/Address.h +++ b/cpp/include/qpid/Address.h @@ -36,7 +36,7 @@ public: static const std::string TCP; // Default TCP protocol tag. static const uint16_t AMQP_PORT=5672; // Default AMQP port. - QPID_COMMON_EXTERN explicit Address( + QPID_COMMON_INLINE_EXTERN explicit Address( const std::string& protocol_=std::string(), const std::string& host_=std::string(), uint16_t port_=0 diff --git a/cpp/include/qpid/CommonImportExport.h b/cpp/include/qpid/CommonImportExport.h index 02c06ed7af..dd2b900b73 100644 --- a/cpp/include/qpid/CommonImportExport.h +++ b/cpp/include/qpid/CommonImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#include "qpid/ImportExport.h" + #if defined(COMMON_EXPORT) || defined (qpidcommon_EXPORTS) -#define QPID_COMMON_EXTERN __declspec(dllexport) -#else -#define QPID_COMMON_EXTERN __declspec(dllimport) -#endif +# define QPID_COMMON_EXTERN QPID_EXPORT +# define QPID_COMMON_CLASS_EXTERN QPID_CLASS_EXPORT +# define QPID_COMMON_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QPID_COMMON_EXTERN +# define QPID_COMMON_EXTERN QPID_IMPORT +# define QPID_COMMON_CLASS_EXTERN QPID_CLASS_IMPORT +# define QPID_COMMON_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif diff --git a/cpp/include/qpid/Exception.h b/cpp/include/qpid/Exception.h index fa7111160c..cbd175214d 100644 --- a/cpp/include/qpid/Exception.h +++ b/cpp/include/qpid/Exception.h @@ -36,7 +36,7 @@ namespace qpid /** * Base class for Qpid runtime exceptions. */ -class Exception : public std::exception +class QPID_COMMON_CLASS_EXTERN Exception : public std::exception { public: QPID_COMMON_EXTERN explicit Exception(const std::string& message=std::string()) throw(); @@ -51,30 +51,30 @@ class Exception : public std::exception }; /** Exception that includes an errno message. */ -struct ErrnoException : public Exception { +struct QPID_COMMON_CLASS_EXTERN ErrnoException : public Exception { ErrnoException(const std::string& msg, int err) : Exception(msg+": "+qpid::sys::strError(err)) {} ErrnoException(const std::string& msg) : Exception(msg+": "+qpid::sys::strError(errno)) {} }; -struct SessionException : public Exception { +struct QPID_COMMON_CLASS_EXTERN SessionException : public Exception { const framing::execution::ErrorCode code; SessionException(framing::execution::ErrorCode code_, const std::string& message) : Exception(message), code(code_) {} }; -struct ChannelException : public Exception { +struct QPID_COMMON_CLASS_EXTERN ChannelException : public Exception { const framing::session::DetachCode code; ChannelException(framing::session::DetachCode _code, const std::string& message) : Exception(message), code(_code) {} }; -struct ConnectionException : public Exception { +struct QPID_COMMON_CLASS_EXTERN ConnectionException : public Exception { const framing::connection::CloseCode code; ConnectionException(framing::connection::CloseCode _code, const std::string& message) : Exception(message), code(_code) {} }; -struct ClosedException : public Exception { +struct QPID_COMMON_CLASS_EXTERN ClosedException : public Exception { QPID_COMMON_EXTERN ClosedException(const std::string& msg=std::string()); QPID_COMMON_EXTERN std::string getPrefix() const; }; diff --git a/cpp/include/qpid/ImportExport.h b/cpp/include/qpid/ImportExport.h new file mode 100644 index 0000000000..e62399faf7 --- /dev/null +++ b/cpp/include/qpid/ImportExport.h @@ -0,0 +1,71 @@ +#ifndef QPID_IMPORTEXPORT_H +#define QPID_IMPORTEXPORT_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. + */ + +// +// This header file defines the following macros for the control of library/DLL +// import and export: +// +// QPID_EXPORT - Export declaration for Methods +// QPID_CLASS_EXPORT - Export declaration for Classes +// QPID_INLINE_EXPORT - Export declaration for Inline methods +// +// QPID_IMPORT - Import declaration for Methods +// QPID_CLASS_IMPORT - Import declaration for Classes +// QPID_INLINE_IMPORT - Import declaration for Inline methods +// + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) + // + // Import and Export definitions for Windows: + // +# define QPID_EXPORT __declspec(dllexport) +# define QPID_IMPORT __declspec(dllimport) +# ifdef _MSC_VER + // + // Specific to the Microsoft compiler: + // +# define QPID_CLASS_EXPORT +# define QPID_CLASS_IMPORT +# define QPID_INLINE_EXPORT QPID_EXPORT +# define QPID_INLINE_IMPORT QPID_IMPORT +# else + // + // Specific to non-Microsoft compilers (mingw32): + // +# define QPID_CLASS_EXPORT QPID_EXPORT +# define QPID_CLASS_IMPORT QPID_IMPORT +# define QPID_INLINE_EXPORT +# define QPID_INLINE_IMPORT +# endif +#else + // + // Non-Windows (Linux, etc.) definitions: + // +# define QPID_EXPORT +# define QPID_IMPORT +# define QPID_CLASS_EXPORT +# define QPID_CLASS_IMPORT +# define QPID_INLINE_EXPORT +# define QPID_INLINE_IMPORT +#endif + +#endif /*!QPID_IMPORTEXPORT_H*/ diff --git a/cpp/include/qpid/Msg.h b/cpp/include/qpid/Msg.h index e1837c29e5..5f0b11bc60 100644 --- a/cpp/include/qpid/Msg.h +++ b/cpp/include/qpid/Msg.h @@ -24,6 +24,7 @@ #include <sstream> #include <iostream> +#include "qpid/types/ImportExport.h" namespace qpid { diff --git a/cpp/include/qpid/Options.h b/cpp/include/qpid/Options.h index 078a6b4d95..63d91c2d72 100644 --- a/cpp/include/qpid/Options.h +++ b/cpp/include/qpid/Options.h @@ -133,77 +133,6 @@ inline po::value_semantic* optValue(bool& value) { return po::bool_switch(&value -/* - * --------------------------------------------- - * Explanation for Boost 103200 conditional code - * --------------------------------------------- - * - * This boost version has an implementation of the program_options library - * that has no provision for allowing unregistered options to pass by. - * - * But that means that, if you have a program that loads optional modules - * after start-up, and those modules each have their own set of options, - * then if you parse the command line too soon, you will get spurious - * reports of unrecognized options -- and the program will exit! - * - * And we must process the command-line before module-loading, because we - * need to look at the "bootstrap" options. - * - * This conditional code: - * - * 1. implements it's own functor class, derived from the Boost - * "options_description_easy_init" class. This functor is used - * to process added options and do the functor chaining, so that - * I can snoop on the arguments before doing an explicit call - * to its parent. - * - * 2. It implements two static vectors, one to hold long names, and - * one for short names, so that options declared by modules are - * not forgotten when their options_description goes out of scope. - * - * I will be thrilled to personally delete this code if we ever decide - * that qpid doesn't really need to support this antique version of Boost. - * - */ - -#if ( BOOST_VERSION == 103200 ) -struct Options; - - -struct -options_description_less_easy_init - : public po::options_description_easy_init -{ - options_description_less_easy_init ( Options * my_owner, - po::options_description * my_parents_owner - ) - : po::options_description_easy_init(my_parents_owner) - { - owner = my_owner; - } - - - options_description_less_easy_init& - operator()(char const * name, - char const * description); - - - options_description_less_easy_init& - operator()(char const * name, - const po::value_semantic* s); - - - options_description_less_easy_init& - operator()(const char* name, - const po::value_semantic* s, - const char* description); - - - Options * owner; -}; -#endif - - struct Options : public po::options_description { struct Exception : public qpid::Exception { @@ -222,26 +151,9 @@ struct Options : public po::options_description { bool allowUnknown = false); - #if ( BOOST_VERSION == 103200 ) - options_description_less_easy_init m_less_easy; - - options_description_less_easy_init addOptions() { - return m_less_easy; - } - - bool - is_registered_option ( std::string s ); - - void - register_names ( std::string s ); - - static std::vector<std::string> long_names; - static std::vector<std::string> short_names; - #else boost::program_options::options_description_easy_init addOptions() { return add_options(); } - #endif }; diff --git a/cpp/include/qpid/Url.h b/cpp/include/qpid/Url.h index 353e9d5599..915b08ac5f 100644 --- a/cpp/include/qpid/Url.h +++ b/cpp/include/qpid/Url.h @@ -66,7 +66,7 @@ struct Url : public std::vector<Address> { *@exception Invalid if the url is invalid. */ QPID_COMMON_EXTERN void parse(const char* url); - QPID_COMMON_EXTERN void parse(const std::string& url) { parse(url.c_str()); } + QPID_COMMON_INLINE_EXTERN void parse(const std::string& url) { parse(url.c_str()); } /** Replace contesnts with parsed URL. Replace with empty URL if invalid. */ QPID_COMMON_EXTERN void parseNoThrow(const char* url); diff --git a/cpp/include/qpid/agent/ManagementAgent.h b/cpp/include/qpid/agent/ManagementAgent.h index e2451244c1..10bc6527a9 100644 --- a/cpp/include/qpid/agent/ManagementAgent.h +++ b/cpp/include/qpid/agent/ManagementAgent.h @@ -110,8 +110,8 @@ class ManagementAgent uint16_t intervalSeconds = 10, bool useExternalThread = false, const std::string& storeFile = "", - const std::string& uid = "guest", - const std::string& pwd = "guest", + const std::string& uid = "", + const std::string& pwd = "", const std::string& mech = "PLAIN", const std::string& proto = "tcp") = 0; diff --git a/cpp/include/qpid/agent/QmfAgentImportExport.h b/cpp/include/qpid/agent/QmfAgentImportExport.h index e41425a7ba..3f923ac4b2 100644 --- a/cpp/include/qpid/agent/QmfAgentImportExport.h +++ b/cpp/include/qpid/agent/QmfAgentImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -#if defined (qmf_EXPORTS) -#define QMF_AGENT_EXTERN __declspec(dllexport) -#else -#define QMF_AGENT_EXTERN __declspec(dllimport) -#endif +#include "qpid/ImportExport.h" + +#if defined(QMF_EXPORT) || defined (qmf_EXPORTS) +# define QMF_AGENT_EXTERN QPID_EXPORT +# define QMF_AGENT_CLASS_EXTERN QPID_CLASS_EXPORT +# define QMF_AGENT_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QMF_AGENT_EXTERN +# define QMF_AGENT_EXTERN QPID_IMPORT +# define QMF_AGENT_CLASS_EXTERN QPID_CLASS_IMPORT +# define QMF_AGENT_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif diff --git a/cpp/include/qpid/amqp_0_10/Codecs.h b/cpp/include/qpid/amqp_0_10/Codecs.h index 08275402fc..73846f33a8 100644 --- a/cpp/include/qpid/amqp_0_10/Codecs.h +++ b/cpp/include/qpid/amqp_0_10/Codecs.h @@ -34,14 +34,14 @@ namespace amqp_0_10 { * Codec for encoding/decoding a map of Variants using the AMQP 0-10 * map encoding. */ -class QPID_COMMON_EXTERN MapCodec +class QPID_COMMON_CLASS_EXTERN MapCodec { public: typedef qpid::types::Variant::Map ObjectType; - static void encode(const ObjectType&, std::string&); - static void decode(const std::string&, ObjectType&); - static size_t encodedSize(const ObjectType&); - static const std::string contentType; + static void QPID_COMMON_EXTERN encode(const ObjectType&, std::string&); + static void QPID_COMMON_EXTERN decode(const std::string&, ObjectType&); + static size_t QPID_COMMON_EXTERN encodedSize(const ObjectType&); + static const QPID_COMMON_EXTERN std::string contentType; private: }; @@ -49,14 +49,14 @@ class QPID_COMMON_EXTERN MapCodec * Codec for encoding/decoding a list of Variants using the AMQP 0-10 * list encoding. */ -class QPID_COMMON_EXTERN ListCodec +class QPID_COMMON_CLASS_EXTERN ListCodec { public: typedef qpid::types::Variant::List ObjectType; - static void encode(const ObjectType&, std::string&); - static void decode(const std::string&, ObjectType&); - static size_t encodedSize(const ObjectType&); - static const std::string contentType; + static void QPID_COMMON_EXTERN encode(const ObjectType&, std::string&); + static void QPID_COMMON_EXTERN decode(const std::string&, ObjectType&); + static size_t QPID_COMMON_EXTERN encodedSize(const ObjectType&); + static const QPID_COMMON_EXTERN std::string contentType; private: }; diff --git a/cpp/include/qpid/client/ClientImportExport.h b/cpp/include/qpid/client/ClientImportExport.h index 42b02e33c3..2a3a5a52e9 100644 --- a/cpp/include/qpid/client/ClientImportExport.h +++ b/cpp/include/qpid/client/ClientImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#include "qpid/ImportExport.h" + #if defined(CLIENT_EXPORT) || defined (qpidclient_EXPORTS) -#define QPID_CLIENT_EXTERN __declspec(dllexport) -#else -#define QPID_CLIENT_EXTERN __declspec(dllimport) -#endif +# define QPID_CLIENT_EXTERN QPID_EXPORT +# define QPID_CLIENT_CLASS_EXTERN QPID_CLASS_EXPORT +# define QPID_CLIENT_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QPID_CLIENT_EXTERN +# define QPID_CLIENT_EXTERN QPID_IMPORT +# define QPID_CLIENT_CLASS_EXTERN QPID_CLASS_IMPORT +# define QPID_CLIENT_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif diff --git a/cpp/include/qpid/client/Completion.h b/cpp/include/qpid/client/Completion.h index 99d940f031..9546db9258 100644 --- a/cpp/include/qpid/client/Completion.h +++ b/cpp/include/qpid/client/Completion.h @@ -41,7 +41,7 @@ template <class T> class PrivateImplRef; * *\ingroup clientapi */ -class Completion : public Handle<CompletionImpl> +class QPID_CLIENT_CLASS_EXTERN Completion : public Handle<CompletionImpl> { public: QPID_CLIENT_EXTERN Completion(CompletionImpl* = 0); diff --git a/cpp/include/qpid/client/Connection.h b/cpp/include/qpid/client/Connection.h index 6ed0d98bc0..c0db0f301d 100644 --- a/cpp/include/qpid/client/Connection.h +++ b/cpp/include/qpid/client/Connection.h @@ -60,7 +60,7 @@ class ConnectionImpl; * */ -class Connection +class QPID_CLIENT_CLASS_EXTERN Connection { framing::ProtocolVersion version; @@ -102,8 +102,8 @@ class Connection * within a single broker). */ QPID_CLIENT_EXTERN void open(const std::string& host, int port = 5672, - const std::string& uid = "guest", - const std::string& pwd = "guest", + const std::string& uid = "", + const std::string& pwd = "", const std::string& virtualhost = "/", uint16_t maxFrameSize=65535); /** @@ -124,8 +124,8 @@ class Connection * within a single broker). */ QPID_CLIENT_EXTERN void open(const Url& url, - const std::string& uid = "guest", - const std::string& pwd = "guest", + const std::string& uid = "", + const std::string& pwd = "", const std::string& virtualhost = "/", uint16_t maxFrameSize=65535); /** diff --git a/cpp/include/qpid/client/ConnectionSettings.h b/cpp/include/qpid/client/ConnectionSettings.h index 1c2ee28b1b..2b6b86f891 100644 --- a/cpp/include/qpid/client/ConnectionSettings.h +++ b/cpp/include/qpid/client/ConnectionSettings.h @@ -37,7 +37,7 @@ namespace client { /** * Settings for a Connection. */ -struct ConnectionSettings { +struct QPID_CLIENT_CLASS_EXTERN ConnectionSettings { QPID_CLIENT_EXTERN ConnectionSettings(); QPID_CLIENT_EXTERN virtual ~ConnectionSettings(); diff --git a/cpp/include/qpid/client/FailoverListener.h b/cpp/include/qpid/client/FailoverListener.h index 59108eb7cb..53c7c26211 100644 --- a/cpp/include/qpid/client/FailoverListener.h +++ b/cpp/include/qpid/client/FailoverListener.h @@ -48,7 +48,7 @@ namespace client { * FailoverListener::decode to extract a list of broker URLs from a * failover exchange message. */ -class FailoverListener : private MessageListener, private qpid::sys::Runnable +class QPID_CLIENT_CLASS_EXTERN FailoverListener : private MessageListener, private qpid::sys::Runnable { public: /** The name of the standard failover exchange amq.failover */ diff --git a/cpp/include/qpid/client/FailoverManager.h b/cpp/include/qpid/client/FailoverManager.h index 0d30e2ed60..d3a0dbc976 100644 --- a/cpp/include/qpid/client/FailoverManager.h +++ b/cpp/include/qpid/client/FailoverManager.h @@ -42,7 +42,7 @@ struct CannotConnectException : qpid::Exception /** * Utility to manage failover. */ -class FailoverManager +class QPID_CLIENT_CLASS_EXTERN FailoverManager { public: /** diff --git a/cpp/include/qpid/client/Future.h b/cpp/include/qpid/client/Future.h index 09088e68f6..630a7e03c0 100644 --- a/cpp/include/qpid/client/Future.h +++ b/cpp/include/qpid/client/Future.h @@ -34,7 +34,7 @@ namespace qpid { namespace client { /**@internal */ -class Future +class QPID_CLIENT_CLASS_EXTERN Future { framing::SequenceNumber command; boost::shared_ptr<FutureResult> result; diff --git a/cpp/include/qpid/client/FutureResult.h b/cpp/include/qpid/client/FutureResult.h index b2b663daa1..ead4929571 100644 --- a/cpp/include/qpid/client/FutureResult.h +++ b/cpp/include/qpid/client/FutureResult.h @@ -34,7 +34,7 @@ namespace client { class SessionImpl; ///@internal -class FutureResult : public FutureCompletion +class QPID_CLIENT_CLASS_EXTERN FutureResult : public FutureCompletion { std::string result; public: diff --git a/cpp/include/qpid/client/Handle.h b/cpp/include/qpid/client/Handle.h index 088e836fcf..b8315481a9 100644 --- a/cpp/include/qpid/client/Handle.h +++ b/cpp/include/qpid/client/Handle.h @@ -40,22 +40,22 @@ template <class T> class Handle { public: /**@return true if handle is valid, i.e. not null. */ - QPID_CLIENT_EXTERN bool isValid() const { return impl; } + QPID_CLIENT_INLINE_EXTERN bool isValid() const { return impl; } /**@return true if handle is null. It is an error to call any function on a null handle. */ - QPID_CLIENT_EXTERN bool isNull() const { return !impl; } + QPID_CLIENT_INLINE_EXTERN bool isNull() const { return !impl; } /** Conversion to bool supports idiom if (handle) { handle->... } */ - QPID_CLIENT_EXTERN operator bool() const { return impl; } + QPID_CLIENT_INLINE_EXTERN operator bool() const { return impl; } /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ - QPID_CLIENT_EXTERN bool operator !() const { return !impl; } + QPID_CLIENT_INLINE_EXTERN bool operator !() const { return !impl; } void swap(Handle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; } protected: typedef T Impl; - QPID_CLIENT_EXTERN Handle() :impl() {} + QPID_CLIENT_INLINE_EXTERN Handle() :impl() {} // Not implemented,subclasses must implement. QPID_CLIENT_EXTERN Handle(const Handle&); diff --git a/cpp/include/qpid/client/LocalQueue.h b/cpp/include/qpid/client/LocalQueue.h index 70e4cebcf1..1a19a8499d 100644 --- a/cpp/include/qpid/client/LocalQueue.h +++ b/cpp/include/qpid/client/LocalQueue.h @@ -71,7 +71,7 @@ template <class T> class PrivateImplRef; * </ul> */ -class LocalQueue : public Handle<LocalQueueImpl> { +class QPID_CLIENT_CLASS_EXTERN LocalQueue : public Handle<LocalQueueImpl> { public: /** Create a local queue. Subscribe the local queue to a remote broker * queue with a SubscriptionManager. diff --git a/cpp/include/qpid/client/Message.h b/cpp/include/qpid/client/Message.h index 2401cbdc92..ba50dda9ba 100644 --- a/cpp/include/qpid/client/Message.h +++ b/cpp/include/qpid/client/Message.h @@ -112,7 +112,7 @@ class MessageImpl; * * */ -class Message +class QPID_CLIENT_CLASS_EXTERN Message { public: /** Create a Message. diff --git a/cpp/include/qpid/client/MessageListener.h b/cpp/include/qpid/client/MessageListener.h index d200f8cf21..3ca2fa964a 100644 --- a/cpp/include/qpid/client/MessageListener.h +++ b/cpp/include/qpid/client/MessageListener.h @@ -84,7 +84,7 @@ namespace client { * */ - class MessageListener{ + class QPID_CLIENT_CLASS_EXTERN MessageListener{ public: QPID_CLIENT_EXTERN virtual ~MessageListener(); diff --git a/cpp/include/qpid/client/MessageReplayTracker.h b/cpp/include/qpid/client/MessageReplayTracker.h index 6f5a0f4ac3..06a3f29c7d 100644 --- a/cpp/include/qpid/client/MessageReplayTracker.h +++ b/cpp/include/qpid/client/MessageReplayTracker.h @@ -34,7 +34,7 @@ namespace client { * Utility to track messages sent asynchronously, allowing those that * are indoubt to be replayed over a new session. */ -class MessageReplayTracker +class QPID_CLIENT_CLASS_EXTERN MessageReplayTracker { public: QPID_CLIENT_EXTERN MessageReplayTracker(uint flushInterval); diff --git a/cpp/include/qpid/client/QueueOptions.h b/cpp/include/qpid/client/QueueOptions.h index f8a4963f06..3984b63fdd 100644 --- a/cpp/include/qpid/client/QueueOptions.h +++ b/cpp/include/qpid/client/QueueOptions.h @@ -35,7 +35,7 @@ enum QueueOrderingPolicy {FIFO, LVQ, LVQ_NO_BROWSE}; * A help class to set options on the Queue. Create a configured args while * still allowing any custom configuration via the FieldTable base class */ -class QueueOptions: public framing::FieldTable +class QPID_CLIENT_CLASS_EXTERN QueueOptions: public framing::FieldTable { public: QPID_CLIENT_EXTERN QueueOptions(); diff --git a/cpp/include/qpid/client/SessionBase_0_10.h b/cpp/include/qpid/client/SessionBase_0_10.h index 3b5c84e74b..ea50ab32f7 100644 --- a/cpp/include/qpid/client/SessionBase_0_10.h +++ b/cpp/include/qpid/client/SessionBase_0_10.h @@ -54,7 +54,7 @@ enum CreditUnit { MESSAGE_CREDIT=0, BYTE_CREDIT=1, UNLIMITED_CREDIT=0xFFFFFFFF } * Subclasses provide the AMQP commands for a given * version of the protocol. */ -class SessionBase_0_10 { +class QPID_CLIENT_CLASS_EXTERN SessionBase_0_10 { public: ///@internal diff --git a/cpp/include/qpid/client/Subscription.h b/cpp/include/qpid/client/Subscription.h index 425b6b92e2..bb9b98e8ff 100644 --- a/cpp/include/qpid/client/Subscription.h +++ b/cpp/include/qpid/client/Subscription.h @@ -39,7 +39,7 @@ class SubscriptionManager; * A handle to an active subscription. Provides methods to query the subscription status * and control acknowledgement (acquire and accept) of messages. */ -class Subscription : public Handle<SubscriptionImpl> { +class QPID_CLIENT_CLASS_EXTERN Subscription : public Handle<SubscriptionImpl> { public: QPID_CLIENT_EXTERN Subscription(SubscriptionImpl* = 0); QPID_CLIENT_EXTERN Subscription(const Subscription&); @@ -91,13 +91,13 @@ class Subscription : public Handle<SubscriptionImpl> { QPID_CLIENT_EXTERN void release(const SequenceSet& messageIds); /* Acquire a single message */ - QPID_CLIENT_EXTERN void acquire(const Message& m) { acquire(SequenceSet(m.getId())); } + QPID_CLIENT_INLINE_EXTERN void acquire(const Message& m) { acquire(SequenceSet(m.getId())); } /* Accept a single message */ - QPID_CLIENT_EXTERN void accept(const Message& m) { accept(SequenceSet(m.getId())); } + QPID_CLIENT_INLINE_EXTERN void accept(const Message& m) { accept(SequenceSet(m.getId())); } /* Release a single message */ - QPID_CLIENT_EXTERN void release(const Message& m) { release(SequenceSet(m.getId())); } + QPID_CLIENT_INLINE_EXTERN void release(const Message& m) { release(SequenceSet(m.getId())); } /** Get the session associated with this subscription */ QPID_CLIENT_EXTERN Session getSession() const; diff --git a/cpp/include/qpid/client/SubscriptionManager.h b/cpp/include/qpid/client/SubscriptionManager.h index e70e05f73a..b69819a8ff 100644 --- a/cpp/include/qpid/client/SubscriptionManager.h +++ b/cpp/include/qpid/client/SubscriptionManager.h @@ -94,7 +94,7 @@ class SubscriptionManagerImpl; * </ul> * */ -class SubscriptionManager : public sys::Runnable, public Handle<SubscriptionManagerImpl> +class QPID_CLIENT_CLASS_EXTERN SubscriptionManager : public sys::Runnable, public Handle<SubscriptionManagerImpl> { public: /** Create a new SubscriptionManager associated with a session */ diff --git a/cpp/include/qpid/console/Agent.h b/cpp/include/qpid/console/Agent.h index 97d75da250..629dd71dee 100644 --- a/cpp/include/qpid/console/Agent.h +++ b/cpp/include/qpid/console/Agent.h @@ -31,17 +31,17 @@ namespace console { * * \ingroup qmfconsoleapi */ - class QPID_CONSOLE_EXTERN Agent { + class QPID_CONSOLE_CLASS_EXTERN Agent { public: typedef std::vector<Agent*> Vector; - Agent(Broker* _broker, uint32_t _bank, const std::string& _label) : + QPID_CONSOLE_INLINE_EXTERN Agent(Broker* _broker, uint32_t _bank, const std::string& _label) : broker(_broker), brokerBank(broker->getBrokerBank()), agentBank(_bank), label(_label) {} - Broker* getBroker() const { return broker; } - uint32_t getBrokerBank() const { return brokerBank; } - uint32_t getAgentBank() const { return agentBank; } - const std::string& getLabel() const { return label; } + QPID_CONSOLE_INLINE_EXTERN Broker* getBroker() const { return broker; } + QPID_CONSOLE_INLINE_EXTERN uint32_t getBrokerBank() const { return brokerBank; } + QPID_CONSOLE_INLINE_EXTERN uint32_t getAgentBank() const { return agentBank; } + QPID_CONSOLE_INLINE_EXTERN const std::string& getLabel() const { return label; } private: Broker* broker; @@ -50,7 +50,7 @@ namespace console { const std::string label; }; - QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Agent& agent); + std::ostream& operator<<(std::ostream& o, const Agent& agent); } } diff --git a/cpp/include/qpid/console/Broker.h b/cpp/include/qpid/console/Broker.h index 0b2d1bcb61..c2ba8ac81f 100644 --- a/cpp/include/qpid/console/Broker.h +++ b/cpp/include/qpid/console/Broker.h @@ -55,12 +55,12 @@ namespace console { client::ConnectionSettings& settings); QPID_CONSOLE_EXTERN ~Broker(); - QPID_CONSOLE_EXTERN bool isConnected() const { return connected; } - QPID_CONSOLE_EXTERN const std::string& getError() const { return error; } - QPID_CONSOLE_EXTERN const std::string& getSessionId() const { return amqpSessionId; } - QPID_CONSOLE_EXTERN const framing::Uuid& getBrokerId() const { return brokerId; } - QPID_CONSOLE_EXTERN uint32_t getBrokerBank() const { return 1; } - QPID_CONSOLE_EXTERN void addBinding(const std::string& key) { + QPID_CONSOLE_INLINE_EXTERN bool isConnected() const { return connected; } + QPID_CONSOLE_INLINE_EXTERN const std::string& getError() const { return error; } + QPID_CONSOLE_INLINE_EXTERN const std::string& getSessionId() const { return amqpSessionId; } + QPID_CONSOLE_INLINE_EXTERN const framing::Uuid& getBrokerId() const { return brokerId; } + QPID_CONSOLE_INLINE_EXTERN uint32_t getBrokerBank() const { return 1; } + QPID_CONSOLE_INLINE_EXTERN void addBinding(const std::string& key) { connThreadBody.bindExchange("qpid.management", key); } QPID_CONSOLE_EXTERN std::string getUrl() const; @@ -123,10 +123,10 @@ namespace console { void setBrokerId(const framing::Uuid& id) { brokerId = id; } void appendAgents(std::vector<Agent*>& agents) const; - friend QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Broker& k); + friend std::ostream& operator<<(std::ostream& o, const Broker& k); }; - QPID_CONSOLE_EXTERN std::ostream& operator<<(std::ostream& o, const Broker& k); + std::ostream& operator<<(std::ostream& o, const Broker& k); } } diff --git a/cpp/include/qpid/console/ClassKey.h b/cpp/include/qpid/console/ClassKey.h index 95cd2627f1..5f7c50351a 100644 --- a/cpp/include/qpid/console/ClassKey.h +++ b/cpp/include/qpid/console/ClassKey.h @@ -33,24 +33,24 @@ namespace console { * * \ingroup qmfconsoleapi */ - class QPID_CONSOLE_EXTERN ClassKey { + class QPID_CONSOLE_CLASS_EXTERN ClassKey { public: - static const int HASH_SIZE = 16; + QPID_CONSOLE_EXTERN static const int HASH_SIZE = 16; - ClassKey(const std::string& package, const std::string& name, const uint8_t* hash); + QPID_CONSOLE_EXTERN ClassKey(const std::string& package, const std::string& name, const uint8_t* hash); - const std::string& getPackageName() const { return package; } - const std::string& getClassName() const { return name; } - const uint8_t* getHash() const { return hash; } - std::string getHashString() const; - std::string str() const; - bool operator==(const ClassKey& other) const; - bool operator!=(const ClassKey& other) const; - bool operator<(const ClassKey& other) const; - bool operator>(const ClassKey& other) const; - bool operator<=(const ClassKey& other) const; - bool operator>=(const ClassKey& other) const; - void encode(framing::Buffer& buffer) const; + const QPID_CONSOLE_EXTERN std::string& getPackageName() const { return package; } + const QPID_CONSOLE_EXTERN std::string& getClassName() const { return name; } + const QPID_CONSOLE_EXTERN uint8_t* getHash() const { return hash; } + QPID_CONSOLE_EXTERN std::string getHashString() const; + QPID_CONSOLE_EXTERN std::string str() const; + QPID_CONSOLE_EXTERN bool operator==(const ClassKey& other) const; + QPID_CONSOLE_EXTERN bool operator!=(const ClassKey& other) const; + QPID_CONSOLE_EXTERN bool operator<(const ClassKey& other) const; + QPID_CONSOLE_EXTERN bool operator>(const ClassKey& other) const; + QPID_CONSOLE_EXTERN bool operator<=(const ClassKey& other) const; + QPID_CONSOLE_EXTERN bool operator>=(const ClassKey& other) const; + QPID_CONSOLE_EXTERN void encode(framing::Buffer& buffer) const; private: std::string package; diff --git a/cpp/include/qpid/console/ConsoleImportExport.h b/cpp/include/qpid/console/ConsoleImportExport.h index c2d7cb3a14..aac30858f7 100644 --- a/cpp/include/qpid/console/ConsoleImportExport.h +++ b/cpp/include/qpid/console/ConsoleImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#include "qpid/ImportExport.h" + #if defined(CONSOLE_EXPORT) || defined (qmfconsole_EXPORTS) -#define QPID_CONSOLE_EXTERN __declspec(dllexport) -#else -#define QPID_CONSOLE_EXTERN __declspec(dllimport) -#endif +# define QPID_CONSOLE_EXTERN QPID_EXPORT +# define QPID_CONSOLE_CLASS_EXTERN QPID_CLASS_EXPORT +# define QPID_CONSOLE_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QPID_CONSOLE_EXTERN +# define QPID_CONSOLE_EXTERN QPID_IMPORT +# define QPID_CONSOLE_CLASS_EXTERN QPID_CLASS_IMPORT +# define QPID_CONSOLE_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif diff --git a/cpp/include/qpid/console/ObjectId.h b/cpp/include/qpid/console/ObjectId.h index 7904c85598..0722eaebeb 100644 --- a/cpp/include/qpid/console/ObjectId.h +++ b/cpp/include/qpid/console/ObjectId.h @@ -40,10 +40,10 @@ namespace console { ObjectId() : first(0), second(0) {} ObjectId(framing::Buffer& buffer); - uint8_t getFlags() const { return (first & 0xF000000000000000LL) >> 60; } - uint16_t getSequence() const { return (first & 0x0FFF000000000000LL) >> 48; } - uint32_t getBrokerBank() const { return (first & 0x0000FFFFF0000000LL) >> 28; } - uint32_t getAgentBank() const { return first & 0x000000000FFFFFFFLL; } + uint8_t getFlags() const { return (uint8_t)((first & 0xF000000000000000LL) >> 60); } + uint16_t getSequence() const { return (uint16_t)((first & 0x0FFF000000000000LL) >> 48); } + uint32_t getBrokerBank() const { return (uint32_t)((first & 0x0000FFFFF0000000LL) >> 28); } + uint32_t getAgentBank() const { return (uint32_t) (first & 0x000000000FFFFFFFLL); } uint64_t getObject() const { return second; } bool isDurable() const { return getSequence() == 0; } void decode(framing::Buffer& buffer); diff --git a/cpp/include/qpid/framing/Array.h b/cpp/include/qpid/framing/Array.h index d3bdd36aa6..1e97be3bb4 100644 --- a/cpp/include/qpid/framing/Array.h +++ b/cpp/include/qpid/framing/Array.h @@ -34,7 +34,7 @@ namespace framing { class Buffer; -class Array +class QPID_COMMON_CLASS_EXTERN Array { public: typedef boost::shared_ptr<FieldValue> ValuePtr; @@ -55,25 +55,25 @@ class Array //creates a longstr array QPID_COMMON_EXTERN Array(const std::vector<std::string>& in); - QPID_COMMON_EXTERN TypeCode getType() const { return type; } + QPID_COMMON_INLINE_EXTERN TypeCode getType() const { return type; } // std collection interface. - QPID_COMMON_EXTERN const_iterator begin() const { return values.begin(); } - QPID_COMMON_EXTERN const_iterator end() const { return values.end(); } - QPID_COMMON_EXTERN iterator begin() { return values.begin(); } - QPID_COMMON_EXTERN iterator end(){ return values.end(); } + QPID_COMMON_INLINE_EXTERN const_iterator begin() const { return values.begin(); } + QPID_COMMON_INLINE_EXTERN const_iterator end() const { return values.end(); } + QPID_COMMON_INLINE_EXTERN iterator begin() { return values.begin(); } + QPID_COMMON_INLINE_EXTERN iterator end(){ return values.end(); } - QPID_COMMON_EXTERN ValuePtr front() const { return values.front(); } - QPID_COMMON_EXTERN ValuePtr back() const { return values.back(); } - QPID_COMMON_EXTERN size_t size() const { return values.size(); } + QPID_COMMON_INLINE_EXTERN ValuePtr front() const { return values.front(); } + QPID_COMMON_INLINE_EXTERN ValuePtr back() const { return values.back(); } + QPID_COMMON_INLINE_EXTERN size_t size() const { return values.size(); } QPID_COMMON_EXTERN void insert(iterator i, ValuePtr value); - QPID_COMMON_EXTERN void erase(iterator i) { values.erase(i); } - QPID_COMMON_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); } - QPID_COMMON_EXTERN void pop_back() { values.pop_back(); } + QPID_COMMON_INLINE_EXTERN void erase(iterator i) { values.erase(i); } + QPID_COMMON_INLINE_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); } + QPID_COMMON_INLINE_EXTERN void pop_back() { values.pop_back(); } // Non-std interface - QPID_COMMON_EXTERN void add(ValuePtr value) { push_back(value); } + QPID_COMMON_INLINE_EXTERN void add(ValuePtr value) { push_back(value); } template <class T> void collect(std::vector<T>& out) const diff --git a/cpp/include/qpid/framing/Buffer.h b/cpp/include/qpid/framing/Buffer.h index 04583433c5..8b08e60762 100644 --- a/cpp/include/qpid/framing/Buffer.h +++ b/cpp/include/qpid/framing/Buffer.h @@ -29,14 +29,14 @@ namespace qpid { namespace framing { -struct OutOfBounds : qpid::Exception { +struct QPID_COMMON_CLASS_EXTERN OutOfBounds : qpid::Exception { OutOfBounds() : qpid::Exception(std::string("Out of Bounds")) {} }; class Content; class FieldTable; -class Buffer +class QPID_COMMON_CLASS_EXTERN Buffer { uint32_t size; char* data; @@ -72,12 +72,12 @@ class Buffer QPID_COMMON_EXTERN void restore(bool reRecord = false); QPID_COMMON_EXTERN void reset(); - QPID_COMMON_EXTERN uint32_t available() { return size - position; } - QPID_COMMON_EXTERN uint32_t getSize() { return size; } - QPID_COMMON_EXTERN uint32_t getPosition() { return position; } - QPID_COMMON_EXTERN void setPosition(uint32_t p) { position = p; } - QPID_COMMON_EXTERN Iterator getIterator() { return Iterator(*this); } - QPID_COMMON_EXTERN char* getPointer() { return data; } + QPID_COMMON_INLINE_EXTERN uint32_t available() { return size - position; } + QPID_COMMON_INLINE_EXTERN uint32_t getSize() { return size; } + QPID_COMMON_INLINE_EXTERN uint32_t getPosition() { return position; } + QPID_COMMON_INLINE_EXTERN void setPosition(uint32_t p) { position = p; } + QPID_COMMON_INLINE_EXTERN Iterator getIterator() { return Iterator(*this); } + QPID_COMMON_INLINE_EXTERN char* getPointer() { return data; } QPID_COMMON_EXTERN void putOctet(uint8_t i); QPID_COMMON_EXTERN void putShort(uint16_t i); diff --git a/cpp/include/qpid/framing/FieldTable.h b/cpp/include/qpid/framing/FieldTable.h index fdb1a28b9d..bdcef6d7fd 100644 --- a/cpp/include/qpid/framing/FieldTable.h +++ b/cpp/include/qpid/framing/FieldTable.h @@ -56,7 +56,7 @@ class FieldTable typedef ValueMap::reference reference; typedef ValueMap::value_type value_type; - QPID_COMMON_EXTERN FieldTable() {}; + QPID_COMMON_INLINE_EXTERN FieldTable() {}; QPID_COMMON_EXTERN FieldTable(const FieldTable& ft); QPID_COMMON_EXTERN ~FieldTable(); QPID_COMMON_EXTERN FieldTable& operator=(const FieldTable& ft); @@ -65,9 +65,11 @@ class FieldTable QPID_COMMON_EXTERN void decode(Buffer& buffer); QPID_COMMON_EXTERN int count() const; + QPID_COMMON_INLINE_EXTERN size_t size() const { return values.size(); } + QPID_COMMON_INLINE_EXTERN bool empty() { return size() == 0; } QPID_COMMON_EXTERN void set(const std::string& name, const ValuePtr& value); QPID_COMMON_EXTERN ValuePtr get(const std::string& name) const; - QPID_COMMON_EXTERN bool isSet(const std::string& name) const { return get(name).get() != 0; } + QPID_COMMON_INLINE_EXTERN bool isSet(const std::string& name) const { return get(name).get() != 0; } QPID_COMMON_EXTERN void setString(const std::string& name, const std::string& value); QPID_COMMON_EXTERN void setInt(const std::string& name, const int value); diff --git a/cpp/include/qpid/framing/FieldValue.h b/cpp/include/qpid/framing/FieldValue.h index 19220e74d5..458de62fdf 100644 --- a/cpp/include/qpid/framing/FieldValue.h +++ b/cpp/include/qpid/framing/FieldValue.h @@ -41,14 +41,14 @@ namespace framing { * * \ingroup clientapi */ -class FieldValueException : public qpid::Exception {}; +class QPID_COMMON_CLASS_EXTERN FieldValueException : public qpid::Exception {}; /** * Exception thrown when we can't perform requested conversion * * \ingroup clientapi */ -struct InvalidConversionException : public FieldValueException { +struct QPID_COMMON_CLASS_EXTERN InvalidConversionException : public FieldValueException { InvalidConversionException() {} }; @@ -59,7 +59,7 @@ class List; * * \ingroup clientapi */ -class FieldValue { +class QPID_COMMON_CLASS_EXTERN FieldValue { public: /* * Abstract type for content of different types @@ -90,7 +90,7 @@ class FieldValue { void encode(Buffer& buffer); void decode(Buffer& buffer); QPID_COMMON_EXTERN bool operator==(const FieldValue&) const; - QPID_COMMON_EXTERN bool operator!=(const FieldValue& v) const { return !(*this == v); } + QPID_COMMON_INLINE_EXTERN bool operator!=(const FieldValue& v) const { return !(*this == v); } QPID_COMMON_EXTERN void print(std::ostream& out) const; @@ -98,6 +98,7 @@ class FieldValue { template <typename T> T get() const { throw InvalidConversionException(); } template <class T, int W> T getIntegerValue() const; + template <class T> T getIntegerValue() const; template <class T, int W> T getFloatingPointValue() const; template <int W> void getFixedWidthValue(unsigned char*) const; template <class T> bool get(T&) const; @@ -196,6 +197,18 @@ inline T FieldValue::getIntegerValue() const } } +template <class T> +inline T FieldValue::getIntegerValue() const +{ + FixedWidthValue<1>* const fwv = dynamic_cast< FixedWidthValue<1>* const>(data.get()); + if (fwv) { + uint8_t* octets = fwv->rawOctets(); + return octets[0]; + } else { + throw InvalidConversionException(); + } +} + template <class T, int W> inline T FieldValue::getFloatingPointValue() const { FixedWidthValue<W>* const fwv = dynamic_cast< FixedWidthValue<W>* const>(data.get()); diff --git a/cpp/include/qpid/framing/List.h b/cpp/include/qpid/framing/List.h index 0f17c7884c..681445947c 100644 --- a/cpp/include/qpid/framing/List.h +++ b/cpp/include/qpid/framing/List.h @@ -36,10 +36,11 @@ class FieldValue; /** * Representation of an AMQP 0-10 list */ -class List +class QPID_COMMON_CLASS_EXTERN List { public: typedef boost::shared_ptr<FieldValue> ValuePtr; + typedef ValuePtr value_type; typedef std::list<ValuePtr> Values; typedef Values::const_iterator const_iterator; typedef Values::iterator iterator; @@ -53,19 +54,19 @@ class List QPID_COMMON_EXTERN bool operator==(const List& other) const; // std collection interface. - QPID_COMMON_EXTERN const_iterator begin() const { return values.begin(); } - QPID_COMMON_EXTERN const_iterator end() const { return values.end(); } - QPID_COMMON_EXTERN iterator begin() { return values.begin(); } - QPID_COMMON_EXTERN iterator end(){ return values.end(); } + QPID_COMMON_INLINE_EXTERN const_iterator begin() const { return values.begin(); } + QPID_COMMON_INLINE_EXTERN const_iterator end() const { return values.end(); } + QPID_COMMON_INLINE_EXTERN iterator begin() { return values.begin(); } + QPID_COMMON_INLINE_EXTERN iterator end(){ return values.end(); } - QPID_COMMON_EXTERN ValuePtr front() const { return values.front(); } - QPID_COMMON_EXTERN ValuePtr back() const { return values.back(); } - QPID_COMMON_EXTERN size_t size() const { return values.size(); } + QPID_COMMON_INLINE_EXTERN ValuePtr front() const { return values.front(); } + QPID_COMMON_INLINE_EXTERN ValuePtr back() const { return values.back(); } + QPID_COMMON_INLINE_EXTERN size_t size() const { return values.size(); } - QPID_COMMON_EXTERN iterator insert(iterator i, ValuePtr value) { return values.insert(i, value); } - QPID_COMMON_EXTERN void erase(iterator i) { values.erase(i); } - QPID_COMMON_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); } - QPID_COMMON_EXTERN void pop_back() { values.pop_back(); } + QPID_COMMON_INLINE_EXTERN iterator insert(iterator i, ValuePtr value) { return values.insert(i, value); } + QPID_COMMON_INLINE_EXTERN void erase(iterator i) { values.erase(i); } + QPID_COMMON_INLINE_EXTERN void push_back(ValuePtr value) { values.insert(end(), value); } + QPID_COMMON_INLINE_EXTERN void pop_back() { values.pop_back(); } private: Values values; diff --git a/cpp/include/qpid/framing/ProtocolVersion.h b/cpp/include/qpid/framing/ProtocolVersion.h index e7e75d75f6..30094c165d 100644 --- a/cpp/include/qpid/framing/ProtocolVersion.h +++ b/cpp/include/qpid/framing/ProtocolVersion.h @@ -29,7 +29,7 @@ namespace qpid namespace framing { -class ProtocolVersion +class QPID_COMMON_CLASS_EXTERN ProtocolVersion { private: uint8_t major_; @@ -39,16 +39,16 @@ public: explicit ProtocolVersion(uint8_t _major=0, uint8_t _minor=0) : major_(_major), minor_(_minor) {} - QPID_COMMON_EXTERN uint8_t getMajor() const { return major_; } - QPID_COMMON_EXTERN void setMajor(uint8_t major) { major_ = major; } - QPID_COMMON_EXTERN uint8_t getMinor() const { return minor_; } - QPID_COMMON_EXTERN void setMinor(uint8_t minor) { minor_ = minor; } + QPID_COMMON_INLINE_EXTERN uint8_t getMajor() const { return major_; } + QPID_COMMON_INLINE_EXTERN void setMajor(uint8_t major) { major_ = major; } + QPID_COMMON_INLINE_EXTERN uint8_t getMinor() const { return minor_; } + QPID_COMMON_INLINE_EXTERN void setMinor(uint8_t minor) { minor_ = minor; } QPID_COMMON_EXTERN const std::string toString() const; QPID_COMMON_EXTERN ProtocolVersion& operator=(ProtocolVersion p); QPID_COMMON_EXTERN bool operator==(ProtocolVersion p) const; - QPID_COMMON_EXTERN bool operator!=(ProtocolVersion p) const { return ! (*this == p); } + QPID_COMMON_INLINE_EXTERN bool operator!=(ProtocolVersion p) const { return ! (*this == p); } }; } // namespace framing diff --git a/cpp/include/qpid/framing/SequenceNumber.h b/cpp/include/qpid/framing/SequenceNumber.h index 1e53058df8..eed15a4b75 100644 --- a/cpp/include/qpid/framing/SequenceNumber.h +++ b/cpp/include/qpid/framing/SequenceNumber.h @@ -34,7 +34,7 @@ class Buffer; /** * 4-byte sequence number that 'wraps around'. */ -class SequenceNumber : public +class QPID_COMMON_CLASS_EXTERN SequenceNumber : public boost::equality_comparable< SequenceNumber, boost::less_than_comparable< SequenceNumber, boost::incrementable< diff --git a/cpp/include/qpid/framing/SequenceSet.h b/cpp/include/qpid/framing/SequenceSet.h index 39395e9ad7..0a78e418ba 100644 --- a/cpp/include/qpid/framing/SequenceSet.h +++ b/cpp/include/qpid/framing/SequenceSet.h @@ -29,7 +29,7 @@ namespace qpid { namespace framing { class Buffer; -class SequenceSet : public RangeSet<SequenceNumber> { +class QPID_COMMON_CLASS_EXTERN SequenceSet : public RangeSet<SequenceNumber> { public: SequenceSet() {} SequenceSet(const RangeSet<SequenceNumber>& r) diff --git a/cpp/include/qpid/framing/StructHelper.h b/cpp/include/qpid/framing/StructHelper.h index fc9a7909cc..21f9b91fa9 100644 --- a/cpp/include/qpid/framing/StructHelper.h +++ b/cpp/include/qpid/framing/StructHelper.h @@ -30,7 +30,7 @@ namespace qpid { namespace framing { -class StructHelper +class QPID_COMMON_CLASS_EXTERN StructHelper { public: diff --git a/cpp/include/qpid/framing/Uuid.h b/cpp/include/qpid/framing/Uuid.h index d0a8d02411..ccfd7e9534 100644 --- a/cpp/include/qpid/framing/Uuid.h +++ b/cpp/include/qpid/framing/Uuid.h @@ -52,22 +52,22 @@ struct Uuid : public boost::array<uint8_t, 16> { // boost::array gives us ==, < etc. /** Copy from 16 bytes of data. */ - void assign(const uint8_t* data); + QPID_COMMON_EXTERN void assign(const uint8_t* data); /** Set to a new unique identifier. */ QPID_COMMON_EXTERN void generate(); /** Set to all zeros. */ - void clear(); + QPID_COMMON_EXTERN void clear(); /** Test for null (all zeros). */ QPID_COMMON_EXTERN bool isNull() const; - operator bool() const { return !isNull(); } - bool operator!() const { return isNull(); } + QPID_COMMON_INLINE_EXTERN operator bool() const { return !isNull(); } + QPID_COMMON_INLINE_EXTERN bool operator!() const { return isNull(); } QPID_COMMON_EXTERN void encode(framing::Buffer& buf) const; QPID_COMMON_EXTERN void decode(framing::Buffer& buf); - QPID_COMMON_EXTERN uint32_t encodedSize() const + QPID_COMMON_INLINE_EXTERN uint32_t encodedSize() const { return static_cast<uint32_t>(size()); } /** String value in format 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb. */ diff --git a/cpp/include/qpid/log/Logger.h b/cpp/include/qpid/log/Logger.h index 783ab7bdb9..d255b7e150 100644 --- a/cpp/include/qpid/log/Logger.h +++ b/cpp/include/qpid/log/Logger.h @@ -33,10 +33,10 @@ namespace log { * is handled by Logger::Output-derived classes instantiated by the * platform's sink-related options. */ -class Logger : private boost::noncopyable { +class QPID_COMMON_CLASS_EXTERN Logger : private boost::noncopyable { public: /** Flags indicating what to include in the log output */ - enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32}; + enum FormatFlag { FILE=1, LINE=2, FUNCTION=4, LEVEL=8, TIME=16, THREAD=32, HIRES=64}; /** * Logging output sink. @@ -93,7 +93,7 @@ class Logger : private boost::noncopyable { QPID_COMMON_EXTERN void clear(); /** Get the options used to configure the logger. */ - QPID_COMMON_EXTERN const Options& getOptions() const { return options; } + QPID_COMMON_INLINE_EXTERN const Options& getOptions() const { return options; } private: diff --git a/cpp/include/qpid/log/Options.h b/cpp/include/qpid/log/Options.h index bbc47b47d3..17cbfde9bc 100644 --- a/cpp/include/qpid/log/Options.h +++ b/cpp/include/qpid/log/Options.h @@ -39,7 +39,7 @@ struct Options : public qpid::Options { std::string argv0; std::string name; std::vector<std::string> selectors; - bool time, level, thread, source, function; + bool time, level, thread, source, function, hiresTs; bool trace; std::string prefix; std::auto_ptr<SinkOptions> sinkOptions; diff --git a/cpp/include/qpid/management/ManagementObject.h b/cpp/include/qpid/management/ManagementObject.h index 747edda150..16bf21038c 100644 --- a/cpp/include/qpid/management/ManagementObject.h +++ b/cpp/include/qpid/management/ManagementObject.h @@ -58,14 +58,14 @@ protected: std::string agentName; void fromString(const std::string&); public: - QPID_COMMON_EXTERN ObjectId() : agent(0), first(0), second(0), agentEpoch(0) {} - QPID_COMMON_EXTERN ObjectId(const types::Variant& map) : + QPID_COMMON_INLINE_EXTERN ObjectId() : agent(0), first(0), second(0), agentEpoch(0) {} + QPID_COMMON_INLINE_EXTERN ObjectId(const types::Variant& map) : agent(0), first(0), second(0), agentEpoch(0) { mapDecode(map.asMap()); } QPID_COMMON_EXTERN ObjectId(uint8_t flags, uint16_t seq, uint32_t broker); QPID_COMMON_EXTERN ObjectId(AgentAttachment* _agent, uint8_t flags, uint16_t seq); QPID_COMMON_EXTERN ObjectId(std::istream&); QPID_COMMON_EXTERN ObjectId(const std::string&); - QPID_COMMON_EXTERN ObjectId(const std::string& agentAddress, const std::string& key, + QPID_COMMON_INLINE_EXTERN ObjectId(const std::string& agentAddress, const std::string& key, uint64_t epoch=0) : agent(0), first(0), second(0), agentEpoch(epoch), v2Key(key), agentName(agentAddress) {} @@ -76,15 +76,15 @@ public: QPID_COMMON_EXTERN void mapEncode(types::Variant::Map& map) const; QPID_COMMON_EXTERN void mapDecode(const types::Variant::Map& map); QPID_COMMON_EXTERN operator types::Variant::Map() const; - QPID_COMMON_EXTERN uint32_t encodedSize() const { return 16; }; + QPID_COMMON_INLINE_EXTERN uint32_t encodedSize() const { return 16; }; QPID_COMMON_EXTERN void encode(std::string& buffer) const; QPID_COMMON_EXTERN void decode(const std::string& buffer); QPID_COMMON_EXTERN bool equalV1(const ObjectId &other) const; - QPID_COMMON_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; } + QPID_COMMON_INLINE_EXTERN void setV2Key(const std::string& _key) { v2Key = _key; } QPID_COMMON_EXTERN void setV2Key(const ManagementObject& object); - QPID_COMMON_EXTERN void setAgentName(const std::string& _name) { agentName = _name; } - QPID_COMMON_EXTERN const std::string& getAgentName() const { return agentName; } - QPID_COMMON_EXTERN const std::string& getV2Key() const { return v2Key; } + QPID_COMMON_INLINE_EXTERN void setAgentName(const std::string& _name) { agentName = _name; } + QPID_COMMON_INLINE_EXTERN const std::string& getAgentName() const { return agentName; } + QPID_COMMON_INLINE_EXTERN const std::string& getV2Key() const { return v2Key; } friend QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const ObjectId&); }; @@ -131,7 +131,7 @@ public: virtual ~ManagementItem() {} }; -class ManagementObject : public ManagementItem +class QPID_COMMON_CLASS_EXTERN ManagementObject : public ManagementItem { protected: diff --git a/cpp/include/qpid/messaging/Address.h b/cpp/include/qpid/messaging/Address.h index bebbfc72f6..63dce0c49d 100644 --- a/cpp/include/qpid/messaging/Address.h +++ b/cpp/include/qpid/messaging/Address.h @@ -119,7 +119,7 @@ class AddressImpl; * * An address has value semantics. */ -class Address +class QPID_MESSAGING_CLASS_EXTERN Address { public: QPID_MESSAGING_EXTERN Address(); diff --git a/cpp/include/qpid/messaging/Connection.h b/cpp/include/qpid/messaging/Connection.h index 1ad7a7242f..165573e2ef 100644 --- a/cpp/include/qpid/messaging/Connection.h +++ b/cpp/include/qpid/messaging/Connection.h @@ -42,7 +42,7 @@ class Session; * A connection represents a network connection to a remote endpoint. */ -class Connection : public qpid::messaging::Handle<ConnectionImpl> +class QPID_MESSAGING_CLASS_EXTERN Connection : public qpid::messaging::Handle<ConnectionImpl> { public: QPID_MESSAGING_EXTERN Connection(ConnectionImpl* impl); @@ -54,27 +54,27 @@ class Connection : public qpid::messaging::Handle<ConnectionImpl> * username * password * heartbeat - * tcp-nodelay - * sasl-mechanism - * sasl-service - * sasl-min-ssf - * sasl-max-ssf + * tcp_nodelay + * sasl_mechanisms + * sasl_service + * sasl_min_ssf + * sasl_max_ssf * transport * * Reconnect behaviour can be controlled through the following options: * * reconnect: true/false (enables/disables reconnect entirely) - * reconnect-timeout: number of seconds (give up and report failure after specified time) - * reconnect-limit: n (give up and report failure after specified number of attempts) - * reconnect-interval-min: number of seconds (initial delay between failed reconnection attempts) - * reconnect-interval-max: number of seconds (maximum delay between failed reconnection attempts) - * reconnect-interval: shorthand for setting the same reconnect_interval_min/max - * reconnect-urls: list of alternate urls to try when connecting + * reconnect_timeout: number of seconds (give up and report failure after specified time) + * reconnect_limit: n (give up and report failure after specified number of attempts) + * reconnect_interval_min: number of seconds (initial delay between failed reconnection attempts) + * reconnect_interval_max: number of seconds (maximum delay between failed reconnection attempts) + * reconnect_interval: shorthand for setting the same reconnect_interval_min/max + * reconnect_urls: list of alternate urls to try when connecting * - * The reconnect-interval is the time that the client waits + * The reconnect_interval is the time that the client waits * for after a failed attempt to reconnect before retrying. It - * starts at the value of the min-retry-interval and is - * doubled every failure until the value of max-retry-interval + * starts at the value of the min_retry_interval and is + * doubled every failure until the value of max_retry_interval * is reached. */ QPID_MESSAGING_EXTERN Connection(const std::string& url, const qpid::types::Variant::Map& options = qpid::types::Variant::Map()); diff --git a/cpp/include/qpid/messaging/Duration.h b/cpp/include/qpid/messaging/Duration.h index abcf169090..6b8f05c7c6 100644 --- a/cpp/include/qpid/messaging/Duration.h +++ b/cpp/include/qpid/messaging/Duration.h @@ -32,7 +32,7 @@ namespace messaging { /** \ingroup messaging * A duration is a time in milliseconds. */ -class Duration +class QPID_MESSAGING_CLASS_EXTERN Duration { public: QPID_MESSAGING_EXTERN explicit Duration(uint64_t milliseconds); @@ -46,9 +46,11 @@ class Duration }; QPID_MESSAGING_EXTERN Duration operator*(const Duration& duration, - uint64_t multiplier); + uint64_t multiplier); QPID_MESSAGING_EXTERN Duration operator*(uint64_t multiplier, - const Duration& duration); + const Duration& duration); +QPID_MESSAGING_EXTERN bool operator==(const Duration& a, const Duration& b); +QPID_MESSAGING_EXTERN bool operator!=(const Duration& a, const Duration& b); }} // namespace qpid::messaging diff --git a/cpp/include/qpid/messaging/FailoverUpdates.h b/cpp/include/qpid/messaging/FailoverUpdates.h index 14a1a31b63..6d7314620a 100644 --- a/cpp/include/qpid/messaging/FailoverUpdates.h +++ b/cpp/include/qpid/messaging/FailoverUpdates.h @@ -32,7 +32,7 @@ struct FailoverUpdatesImpl; * A utility to listen for updates on cluster membership and update * the list of known urls for a connection accordingly. */ -class FailoverUpdates +class QPID_MESSAGING_CLASS_EXTERN FailoverUpdates { public: QPID_MESSAGING_EXTERN FailoverUpdates(Connection& connection); diff --git a/cpp/include/qpid/messaging/Handle.h b/cpp/include/qpid/messaging/Handle.h index 1e634ef888..97a8f00b54 100644 --- a/cpp/include/qpid/messaging/Handle.h +++ b/cpp/include/qpid/messaging/Handle.h @@ -40,22 +40,22 @@ template <class T> class Handle { public: /**@return true if handle is valid, i.e. not null. */ - QPID_MESSAGING_EXTERN bool isValid() const { return impl; } + QPID_MESSAGING_INLINE_EXTERN bool isValid() const { return impl; } /**@return true if handle is null. It is an error to call any function on a null handle. */ - QPID_MESSAGING_EXTERN bool isNull() const { return !impl; } + QPID_MESSAGING_INLINE_EXTERN bool isNull() const { return !impl; } /** Conversion to bool supports idiom if (handle) { handle->... } */ - QPID_MESSAGING_EXTERN operator bool() const { return impl; } + QPID_MESSAGING_INLINE_EXTERN operator bool() const { return impl; } /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ - QPID_MESSAGING_EXTERN bool operator !() const { return !impl; } + QPID_MESSAGING_INLINE_EXTERN bool operator !() const { return !impl; } void swap(Handle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; } protected: typedef T Impl; - QPID_MESSAGING_EXTERN Handle() :impl() {} + QPID_MESSAGING_INLINE_EXTERN Handle() :impl() {} // Not implemented,subclasses must implement. QPID_MESSAGING_EXTERN Handle(const Handle&); diff --git a/cpp/include/qpid/messaging/ImportExport.h b/cpp/include/qpid/messaging/ImportExport.h index 52f3eb8568..ab5f21f618 100644 --- a/cpp/include/qpid/messaging/ImportExport.h +++ b/cpp/include/qpid/messaging/ImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#include "qpid/ImportExport.h" + #if defined(CLIENT_EXPORT) || defined (qpidmessaging_EXPORTS) -#define QPID_MESSAGING_EXTERN __declspec(dllexport) -#else -#define QPID_MESSAGING_EXTERN __declspec(dllimport) -#endif +# define QPID_MESSAGING_EXTERN QPID_EXPORT +# define QPID_MESSAGING_CLASS_EXTERN QPID_CLASS_EXPORT +# define QPID_MESSAGING_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QPID_MESSAGING_EXTERN +# define QPID_MESSAGING_EXTERN QPID_IMPORT +# define QPID_MESSAGING_CLASS_EXTERN QPID_CLASS_IMPORT +# define QPID_MESSAGING_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif /*!QPID_MESSAGING_IMPORTEXPORT_H*/ diff --git a/cpp/include/qpid/messaging/Message.h b/cpp/include/qpid/messaging/Message.h index d48af35cc0..e89a6ce02f 100644 --- a/cpp/include/qpid/messaging/Message.h +++ b/cpp/include/qpid/messaging/Message.h @@ -39,7 +39,7 @@ struct MessageImpl; /** \ingroup messaging * Representation of a message. */ -class Message +class QPID_MESSAGING_CLASS_EXTERN Message { public: QPID_MESSAGING_EXTERN Message(const std::string& bytes = std::string()); @@ -55,23 +55,58 @@ class Message QPID_MESSAGING_EXTERN void setSubject(const std::string&); QPID_MESSAGING_EXTERN const std::string& getSubject() const; + /** + * Set the content type (i.e. the MIME type) for the message. This + * should be set by the sending application and indicates to + * recipients of message how to interpret or decode the content. + */ QPID_MESSAGING_EXTERN void setContentType(const std::string&); + /** + * Returns the content type (i.e. the MIME type) for the + * message. This can be used to determine how to decode the + * message content. + */ QPID_MESSAGING_EXTERN const std::string& getContentType() const; + /** + * Set an application defined identifier for the message. At + * present this must be a stringfied UUID (support for less + * restrictive IDs is anticipated however). + */ QPID_MESSAGING_EXTERN void setMessageId(const std::string&); QPID_MESSAGING_EXTERN const std::string& getMessageId() const; + /** + * Sets the user id of the message. This should in general be the + * user-id as which the sending connection authenticated itself as + * the messaging infrastructure will verify this. See + * Connection::getAuthenticatedUsername() + */ QPID_MESSAGING_EXTERN void setUserId(const std::string&); QPID_MESSAGING_EXTERN const std::string& getUserId() const; + /** + * Can be used to set application specific correlation identifiers + * as part of a protocol for message exchange patterns. E.g. a + * request-reponse pattern might require the correlation-id of the + * request and response to match, or might use the message-id of + * the request as the correlation-id on the response etc. + */ QPID_MESSAGING_EXTERN void setCorrelationId(const std::string&); QPID_MESSAGING_EXTERN const std::string& getCorrelationId() const; + /** + * Sets a priority level on the message. This may be used by the + * messaging infrastructure to prioritise delivery of higher + * priority messages. + */ QPID_MESSAGING_EXTERN void setPriority(uint8_t); QPID_MESSAGING_EXTERN uint8_t getPriority() const; /** - * Set the time to live for this message in milliseconds. + * Set the time to live for this message in milliseconds. This can + * be used by the messaging infrastructure to discard messages + * that are no longer of relevance. */ QPID_MESSAGING_EXTERN void setTtl(Duration ttl); /** @@ -79,24 +114,62 @@ class Message */ QPID_MESSAGING_EXTERN Duration getTtl() const; + /** + * Mark the message as durable. This is a hint to the messaging + * infrastructure that the message should be persisted or + * otherwise stored such that failoures or shutdown do not cause + * it to be lost. + */ QPID_MESSAGING_EXTERN void setDurable(bool durable); QPID_MESSAGING_EXTERN bool getDurable() const; + /** + * The redelivered flag if set implies that the message *may* have + * been previously delivered and thus is a hint to the application + * or messaging infrastructure that if de-duplication is required + * this message should be examined to determine if it is a + * duplicate. + */ QPID_MESSAGING_EXTERN bool getRedelivered() const; + /** + * Can be used to provide a hint to the application or messaging + * infrastructure that if de-duplication is required this message + * should be examined to determine if it is a duplicate. + */ QPID_MESSAGING_EXTERN void setRedelivered(bool); + /** + * In addition to a payload (i.e. the content), messages can + * include annotations describing aspectf of the message. In + * addition to the standard annotations such as TTL and content + * type, application- or context- specific properties can also be + * defined. Each message has a map of name values for such custom + * properties. The value is specified as a Variant. + */ QPID_MESSAGING_EXTERN const qpid::types::Variant::Map& getProperties() const; QPID_MESSAGING_EXTERN qpid::types::Variant::Map& getProperties(); + /** + * Set the content to the data held in the string parameter. Note: + * this is treated as raw bytes and need not be text. Consider + * setting the content-type to indicate how the data should be + * interpreted by recipients. + */ QPID_MESSAGING_EXTERN void setContent(const std::string&); /** - * Note that chars are copied. + * Copy count bytes from the region pointed to by chars as the + * message content. */ QPID_MESSAGING_EXTERN void setContent(const char* chars, size_t count); /** Get the content as a std::string */ QPID_MESSAGING_EXTERN std::string getContent() const; - /** Get a const pointer to the start of the content data. */ + /** + * Get a const pointer to the start of the content data. The + * memory pointed to is owned by the message. The getContentSize() + * method indicates how much data there is (i.e. the extent of the + * memory region pointed to by the return value of this method). + */ QPID_MESSAGING_EXTERN const char* getContentPtr() const; /** Get the size of content in bytes. */ QPID_MESSAGING_EXTERN size_t getContentSize() const; @@ -107,9 +180,9 @@ class Message friend struct MessageImplAccess; }; -struct EncodingException : qpid::types::Exception +struct QPID_MESSAGING_CLASS_EXTERN EncodingException : qpid::types::Exception { - EncodingException(const std::string& msg); + QPID_MESSAGING_EXTERN EncodingException(const std::string& msg); }; /** @@ -122,8 +195,8 @@ struct EncodingException : qpid::types::Exception * @exception EncodingException */ QPID_MESSAGING_EXTERN void decode(const Message& message, - qpid::types::Variant::Map& map, - const std::string& encoding = std::string()); + qpid::types::Variant::Map& map, + const std::string& encoding = std::string()); /** * Decodes message content into a Variant::List. * @@ -134,8 +207,8 @@ QPID_MESSAGING_EXTERN void decode(const Message& message, * @exception EncodingException */ QPID_MESSAGING_EXTERN void decode(const Message& message, - qpid::types::Variant::List& list, - const std::string& encoding = std::string()); + qpid::types::Variant::List& list, + const std::string& encoding = std::string()); /** * Encodes a Variant::Map into a message. * @@ -146,8 +219,8 @@ QPID_MESSAGING_EXTERN void decode(const Message& message, * @exception EncodingException */ QPID_MESSAGING_EXTERN void encode(const qpid::types::Variant::Map& map, - Message& message, - const std::string& encoding = std::string()); + Message& message, + const std::string& encoding = std::string()); /** * Encodes a Variant::List into a message. * @@ -158,8 +231,8 @@ QPID_MESSAGING_EXTERN void encode(const qpid::types::Variant::Map& map, * @exception EncodingException */ QPID_MESSAGING_EXTERN void encode(const qpid::types::Variant::List& list, - Message& message, - const std::string& encoding = std::string()); + Message& message, + const std::string& encoding = std::string()); }} // namespace qpid::messaging diff --git a/cpp/include/qpid/messaging/Receiver.h b/cpp/include/qpid/messaging/Receiver.h index 6f3ae961db..13317dfcbd 100644 --- a/cpp/include/qpid/messaging/Receiver.h +++ b/cpp/include/qpid/messaging/Receiver.h @@ -41,7 +41,7 @@ class Session; /** \ingroup messaging * Interface through which messages are received. */ -class Receiver : public qpid::messaging::Handle<ReceiverImpl> +class QPID_MESSAGING_CLASS_EXTERN Receiver : public qpid::messaging::Handle<ReceiverImpl> { public: QPID_MESSAGING_EXTERN Receiver(ReceiverImpl* impl = 0); diff --git a/cpp/include/qpid/messaging/Sender.h b/cpp/include/qpid/messaging/Sender.h index 85658f37cc..8e1c5846e9 100644 --- a/cpp/include/qpid/messaging/Sender.h +++ b/cpp/include/qpid/messaging/Sender.h @@ -40,7 +40,7 @@ class Session; /** \ingroup messaging * Interface through which messages are sent. */ -class Sender : public qpid::messaging::Handle<SenderImpl> +class QPID_MESSAGING_CLASS_EXTERN Sender : public qpid::messaging::Handle<SenderImpl> { public: QPID_MESSAGING_EXTERN Sender(SenderImpl* impl = 0); diff --git a/cpp/include/qpid/messaging/Session.h b/cpp/include/qpid/messaging/Session.h index 6c023629e0..e8d6efb35d 100644 --- a/cpp/include/qpid/messaging/Session.h +++ b/cpp/include/qpid/messaging/Session.h @@ -46,7 +46,7 @@ class SessionImpl; * A session represents a distinct 'conversation' which can involve * sending and receiving messages to and from different addresses. */ -class Session : public qpid::messaging::Handle<SessionImpl> +class QPID_MESSAGING_CLASS_EXTERN Session : public qpid::messaging::Handle<SessionImpl> { public: QPID_MESSAGING_EXTERN Session(SessionImpl* impl = 0); @@ -62,6 +62,12 @@ class Session : public qpid::messaging::Handle<SessionImpl> */ QPID_MESSAGING_EXTERN void close(); + /** + * Commits the sessions transaction. + * + * @exception TransactionAborted if the original session is lost + * forcing an automatic rollback. + */ QPID_MESSAGING_EXTERN void commit(); QPID_MESSAGING_EXTERN void rollback(); @@ -78,6 +84,10 @@ class Session : public qpid::messaging::Handle<SessionImpl> */ QPID_MESSAGING_EXTERN void acknowledge(Message&, bool sync=false); /** + * Acknowledges all message up to the specified message. + */ + QPID_MESSAGING_EXTERN void acknowledgeUpTo(Message&, bool sync=false); + /** * Rejects the specified message. The broker does not redeliver a * message that has been rejected. Once a message has been * acknowledged, it can no longer be rejected. @@ -135,25 +145,51 @@ class Session : public qpid::messaging::Handle<SessionImpl> /** * Create a new sender through which messages can be sent to the * specified address. + * + * @exception ResolutionError if there is an error in resolving + * the address */ QPID_MESSAGING_EXTERN Sender createSender(const Address& address); + /** + * Create a new sender through which messages can be sent to the + * specified address. + * + * @exception ResolutionError if there is an error in resolving + * the address + * + * @exception MalformedAddress if the syntax of address is not + * valid + */ QPID_MESSAGING_EXTERN Sender createSender(const std::string& address); /** * Create a new receiver through which messages can be received * from the specified address. + * + * @exception ResolutionError if there is an error in resolving + * the address */ QPID_MESSAGING_EXTERN Receiver createReceiver(const Address& address); + /** + * Create a new receiver through which messages can be received + * from the specified address. + * + * @exception ResolutionError if there is an error in resolving + * the address + * + * @exception MalformedAddress if the syntax of address is not + * valid + */ QPID_MESSAGING_EXTERN Receiver createReceiver(const std::string& address); /** * Returns the sender with the specified name. - *@exception KeyError if there is none for that name. + * @exception KeyError if there is none for that name. */ QPID_MESSAGING_EXTERN Sender getSender(const std::string& name) const; /** * Returns the receiver with the specified name. - *@exception KeyError if there is none for that name. + * @exception KeyError if there is none for that name. */ QPID_MESSAGING_EXTERN Receiver getReceiver(const std::string& name) const; /** @@ -162,7 +198,16 @@ class Session : public qpid::messaging::Handle<SessionImpl> */ QPID_MESSAGING_EXTERN Connection getConnection() const; + /** + * @returns true if the session has been rendered invalid by some + * exception, false if it is valid for use. + */ QPID_MESSAGING_EXTERN bool hasError(); + /** + * If the session has been rendered invalid by some exception, + * this method will result in that exception being thrown on + * calling this method. + */ QPID_MESSAGING_EXTERN void checkError(); #ifndef SWIG diff --git a/cpp/include/qpid/messaging/exceptions.h b/cpp/include/qpid/messaging/exceptions.h index 0ff608b343..31e2488d91 100644 --- a/cpp/include/qpid/messaging/exceptions.h +++ b/cpp/include/qpid/messaging/exceptions.h @@ -10,9 +10,9 @@ * 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 @@ -29,34 +29,47 @@ namespace qpid { namespace messaging { -/** \ingroup messaging +/** \ingroup messaging */ -struct MessagingException : public qpid::types::Exception +/** + * This is the base class for all messaging related exceptions thrown + * by this API. + */ +struct QPID_MESSAGING_CLASS_EXTERN MessagingException : public qpid::types::Exception { QPID_MESSAGING_EXTERN MessagingException(const std::string& msg); QPID_MESSAGING_EXTERN virtual ~MessagingException() throw(); - + qpid::types::Variant::Map detail; //TODO: override what() to include detail if present }; -struct InvalidOptionString : public MessagingException +/** + * Thrown when the syntax of the option string used to configure a + * connection in not valid + */ +struct QPID_MESSAGING_CLASS_EXTERN InvalidOptionString : public MessagingException { QPID_MESSAGING_EXTERN InvalidOptionString(const std::string& msg); }; -struct KeyError : public MessagingException +/** + * Thrown to indicate a failed lookup of some local object. For + * example when attempting to retrieve a session, sender or receiver + * by name. + */ +struct QPID_MESSAGING_CLASS_EXTERN KeyError : public MessagingException { QPID_MESSAGING_EXTERN KeyError(const std::string&); }; -struct LinkError : public MessagingException +struct QPID_MESSAGING_CLASS_EXTERN LinkError : public MessagingException { QPID_MESSAGING_EXTERN LinkError(const std::string&); }; -struct AddressError : public LinkError +struct QPID_MESSAGING_CLASS_EXTERN AddressError : public LinkError { QPID_MESSAGING_EXTERN AddressError(const std::string&); }; @@ -65,85 +78,118 @@ struct AddressError : public LinkError * Thrown when a syntactically correct address cannot be resolved or * used. */ -struct ResolutionError : public AddressError +struct QPID_MESSAGING_CLASS_EXTERN ResolutionError : public AddressError { QPID_MESSAGING_EXTERN ResolutionError(const std::string& msg); }; -struct AssertionFailed : public ResolutionError +/** + * Thrown when creating a sender or receiver for an address for which + * some asserted property of the node is not matched. + */ +struct QPID_MESSAGING_CLASS_EXTERN AssertionFailed : public ResolutionError { QPID_MESSAGING_EXTERN AssertionFailed(const std::string& msg); }; -struct NotFound : public ResolutionError +/** + * Thrown on attempts to create a sender or receiver to a non-existent + * node. + */ +struct QPID_MESSAGING_CLASS_EXTERN NotFound : public ResolutionError { QPID_MESSAGING_EXTERN NotFound(const std::string& msg); }; /** - * Thrown when an address string with inalid sytanx is used. + * Thrown when an address string with invalid syntax is used. */ -struct MalformedAddress : public AddressError +struct QPID_MESSAGING_CLASS_EXTERN MalformedAddress : public AddressError { QPID_MESSAGING_EXTERN MalformedAddress(const std::string& msg); }; -struct ReceiverError : public LinkError +struct QPID_MESSAGING_CLASS_EXTERN ReceiverError : public LinkError { QPID_MESSAGING_EXTERN ReceiverError(const std::string&); }; -struct FetchError : public ReceiverError +struct QPID_MESSAGING_CLASS_EXTERN FetchError : public ReceiverError { QPID_MESSAGING_EXTERN FetchError(const std::string&); }; -struct NoMessageAvailable : public FetchError +/** + * Thrown by Receiver::fetch(), Receiver::get() and + * Session::nextReceiver() to indicate that there no message was + * available before the timeout specified. + */ +struct QPID_MESSAGING_CLASS_EXTERN NoMessageAvailable : public FetchError { QPID_MESSAGING_EXTERN NoMessageAvailable(); }; -struct SenderError : public LinkError +struct QPID_MESSAGING_CLASS_EXTERN SenderError : public LinkError { QPID_MESSAGING_EXTERN SenderError(const std::string&); }; -struct SendError : public SenderError +struct QPID_MESSAGING_CLASS_EXTERN SendError : public SenderError { QPID_MESSAGING_EXTERN SendError(const std::string&); }; -struct TargetCapacityExceeded : public SendError +/** + * Thrown to indicate that the sender attempted to send a message that + * would result in the target node on the peer exceeding a + * preconfigured capacity. + */ +struct QPID_MESSAGING_CLASS_EXTERN TargetCapacityExceeded : public SendError { QPID_MESSAGING_EXTERN TargetCapacityExceeded(const std::string&); }; -struct SessionError : public MessagingException +struct QPID_MESSAGING_CLASS_EXTERN SessionError : public MessagingException { QPID_MESSAGING_EXTERN SessionError(const std::string&); }; -struct TransactionError : public SessionError +struct QPID_MESSAGING_CLASS_EXTERN TransactionError : public SessionError { QPID_MESSAGING_EXTERN TransactionError(const std::string&); }; -struct TransactionAborted : public TransactionError +/** + * Thrown on Session::commit() if reconnection results in the + * transaction being automatically aborted. + */ +struct QPID_MESSAGING_CLASS_EXTERN TransactionAborted : public TransactionError { QPID_MESSAGING_EXTERN TransactionAborted(const std::string&); }; -struct UnauthorizedAccess : public SessionError +/** + * Thrown to indicate that the application attempted to do something + * for which it was not authorised by its peer. + */ +struct QPID_MESSAGING_CLASS_EXTERN UnauthorizedAccess : public SessionError { QPID_MESSAGING_EXTERN UnauthorizedAccess(const std::string&); }; -struct ConnectionError : public MessagingException +struct QPID_MESSAGING_CLASS_EXTERN ConnectionError : public MessagingException { QPID_MESSAGING_EXTERN ConnectionError(const std::string&); }; -struct TransportFailure : public MessagingException +/** + * Thrown to indicate loss of underlying connection. When + * auto-reconnect is used this will be caught by the library and used + * to trigger reconnection attempts. If reconnection fails (according + * to whatever settings have been configured), then an instnace of + * this class will be thrown to signal that. + */ +struct QPID_MESSAGING_CLASS_EXTERN TransportFailure : public MessagingException { QPID_MESSAGING_EXTERN TransportFailure(const std::string&); }; diff --git a/cpp/include/qpid/sys/ExceptionHolder.h b/cpp/include/qpid/sys/ExceptionHolder.h index 9eff1d64c7..4bc934cf75 100644 --- a/cpp/include/qpid/sys/ExceptionHolder.h +++ b/cpp/include/qpid/sys/ExceptionHolder.h @@ -10,9 +10,9 @@ * 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 @@ -42,14 +42,11 @@ class ExceptionHolder : public Raisable { public: ExceptionHolder() {} // Use default copy & assign. - + /** Take ownership of ex */ template <class Ex> ExceptionHolder(Ex* ex) { wrap(ex); } - template <class Ex> ExceptionHolder(const boost::shared_ptr<Ex>& ex) { wrap(ex.release()); } - template <class Ex> ExceptionHolder& operator=(Ex* ex) { wrap(ex); return *this; } - template <class Ex> ExceptionHolder& operator=(boost::shared_ptr<Ex> ex) { wrap(ex.release()); return *this; } - + void raise() const { if (wrapper.get()) wrapper->raise() ; } std::string what() const { return wrapper.get() ? wrapper->what() : std::string(); } bool empty() const { return !wrapper.get(); } @@ -66,7 +63,7 @@ class ExceptionHolder : public Raisable { template <class Ex> void wrap(Ex* ex) { wrapper.reset(new Wrapper<Ex>(ex)); } boost::shared_ptr<Raisable> wrapper; }; - + }} // namespace qpid::sys diff --git a/cpp/include/qpid/sys/IntegerTypes.h b/cpp/include/qpid/sys/IntegerTypes.h index 89635f033e..75fa921de0 100755 --- a/cpp/include/qpid/sys/IntegerTypes.h +++ b/cpp/include/qpid/sys/IntegerTypes.h @@ -21,7 +21,7 @@ * */ -#if (defined(_WINDOWS) || defined (WIN32)) && defined(_MSC_VER) +#if (defined(_WINDOWS) || defined (WIN32)) #include "qpid/sys/windows/IntegerTypes.h" #endif #if !defined _WINDOWS && !defined WIN32 diff --git a/cpp/include/qpid/sys/Runnable.h b/cpp/include/qpid/sys/Runnable.h index 0f1243a277..fed7663cb6 100644 --- a/cpp/include/qpid/sys/Runnable.h +++ b/cpp/include/qpid/sys/Runnable.h @@ -30,7 +30,7 @@ namespace sys { /** * Interface for objects that can be run, e.g. in a thread. */ -class Runnable +class QPID_COMMON_CLASS_EXTERN Runnable { public: /** Type to represent a runnable as a Functor */ diff --git a/cpp/include/qpid/sys/Thread.h b/cpp/include/qpid/sys/Thread.h index 45a39e796f..f556612908 100644 --- a/cpp/include/qpid/sys/Thread.h +++ b/cpp/include/qpid/sys/Thread.h @@ -25,7 +25,11 @@ #include "qpid/CommonImportExport.h" #ifdef _WIN32 -# define QPID_TSS __declspec(thread) +# ifdef _MSC_VER +# define QPID_TSS __declspec(thread) +# else +# define QPID_TSS __thread +# endif #elif defined (__GNUC__) # define QPID_TSS __thread #elif defined (__SUNPRO_CC) diff --git a/cpp/include/qpid/sys/Time.h b/cpp/include/qpid/sys/Time.h index d3ab832229..9c5ac66e9a 100644 --- a/cpp/include/qpid/sys/Time.h +++ b/cpp/include/qpid/sys/Time.h @@ -119,7 +119,7 @@ class Duration { friend class AbsTime; public: - QPID_COMMON_EXTERN inline Duration(int64_t time0 = 0); + QPID_COMMON_INLINE_EXTERN inline Duration(int64_t time0 = 0); QPID_COMMON_EXTERN explicit Duration(const AbsTime& start, const AbsTime& finish); inline operator int64_t() const; }; @@ -167,6 +167,9 @@ QPID_COMMON_EXTERN void usleep(uint64_t usecs); /** Output formatted date/time for now*/ void outputFormattedNow(std::ostream&); +/** Output unformatted nanosecond-resolution time for now */ +void outputHiresNow(std::ostream&); + }} #endif /*!_sys_Time_h*/ diff --git a/cpp/include/qpid/sys/windows/IntegerTypes.h b/cpp/include/qpid/sys/windows/IntegerTypes.h index ece1a618e9..28b82da1a0 100755 --- a/cpp/include/qpid/sys/windows/IntegerTypes.h +++ b/cpp/include/qpid/sys/windows/IntegerTypes.h @@ -22,13 +22,17 @@ */ typedef unsigned char uint8_t; -typedef char int8_t; typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned int uint32_t; typedef int int32_t; +#if defined(_MSC_VER) +typedef signed char int8_t; typedef unsigned __int64 uint64_t; typedef __int64 int64_t; +#else +#include <stdint.h> +#endif // Visual Studio doesn't define other common types, so set them up here too. typedef unsigned int uint; diff --git a/cpp/include/qpid/types/Exception.h b/cpp/include/qpid/types/Exception.h index d061a7df0e..483d104cc8 100644 --- a/cpp/include/qpid/types/Exception.h +++ b/cpp/include/qpid/types/Exception.h @@ -28,7 +28,7 @@ namespace qpid { namespace types { -class Exception : public std::exception +class QPID_TYPES_CLASS_EXTERN Exception : public std::exception { public: QPID_TYPES_EXTERN explicit Exception(const std::string& message=std::string()) throw(); diff --git a/cpp/include/qpid/types/ImportExport.h b/cpp/include/qpid/types/ImportExport.h index bb10575fcd..8fa41884fb 100644 --- a/cpp/include/qpid/types/ImportExport.h +++ b/cpp/include/qpid/types/ImportExport.h @@ -20,14 +20,16 @@ * under the License. */ -#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#include "qpid/ImportExport.h" + #if defined(TYPES_EXPORT) || defined (qpidtypes_EXPORTS) -#define QPID_TYPES_EXTERN __declspec(dllexport) -#else -#define QPID_TYPES_EXTERN __declspec(dllimport) -#endif +# define QPID_TYPES_EXTERN QPID_EXPORT +# define QPID_TYPES_CLASS_EXTERN QPID_CLASS_EXPORT +# define QPID_TYPES_INLINE_EXTERN QPID_INLINE_EXPORT #else -#define QPID_TYPES_EXTERN +# define QPID_TYPES_EXTERN QPID_IMPORT +# define QPID_TYPES_CLASS_EXTERN QPID_CLASS_IMPORT +# define QPID_TYPES_INLINE_EXTERN QPID_INLINE_IMPORT #endif #endif /*!QPID_TYPES_IMPORTEXPORT_H*/ diff --git a/cpp/include/qpid/types/Uuid.h b/cpp/include/qpid/types/Uuid.h index 467a895184..02af4c7e7f 100644 --- a/cpp/include/qpid/types/Uuid.h +++ b/cpp/include/qpid/types/Uuid.h @@ -29,7 +29,7 @@ namespace qpid { namespace types { -class Uuid +class QPID_TYPES_CLASS_EXTERN Uuid { public: static const size_t SIZE; diff --git a/cpp/include/qpid/types/Variant.h b/cpp/include/qpid/types/Variant.h index 9ae672b7c2..4459fc4123 100644 --- a/cpp/include/qpid/types/Variant.h +++ b/cpp/include/qpid/types/Variant.h @@ -36,7 +36,7 @@ namespace types { /** * Thrown when an illegal conversion of a variant is attempted. */ -struct InvalidConversion : public Exception +struct QPID_TYPES_CLASS_EXTERN InvalidConversion : public Exception { InvalidConversion(const std::string& msg); }; @@ -60,12 +60,14 @@ enum VariantType { VAR_UUID }; +std::string getTypeName(VariantType type); + class VariantImpl; /** * Represents a value of variable type. */ -class Variant +class QPID_TYPES_CLASS_EXTERN Variant { public: typedef std::map<std::string, Variant> Map; |