From 7753a6839ac0abb282e2d4372f7a4199243cf4ff Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 19 Aug 2009 18:31:31 +0000 Subject: Introduce the public includes for the QMF interfaces. Rename Agent to AgentEngine to differentiate the API from the underlying engine. Note that some of these public headers will overlap with the emerging "messaging" API (notably Connection.h and ConnectionSettings.h). It is desirable that these components of the API become common between "messaging" and "qmf". As such, once the differences are reconciled, they will most likely be removed from the qmf space and placed in the messaging space. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@805916 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 283 ++++++++++++++++++++++++++++++ qpid/cpp/include/qmf/AgentObject.h | 93 ++++++++++ qpid/cpp/include/qmf/Connection.h | 118 +++++++++++++ qpid/cpp/include/qmf/ConnectionSettings.h | 135 ++++++++++++++ qpid/cpp/include/qmf/QmfImportExport.h | 33 ++++ 5 files changed, 662 insertions(+) create mode 100644 qpid/cpp/include/qmf/Agent.h create mode 100644 qpid/cpp/include/qmf/AgentObject.h create mode 100644 qpid/cpp/include/qmf/Connection.h create mode 100644 qpid/cpp/include/qmf/ConnectionSettings.h create mode 100644 qpid/cpp/include/qmf/QmfImportExport.h (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h new file mode 100644 index 0000000000..2ba639ca37 --- /dev/null +++ b/qpid/cpp/include/qmf/Agent.h @@ -0,0 +1,283 @@ +#ifndef _QmfAgent_ +#define _QmfAgent_ + +/* + * 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/QmfImportExport.h" + +namespace qmf { + + class AgentImpl; + class Connection; + class ObjectId; + class AgentObject; + class Value; + class Event; + class SchemaObjectClass; + + /** + * AgentListener is used by agents that select the internalStore=false option (see Agent + * constructor) or by agents that wish to provide access control for queries and methods. + */ + class AgentListener { + QMF_EXTERN virtual ~AgentListener(); + + /** + * allowQuery is called before a query operation is executed. If true is returned + * by this function, the query will proceed. If false is returned, the query will + * be forbidden. + * + * @param q The query being requested. + * @param userId The authenticated identity of the user requesting the query. + */ + virtual bool allowQuery(const Query& q, const char* userId); + + /** + * allowMethod is called before a method call is executed. If true is returned + * by this function, the method call will proceed. If false is returned, the method + * call will be forbidden. + * + * @param name The name of the method being called. + * @param args A value object (of type "map") that contains both input and output arguments. + * @param oid The objectId that identifies the instance of the object being called. + * @param cls The Schema describing the object being called. + * @param userId The authenticated identity of the requesting user. + */ + virtual bool allowMethod(const char* name, const Value& args, const ObjectId& oid, + const SchemaObjectClass& cls, const char* userId); + + /** + * query is called when the agent receives a query request. The handler must invoke + * Agent::queryResponse zero or more times (using the supplied context) followed by + * a single invocation of Agent::queryComplete. These calls do not need to be made + * synchronously in the context of this function. They may occur before or after this + * function returns. + * + * This function will only be invoked if internalStore=false in the Agent's constructor. + * + * @param context A context value to use in resulting calls to queryResponse and quertComplete. + * @param q The query requested by the console. + * @param userId the authenticated identity of the user requesting the query. + */ + virtual void query(uint32_t context, const Query& q, const char* userId); + + /** + * syncStart is called when a console requests a standing query. This function must + * behave exactly like AgentListener::query (i.e. send zero or more responses followed + * by a queryComplete) except it then remembers the context and the query and makes + * subsequent queryResponse calls whenever appropriate according the the query. + * + * The standing query shall stay in effect until syncStop is called with the same context + * value or until a specified period of time elapses without receiving a syncTouch for the + * context. + * + * This function will only be invoked if internalStore=false in the Agent's constructor. + * + * @param context A context value to use in resulting calls to queryResponse and queryComplete. + * @param q The query requested by the console. + * @param userId the authenticated identity of the user requesting the query. + */ + virtual void syncStart(uint32_t context, const Query& q, const char* userId); + + /** + * syncTouch is called when the console that requested a standing query refreshes its + * interest in the query. The console must periodically "touch" a standing query to keep + * it alive. This prevents standing queries from accumulating when the console disconnects + * before it can stop the query. + * + * This function will only be invoked if internalStore=false in the Agent's constructor. + * + * @param context The context supplied in a previous call to syncStart. + * @param userId The authenticated identity of the requesting user. + */ + virtual void syncTouch(uint32_t context, const char* userId); + + /** + * syncStop is called when the console that requested a standing query no longer wishes to + * receive data associated with that query. The application shall stop processing this + * query and shall remove its record of the context value. + * + * This function will only be invoked if internalStore=false in the Agent's constructor. + * + * @param context The context supplied in a previous call to syncStart. + * @param userId The authenticated identity of the requesting user. + */ + virtual void syncStop(uint32_t context, const char* userId); + + /** + * methodCall is called when a console invokes a method on a QMF object. The application + * must call Agent::methodResponse once in response to this function. The response does + * not need to be called synchronously in the context of this function. It may be called + * before or after this function returns. + * + * This function will only be invoked if internalStore=false in the Agent's constructor. + * + * @param context A context value to use in resulting call to methodResponse. + * @param name The name of the method being called. + * @param args A value object (of type "map") that contains both input and output arguments. + * @param oid The objectId that identifies the instance of the object being called. + * @param cls The Schema describing the object being called. + * @param userId The authenticated identity of the requesting user. + */ + virtual void methodCall(uint32_t context, const char* name, Value& args, + const ObjectId& oid, const SchemaObjectClass& cls, const char* userId); + }; + + /** + * The Agent class is the QMF Agent portal. It should be instantiated once and associated with a + * Connection (setConnection) to connect an agent to the QMF infrastructure. + */ + class Agent { + public: + /** + * Create an instance of the Agent class. + * + * @param label An optional string label that can be used to identify the agent. + * + * @param internalStore If true, objects shall be tracked internally by the agent. + * If false, the user of the agent must track the objects. + * If the agent is tracking the objects, queries and syncs are handled by + * the agent. The only involvement the user has is to optionally authorize + * individual operations. If the user is tracking the objects, the user code + * must implement queries and syncs (standing queries). + * + * @param listener A pointer to a class that implements the AgentListener interface. + * This must be supplied if any of the following conditions are true: + * - The agent model contains methods + * - The user wishes to individually authorize query and sync operations. + * - internalStore = false + */ + QMF_EXTERN Agent(char* label="qmfa", bool internalStore=true, AgentListener* listener=0); + + /** + * Destroy an instance of the Agent class. + */ + QMF_EXTERN ~Agent(); + + /** + * Set the persistent store file. This file, if specified, is used to store state information + * about the Agent. For example, if object-ids must be persistent across restarts of the Agent + * program, this file path must be supplied. + * + * @param path Full path to a file that is both writable and readable by the Agent program. + */ + QMF_EXTERN void setStoreDir(const char* path); + + /** + * Provide a connection (to a Qpid broker) over which the agent can communicate. + * + * @param conn Pointer to a Connection object. + */ + QMF_EXTERN void setConnection(Connection* conn); + + /** + * Register a class schema (object or event) with the agent. The agent must have a registered + * schema for an object class or an event class before it can handle objects or events of that + * class. + * + * @param cls Pointer to the schema structure describing the class. + */ + QMF_EXTERN void registerClass(SchemaObjectClass* cls); + QMF_EXTERN void registerClass(SchemaEventClass* cls); + + /** + * Add an object to the agent (for internal storage mode only). + * + * @param obj Reference to the object to be managed by the agent. + * + * @param persistent Iff true, the object ID assigned to the object shall indicate persistence + * (i.e. the object ID shall be the same across restarts of the agent program). + * + * @param oid 64-bit value for the oid (if zero, the agent will assign the value). + * + * @param oidLo 32-bit value for the lower 32-bits of the oid. + * + * @param oidHi 32-bit value for the upper 32-bits of the oid. + */ + QMF_EXTERN const ObjectId* addObject(AgentObject& obj, bool persistent=false, uint64_t oid=0); + QMF_EXTERN const ObjectId* addObject(AgentObject& obj, bool persistent, uint32_t oidLo, uint32_t oidHi); + + /** + * Allocate an object ID for an object (for external storage mode only). + * + * @param persistent Iff true, the object ID allocated shall indicate persistence + * (i.e. the object ID shall be the same across restarts of the agent program). + * + * @param oid 64-bit value for the oid (if zero, the agent will assign the value). + * + * @param oidLo 32-bit value for the lower 32-bits of the oid. + * + * @param oidHi 32-bit value for the upper 32-bits of the oid. + */ + QMF_EXTERN const ObjectId* allocObjectId(bool persistent=false, uint64_t oid=0); + QMF_EXTERN const ObjectId* allocObjectId(bool persistent, uint32_t oidLo, uint32_t oidHi); + + /** + * Raise a QMF event. + * + * @param event Reference to an event object to be raised to the QMF infrastructure. + */ + QMF_EXTERN void raiseEvent(Event& event); + + /** + * Provide a response to a query (for external storage mode only). + * + * @param context The context value supplied in the query (via the AgentListener interface). + * + * @param object A reference to the agent that matched the query criteria. + * + * @param prop If true, transmit the property attributes of this object. + * + * @param stat If true, transmit the statistic attributes of this object. + */ + QMF_EXTERN void queryResponse(uint32_t context, AgentObject& object, bool prop = true, bool stat = true); + + /** + * Indicate that a query (or the initial dump of a sync) is complete (for external storage mode only). + * + * @param context The context value supplied in the query/sync (via the AgentListener interface). + */ + QMF_EXTERN void queryComplete(uint32_t context); + + /** + * Provide the response to a method call. + * + * @param context The context value supplied in the method request (via the AgentListener interface). + * + * @param args The argument list from the method call. Must include the output arguments (may include + * the input arguments). + * + * @param status Numerical return status: zero indicates no error, non-zero indicates error. + * + * @param exception Pointer to an exception value. If status is non-zero, the exception value is + * sent to the caller. It is optional (i.e. leave the pointer as 0), or may be + * set to any legal value. A string may be supplied, but an unmanaged object of + * any schema may also be passed. + */ + QMF_EXTERN void methodResponse(uint32_t context, const Value& args, uint32_t status=0, + const Value* exception=0); + + private: + AgentImpl* impl; + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/AgentObject.h b/qpid/cpp/include/qmf/AgentObject.h new file mode 100644 index 0000000000..d6073bca3c --- /dev/null +++ b/qpid/cpp/include/qmf/AgentObject.h @@ -0,0 +1,93 @@ +#ifndef _QmfAgentObject_ +#define _QmfAgentObject_ + +/* + * 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/QmfImportExport.h" + +namespace qmf { + + class AgentObjectImpl; + class SchemaObjectClass; + class ObjectId; + class Value; + class Agent; + + /** + * AgentObject is an extension of Object with agent-specific methods added. + */ + class AgentObject : public Object { + public: + /** + * Create a new Object of a specific type. + * + * @param type Pointer to the schema class to use as a type for this object. + */ + QMF_EXTERN AgentObject(const SchemaObjectClass* type); + + /** + * Schedule this object for deletion. Agent objects should never be directly + * destroyed, rather this method should be called and all pointers to this + * object dropped. The agent will clean up and properly delete the object at + * the appropraite time. + */ + QMF_EXTERN void destroy(); + + /** + * Set the object ID for this object if it is to be managed by the agent. + * + * @param oid The new object ID for the managed object. + */ + QMF_EXTERN void setObjectId(ObjectId& oid); + + /** + * Handler for invoked method calls. This will only be called for objects that + * are being managed and stored by an agent (see internalStore argument in Agent::Agent). + * If this function is not overridden in a child class, the default implementation will + * cause AgentListener::methodCall to be invoked in the application program. + * + * If this function is overridden in a sub-class, the implementation must perform + * the actions associated with the method call (i.e. implement the method). Once the + * method execution is complete, it must call Agent::methodResponse with the result + * of the method execution. Agent::methodResponse does not need to be called + * synchronously in the context of this function call. It may be called at a later + * time from a different thread. + * + * @param context Context supplied by the agent and required to be passed in the + * call to Agent::methodResponse + * + * @param name The name of the method. + * + * @param args A Value (of type map) that contains the input and output arguments. + * + * @param userId The authenticated identity of the user who invoked the method. + */ + QMF_EXTERN virtual void methodInvoked(uint32_t context, const char* name, Value& args, + const char* userId); + private: + friend class Agent; + virtual ~AgentObject(); + void setAgent(Agent* agent); + AgentObjectImpl* impl; + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/Connection.h b/qpid/cpp/include/qmf/Connection.h new file mode 100644 index 0000000000..dbe8e97cfe --- /dev/null +++ b/qpid/cpp/include/qmf/Connection.h @@ -0,0 +1,118 @@ +#ifndef _QmfConnection_ +#define _QmfConnection_ + +/* + * 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/QmfImportExport.h" +#include "qmf/ConnectionSettings.h" + +namespace qmf { + + enum ConnectionState { + CONNECTION_UP = 1, + CONNECTION_DOWN = 2 + }; + + /** + * Implement a subclass of ConnectionListener and provide it with the + * Connection constructor to receive notification of changes in the + * connection state. + * + * \ingroup qmfapi + */ + class ConnectionListener { + QMF_EXTERN virtual ~ConnectionListener(); + + /** + * Called each time the state of the connection changes. + */ + virtual void newState(ConnectionState state); + + /** + * Called if the connection requires input from an interactive client. + * + * @param prompt Text of the prompt - describes what information is required. + * @param answer The interactive user input. + * @param answerLen on Input - the maximum number of bytes that can be copied to answer. + * on Output - the number of bytes copied to answer. + */ + virtual void interactivePrompt(const char* prompt, char* answer, uint32_t answerLen); + }; + + class ConnectionImpl; + + /** + * The Connection class represents a connection to a QPID broker that can + * be used by agents and consoles, possibly multiple at the same time. + * + * \ingroup qmfapi + */ + class Connection { + public: + + /** + * Creates a connection object and begins the process of attempting to + * connect to the QPID broker. + * + * @param settings The settings that control how the connection is set + * up. + * + * @param listener An optional pointer to a subclass of + * ConnectionListener to receive notifications of events related to + * this connection. + */ + QMF_EXTERN Connection(const ConnectionSettings& settings, + const ConnectionListener* listener = 0); + + /** + * Destroys a connection, causing the connection to be closed. + */ + QMF_EXTERN ~Connection(); + + /** + * Set the administrative state of the connection (enabled or disabled). + * + * @param enabled True => enable connection, False => disable connection + */ + QMF_EXTERN void setAdminState(bool enabled); + + /** + * Return the current operational state of the connection (up or down). + * + * @return the current connection state. + */ + QMF_EXTERN ConnectionState getOperState() const; + + /** + * Get the error message from the last failure to connect. + * + * @return Null-terminated string containing the error message. + */ + QMF_EXTERN const char* getLastError() const; + + private: + friend class AgentImpl; + friend class ConsoleImpl; + ConnectionImpl* impl; + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h new file mode 100644 index 0000000000..b5f3be7eef --- /dev/null +++ b/qpid/cpp/include/qmf/ConnectionSettings.h @@ -0,0 +1,135 @@ +#ifndef _QmfConnectionSettings_ +#define _QmfConnectionSettings_ + +/* + * 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/QmfImportExport.h" + +namespace qmf { + + class ConnectionSettingsImpl; + class Value; + + /** + * Settings for AMQP connections to the broker. + */ + class ConnectionSettings { + public: + + /** + * Create a set of default connection settings. + * + * If no further attributes are set, the settings will cause a connection to be made to + * the default broker (on localhost or at a host/port supplied by service discovery) and + * authentication will be the best-available (GSSAPI/Kerberos, Anonymous, Plain with prompts + * for username and password). + */ + QMF_EXTERN ConnectionSettings(); + + /** + * Create a set of connection settings by URL. + * + * @param url Universal resource locator describing the broker address and additional attributes. + * + * The URL is of the form: + * amqp[s]://host[:port][?key=value[&key=value]*] + * + * For example: + * amqp://localhost + * amqp://broker?transport=rdma&authmech=GSSAPI&authservice=qpidd + * amqps://broker?authmech=PLAIN&authuser=guest&authpass=guest + */ + QMF_EXTERN ConnectionSettings(const char* url); + + /** + * Destroy the connection settings object. + */ + QMF_EXTERN ~ConnectionSettings(); + + /** + * Set an attribute to control connection setup. + * + * @param key A null-terminated string that is an attribute name. + * + * @param value Reference to a value to be stored as the attribute. The type of the value + * is specific to the key. + */ + QMF_EXTERN void setAttr(const char* key, const Value& value); + + /** + * Get the value of an attribute. + * + * @param key A null-terminated attribute name. + */ + QMF_EXTERN const Value& getAttr(const char* key) const; + + /** + * Get the attribute string (the portion of the URL following the '?') for the settings. + * + * @return A pointer to the attribute string. If the content of this string needs to be + * available beyond the scope of the calling function, it should be copied. The + * returned pointer may become invalid if the set of attributes is changed. + */ + QMF_EXTERN const char* getAttrString() const; + + /** + * Shortcuts for setting the transport for the connection. + * + * @param port The port value for the connection address. + */ + QMF_EXTERN void transportTcp(uint16_t port = 5672); + QMF_EXTERN void transportSsl(uint16_t port = 5671); + QMF_EXTERN void transportRdma(uint16_t port = 5672); + + /** + * Shortcuts for setting authentication mechanisms. + * + * @param username Null-terminated authentication user name. + * + * @param password Null-terminated authentication password. + * + * @param serviceName Null-terminated GSSAPI service name (Kerberos service principal) + * + * @param minSsf Minimum security factor for connections. 0 = encryption not required. + * + * @param maxSsf Maximum security factor for connections. 0 = encryption not permitted. + */ + QMF_EXTERN void authAnonymous(const char* username = 0); + QMF_EXTERN void authPlain(const char* username = 0, const char* password = 0); + QMF_EXTERN void authGssapi(const char* serviceName, uint32_t minSsf = 0, uint32_t maxSsf = 256); + + /** + * Shortcut for setting connection retry attributes. + * + * @param delayMin Minimum delay (in seconds) between connection attempts. + * + * @param delaxMax Maximum delay (in seconds) between connection attempts. + * + * @param delayFactor Factor to multiply the delay by between failed connection attempts. + */ + QMF_EXTERN void setRetry(int delayMin = 1, int delayMax = 128, int delayFactor = 2); + + private: + ConnectionSettingsImpl* impl; + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/QmfImportExport.h b/qpid/cpp/include/qmf/QmfImportExport.h new file mode 100644 index 0000000000..8353a3cc16 --- /dev/null +++ b/qpid/cpp/include/qmf/QmfImportExport.h @@ -0,0 +1,33 @@ +#ifndef QMF_IMPORT_EXPORT_H +#define QMF_IMPORT_EXPORT_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. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +# if defined(QMF_EXPORT) || defined (qmf_EXPORTS) +# define QMF_EXTERN __declspec(dllexport) +# else +# define QMF_EXTERN __declspec(dllimport) +# endif +#else +# define QMF_EXTERN +#endif + +#endif -- cgit v1.2.1 From eaad487ef5d7233af17e9abf6f226fa962ebc931 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 19 Aug 2009 20:01:57 +0000 Subject: Fixed doxygen generation for the C++ APIs git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@805955 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 4 ++++ qpid/cpp/include/qmf/AgentObject.h | 2 ++ qpid/cpp/include/qmf/Connection.h | 5 +++++ qpid/cpp/include/qmf/ConnectionSettings.h | 2 ++ 4 files changed, 13 insertions(+) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h index 2ba639ca37..e61cd737d0 100644 --- a/qpid/cpp/include/qmf/Agent.h +++ b/qpid/cpp/include/qmf/Agent.h @@ -35,6 +35,8 @@ namespace qmf { /** * AgentListener is used by agents that select the internalStore=false option (see Agent * constructor) or by agents that wish to provide access control for queries and methods. + * + * \ingroup qmfapi */ class AgentListener { QMF_EXTERN virtual ~AgentListener(); @@ -143,6 +145,8 @@ namespace qmf { /** * The Agent class is the QMF Agent portal. It should be instantiated once and associated with a * Connection (setConnection) to connect an agent to the QMF infrastructure. + * + * \ingroup qmfapi */ class Agent { public: diff --git a/qpid/cpp/include/qmf/AgentObject.h b/qpid/cpp/include/qmf/AgentObject.h index d6073bca3c..a1878605eb 100644 --- a/qpid/cpp/include/qmf/AgentObject.h +++ b/qpid/cpp/include/qmf/AgentObject.h @@ -32,6 +32,8 @@ namespace qmf { /** * AgentObject is an extension of Object with agent-specific methods added. + * + * \ingroup qmfapi */ class AgentObject : public Object { public: diff --git a/qpid/cpp/include/qmf/Connection.h b/qpid/cpp/include/qmf/Connection.h index dbe8e97cfe..b910cdad19 100644 --- a/qpid/cpp/include/qmf/Connection.h +++ b/qpid/cpp/include/qmf/Connection.h @@ -25,6 +25,11 @@ namespace qmf { + /** + * Operational states for Connections. + * + * \ingroup qmfapi + */ enum ConnectionState { CONNECTION_UP = 1, CONNECTION_DOWN = 2 diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h index b5f3be7eef..53a83dfd2a 100644 --- a/qpid/cpp/include/qmf/ConnectionSettings.h +++ b/qpid/cpp/include/qmf/ConnectionSettings.h @@ -29,6 +29,8 @@ namespace qmf { /** * Settings for AMQP connections to the broker. + * + * \ingroup qmfapi */ class ConnectionSettings { public: -- cgit v1.2.1 From 95931ede08d91630c1cb8b1d3c3ca2d22079e4ba Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 21 Aug 2009 21:19:22 +0000 Subject: Implemented the new QMF ConnectionSettings and incorporated into the bindings. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@806725 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Connection.h | 2 ++ qpid/cpp/include/qmf/ConnectionSettings.h | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/Connection.h b/qpid/cpp/include/qmf/Connection.h index b910cdad19..f648b1427f 100644 --- a/qpid/cpp/include/qmf/Connection.h +++ b/qpid/cpp/include/qmf/Connection.h @@ -47,6 +47,8 @@ namespace qmf { /** * Called each time the state of the connection changes. + * + * @param state the new state */ virtual void newState(ConnectionState state); diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h index 53a83dfd2a..9bd6922a56 100644 --- a/qpid/cpp/include/qmf/ConnectionSettings.h +++ b/qpid/cpp/include/qmf/ConnectionSettings.h @@ -21,6 +21,7 @@ */ #include "qmf/QmfImportExport.h" +#include "qpid/sys/IntegerTypes.h" namespace qmf { @@ -35,6 +36,8 @@ namespace qmf { class ConnectionSettings { public: + ConnectionSettings(const ConnectionSettings& copy); + /** * Create a set of default connection settings. * @@ -79,8 +82,10 @@ namespace qmf { * Get the value of an attribute. * * @param key A null-terminated attribute name. + * + * @return The value associated with the attribute name. */ - QMF_EXTERN const Value& getAttr(const char* key) const; + QMF_EXTERN Value getAttr(const char* key) const; /** * Get the attribute string (the portion of the URL following the '?') for the settings. @@ -129,6 +134,7 @@ namespace qmf { QMF_EXTERN void setRetry(int delayMin = 1, int delayMax = 128, int delayFactor = 2); private: + friend class ResilientConnectionImpl; ConnectionSettingsImpl* impl; }; -- cgit v1.2.1 From 32c4f003827349ed7cc24f7e870c8833b30c277d Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Fri, 4 Sep 2009 21:19:13 +0000 Subject: Pick up correct CMake-set macro (qmfcommon_EXPORTS) to flip import/export for qmfcommon lib git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@811553 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/QmfImportExport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/QmfImportExport.h b/qpid/cpp/include/qmf/QmfImportExport.h index 8353a3cc16..f5e1d9127c 100644 --- a/qpid/cpp/include/qmf/QmfImportExport.h +++ b/qpid/cpp/include/qmf/QmfImportExport.h @@ -21,7 +21,7 @@ */ #if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -# if defined(QMF_EXPORT) || defined (qmf_EXPORTS) +# if defined(QMF_EXPORT) || defined (qmfcommon_EXPORTS) # define QMF_EXTERN __declspec(dllexport) # else # define QMF_EXTERN __declspec(dllimport) -- cgit v1.2.1 From c8fa5fa308f6ad9be22612568ace703777fbb6d9 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 18 Sep 2009 20:15:15 +0000 Subject: Refactored the QMF engine to adhere to the following rules regarding the pimpl (Pointer to Implementation) pattern: 1) Impl classes have constructors matching the public constructors 2) Additional Impl constructors are accessed through a static factory function 3) All linkages to objects are to the public object 4) If a back-link (from Impl to public) is needed, the Impl class must be derived from boost::noncopyable 5) All public classes have non-default copy constructors that make a copy of the Impl class git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@816770 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/ConnectionSettings.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h index 9bd6922a56..5ba49226fc 100644 --- a/qpid/cpp/include/qmf/ConnectionSettings.h +++ b/qpid/cpp/include/qmf/ConnectionSettings.h @@ -36,8 +36,6 @@ namespace qmf { class ConnectionSettings { public: - ConnectionSettings(const ConnectionSettings& copy); - /** * Create a set of default connection settings. * @@ -63,6 +61,11 @@ namespace qmf { */ QMF_EXTERN ConnectionSettings(const char* url); + /** + * Copy Constructor. + */ + ConnectionSettings(const ConnectionSettings& from); + /** * Destroy the connection settings object. */ -- cgit v1.2.1 From 4e9025e343b611268d8164d255282b2198332597 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 25 Sep 2009 20:24:22 +0000 Subject: QMF updates: - Refactored into two namespaces: 1) 'qmf' for the public QMF api (c++) 2) 'qmf::engine' for the public engine API (used for language bindings) - Added object and first_object calls to Console (in Ruby) - Made objects call compatible with the kwarg arguments used in the older API - Added to_s functions to classes that needed them git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@818994 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/ConnectionSettings.h | 146 ------------- qpid/cpp/include/qmf/ConsoleObject.h | 94 +++++++++ qpid/cpp/include/qmf/engine/Agent.h | 209 +++++++++++++++++++ qpid/cpp/include/qmf/engine/ConnectionSettings.h | 148 +++++++++++++ qpid/cpp/include/qmf/engine/Console.h | 228 +++++++++++++++++++++ qpid/cpp/include/qmf/engine/Event.h | 32 +++ qpid/cpp/include/qmf/engine/Message.h | 41 ++++ qpid/cpp/include/qmf/engine/Object.h | 56 +++++ qpid/cpp/include/qmf/engine/ObjectId.h | 62 ++++++ .../cpp/include/qmf/engine/QmfEngineImportExport.h | 33 +++ qpid/cpp/include/qmf/engine/Query.h | 110 ++++++++++ qpid/cpp/include/qmf/engine/ResilientConnection.h | 165 +++++++++++++++ qpid/cpp/include/qmf/engine/Schema.h | 209 +++++++++++++++++++ qpid/cpp/include/qmf/engine/Typecode.h | 53 +++++ qpid/cpp/include/qmf/engine/Value.h | 121 +++++++++++ 15 files changed, 1561 insertions(+), 146 deletions(-) delete mode 100644 qpid/cpp/include/qmf/ConnectionSettings.h create mode 100644 qpid/cpp/include/qmf/ConsoleObject.h create mode 100644 qpid/cpp/include/qmf/engine/Agent.h create mode 100644 qpid/cpp/include/qmf/engine/ConnectionSettings.h create mode 100644 qpid/cpp/include/qmf/engine/Console.h create mode 100644 qpid/cpp/include/qmf/engine/Event.h create mode 100644 qpid/cpp/include/qmf/engine/Message.h create mode 100644 qpid/cpp/include/qmf/engine/Object.h create mode 100644 qpid/cpp/include/qmf/engine/ObjectId.h create mode 100644 qpid/cpp/include/qmf/engine/QmfEngineImportExport.h create mode 100644 qpid/cpp/include/qmf/engine/Query.h create mode 100644 qpid/cpp/include/qmf/engine/ResilientConnection.h create mode 100644 qpid/cpp/include/qmf/engine/Schema.h create mode 100644 qpid/cpp/include/qmf/engine/Typecode.h create mode 100644 qpid/cpp/include/qmf/engine/Value.h (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h deleted file mode 100644 index 5ba49226fc..0000000000 --- a/qpid/cpp/include/qmf/ConnectionSettings.h +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef _QmfConnectionSettings_ -#define _QmfConnectionSettings_ - -/* - * 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/QmfImportExport.h" -#include "qpid/sys/IntegerTypes.h" - -namespace qmf { - - class ConnectionSettingsImpl; - class Value; - - /** - * Settings for AMQP connections to the broker. - * - * \ingroup qmfapi - */ - class ConnectionSettings { - public: - - /** - * Create a set of default connection settings. - * - * If no further attributes are set, the settings will cause a connection to be made to - * the default broker (on localhost or at a host/port supplied by service discovery) and - * authentication will be the best-available (GSSAPI/Kerberos, Anonymous, Plain with prompts - * for username and password). - */ - QMF_EXTERN ConnectionSettings(); - - /** - * Create a set of connection settings by URL. - * - * @param url Universal resource locator describing the broker address and additional attributes. - * - * The URL is of the form: - * amqp[s]://host[:port][?key=value[&key=value]*] - * - * For example: - * amqp://localhost - * amqp://broker?transport=rdma&authmech=GSSAPI&authservice=qpidd - * amqps://broker?authmech=PLAIN&authuser=guest&authpass=guest - */ - QMF_EXTERN ConnectionSettings(const char* url); - - /** - * Copy Constructor. - */ - ConnectionSettings(const ConnectionSettings& from); - - /** - * Destroy the connection settings object. - */ - QMF_EXTERN ~ConnectionSettings(); - - /** - * Set an attribute to control connection setup. - * - * @param key A null-terminated string that is an attribute name. - * - * @param value Reference to a value to be stored as the attribute. The type of the value - * is specific to the key. - */ - QMF_EXTERN void setAttr(const char* key, const Value& value); - - /** - * Get the value of an attribute. - * - * @param key A null-terminated attribute name. - * - * @return The value associated with the attribute name. - */ - QMF_EXTERN Value getAttr(const char* key) const; - - /** - * Get the attribute string (the portion of the URL following the '?') for the settings. - * - * @return A pointer to the attribute string. If the content of this string needs to be - * available beyond the scope of the calling function, it should be copied. The - * returned pointer may become invalid if the set of attributes is changed. - */ - QMF_EXTERN const char* getAttrString() const; - - /** - * Shortcuts for setting the transport for the connection. - * - * @param port The port value for the connection address. - */ - QMF_EXTERN void transportTcp(uint16_t port = 5672); - QMF_EXTERN void transportSsl(uint16_t port = 5671); - QMF_EXTERN void transportRdma(uint16_t port = 5672); - - /** - * Shortcuts for setting authentication mechanisms. - * - * @param username Null-terminated authentication user name. - * - * @param password Null-terminated authentication password. - * - * @param serviceName Null-terminated GSSAPI service name (Kerberos service principal) - * - * @param minSsf Minimum security factor for connections. 0 = encryption not required. - * - * @param maxSsf Maximum security factor for connections. 0 = encryption not permitted. - */ - QMF_EXTERN void authAnonymous(const char* username = 0); - QMF_EXTERN void authPlain(const char* username = 0, const char* password = 0); - QMF_EXTERN void authGssapi(const char* serviceName, uint32_t minSsf = 0, uint32_t maxSsf = 256); - - /** - * Shortcut for setting connection retry attributes. - * - * @param delayMin Minimum delay (in seconds) between connection attempts. - * - * @param delaxMax Maximum delay (in seconds) between connection attempts. - * - * @param delayFactor Factor to multiply the delay by between failed connection attempts. - */ - QMF_EXTERN void setRetry(int delayMin = 1, int delayMax = 128, int delayFactor = 2); - - private: - friend class ResilientConnectionImpl; - ConnectionSettingsImpl* impl; - }; - -} - -#endif diff --git a/qpid/cpp/include/qmf/ConsoleObject.h b/qpid/cpp/include/qmf/ConsoleObject.h new file mode 100644 index 0000000000..acbc285e05 --- /dev/null +++ b/qpid/cpp/include/qmf/ConsoleObject.h @@ -0,0 +1,94 @@ +#ifndef _QmfConsoleObject_ +#define _QmfConsoleObject_ + +/* + * 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/QmfImportExport.h" + +namespace qmf { + + class ConsoleObjectImpl; + class SchemaObjectClass; + class ObjectId; + class Value; + + /** + * ConsoleObject is an extension of Object with console-specific methods added. + * + * \ingroup qmfapi + */ + class ConsoleObject : public Object { + public: + /** + * Create a new Object of a specific type. + * + * @param type Pointer to the schema class to use as a type for this object. + */ + QMF_EXTERN ConsoleObject(const SchemaObjectClass* type); + + /** + * Destroy the object. + */ + QMF_EXTERN virtual ~ConsoleObject(); + + /** + * + */ + QMF_EXTERN const SchemaObjectClass* getSchema() const; + + /** + * + */ + QMF_EXTERN ObjectId* getObjectId() const; + + /** + * + */ + QMF_EXTERN uint64_t getCurrentTime() const; + QMF_EXTERN uint64_t getCreateTime() const; + QMF_EXTERN uint64_t getDeleteTime() const; + + /** + * + */ + QMF_EXTERN bool isDeleted() const; + + /** + * + */ + QMF_EXTERN void update(); + + /** + * + */ + QMF_EXTERN void invokeMethod(const char* name, const Value* arguments, MethodResult& result); + + /** + * + */ + QMF_EXTERN uint32_t invokeMethodAsync(const char* name, const Value* arguments = 0); + + private: + ConsoleObjectImpl* impl; + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/engine/Agent.h b/qpid/cpp/include/qmf/engine/Agent.h new file mode 100644 index 0000000000..71abf82254 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Agent.h @@ -0,0 +1,209 @@ +#ifndef _QmfEngineAgent_ +#define _QmfEngineAgent_ + +/* + * 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 +#include +#include +#include +#include +#include +#include + +namespace qmf { +namespace engine { + + /** + * AgentEvent + * + * This structure represents a QMF event coming from the agent to + * the application. + */ + struct AgentEvent { + enum EventKind { + GET_QUERY = 1, + START_SYNC = 2, + END_SYNC = 3, + METHOD_CALL = 4, + DECLARE_QUEUE = 5, + DELETE_QUEUE = 6, + BIND = 7, + UNBIND = 8, + SETUP_COMPLETE = 9 + }; + + EventKind kind; + uint32_t sequence; // Protocol sequence (for all kinds) + char* authUserId; // Authenticated user ID (for all kinds) + char* authToken; // Authentication token if issued (for all kinds) + char* name; // Name of the method/sync query + // (METHOD_CALL, START_SYNC, END_SYNC, DECLARE_QUEUE, BIND, UNBIND) + Object* object; // Object involved in method call (METHOD_CALL) + ObjectId* objectId; // ObjectId for method call (METHOD_CALL) + Query* query; // Query parameters (GET_QUERY, START_SYNC) + Value* arguments; // Method parameters (METHOD_CALL) + char* exchange; // Exchange for bind (BIND, UNBIND) + char* bindingKey; // Key for bind (BIND, UNBIND) + const SchemaObjectClass* objectClass; // (METHOD_CALL) + }; + + class AgentImpl; + + /** + * Agent - Protocol engine for the QMF agent + */ + class Agent { + public: + Agent(char* label, bool internalStore=true); + ~Agent(); + + /** + * Configure the directory path for storing persistent data. + *@param path Null-terminated string containing a directory path where files can be + * created, written, and read. If NULL, no persistent storage will be + * attempted. + */ + void setStoreDir(const char* path); + + /** + * Configure the directory path for files transferred over QMF. + *@param path Null-terminated string containing a directory path where files can be + * created, deleted, written, and read. If NULL, file transfers shall not + * be permitted. + */ + void setTransferDir(const char* path); + + /** + * Pass messages received from the AMQP session to the Agent engine. + *@param message AMQP messages received on the agent session. + */ + void handleRcvMessage(Message& message); + + /** + * Get the next message to be sent to the AMQP network. + *@param item The Message structure describing the message to be produced. + *@return true if the Message is valid, false if there are no messages to send. + */ + bool getXmtMessage(Message& item) const; + + /** + * Remove and discard one message from the head of the transmit queue. + */ + void popXmt(); + + /** + * Get the next application event from the agent engine. + *@param event The event iff the return value is true + *@return true if event is valid, false if there are no events to process + */ + bool getEvent(AgentEvent& event) const; + + /** + * Remove and discard one event from the head of the event queue. + */ + void popEvent(); + + /** + * A new AMQP session has been established for Agent communication. + */ + void newSession(); + + /** + * Start the QMF Agent protocol. This should be invoked after a SETUP_COMPLETE event + * is received from the Agent engine. + */ + void startProtocol(); + + /** + * This method is called periodically so the agent can supply a heartbeat. + */ + void heartbeat(); + + /** + * Respond to a method request. + *@param sequence The sequence number from the method request event. + *@param status The method's completion status. + *@param text Status text ("OK" or an error message) + *@param arguments The list of output arguments from the method call. + */ + void methodResponse(uint32_t sequence, uint32_t status, char* text, const Value& arguments); + + /** + * Send a content indication to the QMF bus. This is only needed for objects that are + * managed by the application. This is *NOT* needed for objects managed by the Agent + * (inserted using addObject). + *@param sequence The sequence number of the GET request or the SYNC_START request. + *@param object The object (annotated with "changed" flags) for publication. + *@param prop If true, changed object properties are transmitted. + *@param stat If true, changed object statistics are transmitted. + */ + void queryResponse(uint32_t sequence, Object& object, bool prop = true, bool stat = true); + + /** + * Indicate the completion of a query. This is not used for SYNC_START requests. + *@param sequence The sequence number of the GET request. + */ + void queryComplete(uint32_t sequence); + + /** + * Register a schema class with the Agent. + *@param cls A SchemaObejctClass object that defines data managed by the agent. + */ + void registerClass(SchemaObjectClass* cls); + + /** + * Register a schema class with the Agent. + *@param cls A SchemaEventClass object that defines events sent by the agent. + */ + void registerClass(SchemaEventClass* cls); + + /** + * Give an object to the Agent for storage and management. Once added, the agent takes + * responsibility for the life cycle of the object. + *@param obj The object to be managed by the Agent. + *@param persistId A unique non-zero value if the object-id is to be persistent. + *@return The objectId of the managed object. + */ + const ObjectId* addObject(Object& obj, uint64_t persistId); + // const ObjectId* addObject(Object& obj, uint32_t persistIdLo, uint32_t persistIdHi); + + /** + * Allocate an object-id for an object that will be managed by the application. + *@param persistId A unique non-zero value if the object-id is to be persistent. + *@return The objectId structure for the allocated ID. + */ + const ObjectId* allocObjectId(uint64_t persistId); + const ObjectId* allocObjectId(uint32_t persistIdLo, uint32_t persistIdHi); + + /** + * Raise an event into the QMF network.. + *@param event The event object for the event to be raised. + */ + void raiseEvent(Event& event); + + private: + AgentImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/ConnectionSettings.h b/qpid/cpp/include/qmf/engine/ConnectionSettings.h new file mode 100644 index 0000000000..33f7c85a94 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/ConnectionSettings.h @@ -0,0 +1,148 @@ +#ifndef _QmfEngineConnectionSettings_ +#define _QmfEngineConnectionSettings_ + +/* + * 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/engine/QmfEngineImportExport.h" +#include "qpid/sys/IntegerTypes.h" + +namespace qmf { +namespace engine { + + class ConnectionSettingsImpl; + class Value; + + /** + * Settings for AMQP connections to the broker. + * + * \ingroup qmfapi + */ + class ConnectionSettings { + public: + + /** + * Create a set of default connection settings. + * + * If no further attributes are set, the settings will cause a connection to be made to + * the default broker (on localhost or at a host/port supplied by service discovery) and + * authentication will be the best-available (GSSAPI/Kerberos, Anonymous, Plain with prompts + * for username and password). + */ + QMFE_EXTERN ConnectionSettings(); + + /** + * Create a set of connection settings by URL. + * + * @param url Universal resource locator describing the broker address and additional attributes. + * + * The URL is of the form: + * amqp[s]://host[:port][?key=value[&key=value]*] + * + * For example: + * amqp://localhost + * amqp://broker?transport=rdma&authmech=GSSAPI&authservice=qpidd + * amqps://broker?authmech=PLAIN&authuser=guest&authpass=guest + */ + QMFE_EXTERN ConnectionSettings(const char* url); + + /** + * Copy Constructor. + */ + ConnectionSettings(const ConnectionSettings& from); + + /** + * Destroy the connection settings object. + */ + QMFE_EXTERN ~ConnectionSettings(); + + /** + * Set an attribute to control connection setup. + * + * @param key A null-terminated string that is an attribute name. + * + * @param value Reference to a value to be stored as the attribute. The type of the value + * is specific to the key. + */ + QMFE_EXTERN void setAttr(const char* key, const Value& value); + + /** + * Get the value of an attribute. + * + * @param key A null-terminated attribute name. + * + * @return The value associated with the attribute name. + */ + QMFE_EXTERN Value getAttr(const char* key) const; + + /** + * Get the attribute string (the portion of the URL following the '?') for the settings. + * + * @return A pointer to the attribute string. If the content of this string needs to be + * available beyond the scope of the calling function, it should be copied. The + * returned pointer may become invalid if the set of attributes is changed. + */ + QMFE_EXTERN const char* getAttrString() const; + + /** + * Shortcuts for setting the transport for the connection. + * + * @param port The port value for the connection address. + */ + QMFE_EXTERN void transportTcp(uint16_t port = 5672); + QMFE_EXTERN void transportSsl(uint16_t port = 5671); + QMFE_EXTERN void transportRdma(uint16_t port = 5672); + + /** + * Shortcuts for setting authentication mechanisms. + * + * @param username Null-terminated authentication user name. + * + * @param password Null-terminated authentication password. + * + * @param serviceName Null-terminated GSSAPI service name (Kerberos service principal) + * + * @param minSsf Minimum security factor for connections. 0 = encryption not required. + * + * @param maxSsf Maximum security factor for connections. 0 = encryption not permitted. + */ + QMFE_EXTERN void authAnonymous(const char* username = 0); + QMFE_EXTERN void authPlain(const char* username = 0, const char* password = 0); + QMFE_EXTERN void authGssapi(const char* serviceName, uint32_t minSsf = 0, uint32_t maxSsf = 256); + + /** + * Shortcut for setting connection retry attributes. + * + * @param delayMin Minimum delay (in seconds) between connection attempts. + * + * @param delaxMax Maximum delay (in seconds) between connection attempts. + * + * @param delayFactor Factor to multiply the delay by between failed connection attempts. + */ + QMFE_EXTERN void setRetry(int delayMin = 1, int delayMax = 128, int delayFactor = 2); + + private: + friend class ResilientConnectionImpl; + ConnectionSettingsImpl* impl; + }; + +} +} + +#endif diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h new file mode 100644 index 0000000000..49cf41f2bc --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -0,0 +1,228 @@ +#ifndef _QmfEngineConsole_ +#define _QmfEngineConsole_ + +/* + * 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 +#include +#include +#include +#include +#include +#include +#include + +namespace qmf { +namespace engine { + + class Console; + struct ConsoleImpl; + class BrokerProxyImpl; + class AgentProxy; + struct AgentProxyImpl; + struct MethodResponseImpl; + struct QueryResponseImpl; + struct QueryContext; + + /** + * + */ + class MethodResponse { + public: + MethodResponse(const MethodResponse& from); + ~MethodResponse(); + uint32_t getStatus() const; + const Value* getException() const; + const Value* getArgs() const; + + private: + friend struct MethodResponseImpl; + friend struct ConsoleImpl; + MethodResponse(MethodResponseImpl* impl); + MethodResponseImpl* impl; + }; + + /** + * + */ + class QueryResponse { + public: + ~QueryResponse(); + uint32_t getStatus() const; + const Value* getException() const; + uint32_t getObjectCount() const; + const Object* getObject(uint32_t idx) const; + + private: + friend struct QueryResponseImpl; + friend struct QueryContext; + QueryResponse(QueryResponseImpl* impl); + QueryResponseImpl *impl; + }; + + /** + * + */ + struct ConsoleEvent { + enum EventKind { + AGENT_ADDED = 1, + AGENT_DELETED = 2, + NEW_PACKAGE = 3, + NEW_CLASS = 4, + OBJECT_UPDATE = 5, + EVENT_RECEIVED = 7, + AGENT_HEARTBEAT = 8 + }; + + EventKind kind; + AgentProxy* agent; // (AGENT_[ADDED|DELETED|HEARTBEAT]) + char* name; // (NEW_PACKAGE) + SchemaClassKey* classKey; // (NEW_CLASS) + Object* object; // (OBJECT_UPDATE) + void* context; // (OBJECT_UPDATE) + Event* event; // (EVENT_RECEIVED) + uint64_t timestamp; // (AGENT_HEARTBEAT) + QueryResponse* queryResponse; // (QUERY_COMPLETE) + }; + + /** + * + */ + struct BrokerEvent { + enum EventKind { + BROKER_INFO = 10, + DECLARE_QUEUE = 11, + DELETE_QUEUE = 12, + BIND = 13, + UNBIND = 14, + SETUP_COMPLETE = 15, + STABLE = 16, + QUERY_COMPLETE = 17, + METHOD_RESPONSE = 18 + }; + + EventKind kind; + char* name; // ([DECLARE|DELETE]_QUEUE, [UN]BIND) + char* exchange; // ([UN]BIND) + char* bindingKey; // ([UN]BIND) + void* context; // (QUERY_COMPLETE, METHOD_RESPONSE) + QueryResponse* queryResponse; // (QUERY_COMPLETE) + MethodResponse* methodResponse; // (METHOD_RESPONSE) + }; + + /** + * + */ + class AgentProxy { + public: + ~AgentProxy(); + const char* getLabel() const; + + private: + friend struct AgentProxyImpl; + friend class BrokerProxyImpl; + AgentProxy(AgentProxyImpl* impl); + AgentProxyImpl* impl; + }; + + /** + * + */ + class BrokerProxy { + public: + BrokerProxy(Console& console); + ~BrokerProxy(); + + void sessionOpened(SessionHandle& sh); + void sessionClosed(); + void startProtocol(); + + void handleRcvMessage(Message& message); + bool getXmtMessage(Message& item) const; + void popXmt(); + + bool getEvent(BrokerEvent& event) const; + void popEvent(); + + uint32_t agentCount() const; + const AgentProxy* getAgent(uint32_t idx) const; + void sendQuery(const Query& query, void* context, const AgentProxy* agent = 0); + + private: + friend struct ConsoleImpl; + friend struct StaticContext; + BrokerProxyImpl* impl; + }; + + // TODO - move this to a public header + struct ConsoleSettings { + bool rcvObjects; + bool rcvEvents; + bool rcvHeartbeats; + bool userBindings; + + ConsoleSettings() : + rcvObjects(true), + rcvEvents(true), + rcvHeartbeats(true), + userBindings(false) {} + }; + + class Console { + public: + Console(const ConsoleSettings& settings = ConsoleSettings()); + ~Console(); + + bool getEvent(ConsoleEvent& event) const; + void popEvent(); + + void addConnection(BrokerProxy& broker, void* context); + void delConnection(BrokerProxy& broker); + + uint32_t packageCount() const; + const char* getPackageName(uint32_t idx) const; + + uint32_t classCount(const char* packageName) const; + const SchemaClassKey* getClass(const char* packageName, uint32_t idx) const; + + ClassKind getClassKind(const SchemaClassKey* key) const; + const SchemaObjectClass* getObjectClass(const SchemaClassKey* key) const; + const SchemaEventClass* getEventClass(const SchemaClassKey* key) const; + + void bindPackage(const char* packageName); + void bindClass(const SchemaClassKey* key); + void bindClass(const char* packageName, const char* className); + + /* + void startSync(const Query& query, void* context, SyncQuery& sync); + void touchSync(SyncQuery& sync); + void endSync(SyncQuery& sync); + */ + + private: + friend class BrokerProxyImpl; + friend struct AgentProxyImpl; + ConsoleImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/Event.h b/qpid/cpp/include/qmf/engine/Event.h new file mode 100644 index 0000000000..50ab5c1200 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Event.h @@ -0,0 +1,32 @@ +#ifndef _QmfEngineEvent_ +#define _QmfEngineEvent_ + +/* + * 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. + */ + +namespace qmf { +namespace engine { + + class Event { + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/Message.h b/qpid/cpp/include/qmf/engine/Message.h new file mode 100644 index 0000000000..1e95cc6afe --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Message.h @@ -0,0 +1,41 @@ +#ifndef _QmfEngineMessage_ +#define _QmfEngineMessage_ + +/* + * 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 "qpid/sys/IntegerTypes.h" + +namespace qmf { +namespace engine { + + struct Message { + char* body; + uint32_t length; + char* destination; + char* routingKey; + char* replyExchange; + char* replyKey; + char* userId; + }; + +} +} + +#endif diff --git a/qpid/cpp/include/qmf/engine/Object.h b/qpid/cpp/include/qmf/engine/Object.h new file mode 100644 index 0000000000..ad67cfdb95 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Object.h @@ -0,0 +1,56 @@ +#ifndef _QmfEngineObject_ +#define _QmfEngineObject_ + +/* + * 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 +#include +#include + +namespace qmf { +namespace engine { + + struct ObjectImpl; + class Object { + public: + Object(const SchemaObjectClass* type); + Object(const Object& from); + virtual ~Object(); + + void destroy(); + const ObjectId* getObjectId() const; + void setObjectId(ObjectId* oid); + const SchemaObjectClass* getClass() const; + Value* getValue(const char* key) const; + void invokeMethod(const char* methodName, const Value* inArgs, void* context) const; + bool isDeleted() const; + void merge(const Object& from); + + private: + friend struct ObjectImpl; + friend class AgentImpl; + Object(ObjectImpl* impl); + ObjectImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/ObjectId.h b/qpid/cpp/include/qmf/engine/ObjectId.h new file mode 100644 index 0000000000..a4b868b578 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/ObjectId.h @@ -0,0 +1,62 @@ +#ifndef _QmfEngineObjectId_ +#define _QmfEngineObjectId_ + +/* + * 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 + +namespace qmf { +namespace engine { + + // TODO: Add to/from string and << operator + + struct ObjectIdImpl; + class ObjectId { + public: + ObjectId(); + ObjectId(const ObjectId& from); + ~ObjectId(); + + uint64_t getObjectNum() const; + uint32_t getObjectNumHi() const; + uint32_t getObjectNumLo() const; + bool isDurable() const; + + bool operator==(const ObjectId& other) const; + bool operator<(const ObjectId& other) const; + bool operator>(const ObjectId& other) const; + bool operator<=(const ObjectId& other) const; + bool operator>=(const ObjectId& other) const; + + private: + friend struct ObjectIdImpl; + friend struct ObjectImpl; + friend class BrokerProxyImpl; + friend struct QueryImpl; + friend struct ValueImpl; + friend class AgentImpl; + ObjectId(ObjectIdImpl* impl); + ObjectIdImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h new file mode 100644 index 0000000000..70164c749f --- /dev/null +++ b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h @@ -0,0 +1,33 @@ +#ifndef QMF_ENGINE_IMPORT_EXPORT_H +#define QMF_ENGINE_IMPORT_EXPORT_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. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +# if defined(QMF_EXPORT) || defined (qmfcommon_EXPORTS) +# define QMFE_EXTERN __declspec(dllexport) +# else +# define QMFE_EXTERN __declspec(dllimport) +# endif +#else +# define QMFE_EXTERN +#endif + +#endif diff --git a/qpid/cpp/include/qmf/engine/Query.h b/qpid/cpp/include/qmf/engine/Query.h new file mode 100644 index 0000000000..1b11ea83f2 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Query.h @@ -0,0 +1,110 @@ +#ifndef _QmfEngineQuery_ +#define _QmfEngineQuery_ + +/* + * 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 +#include + +namespace qmf { +namespace engine { + + class Object; + struct QueryElementImpl; + struct QueryImpl; + struct QueryExpressionImpl; + class SchemaClassKey; + + enum ValueOper { + O_EQ = 1, + O_NE = 2, + O_LT = 3, + O_LE = 4, + O_GT = 5, + O_GE = 6, + O_RE_MATCH = 7, + O_RE_NOMATCH = 8 + }; + + struct QueryOperand { + virtual ~QueryOperand() {} + virtual bool evaluate(const Object* object) const = 0; + }; + + struct QueryElement : public QueryOperand { + QueryElement(const char* attrName, const Value* value, ValueOper oper); + QueryElement(QueryElementImpl* impl); + virtual ~QueryElement(); + bool evaluate(const Object* object) const; + + QueryElementImpl* impl; + }; + + enum ExprOper { + E_NOT = 1, + E_AND = 2, + E_OR = 3, + E_XOR = 4 + }; + + struct QueryExpression : public QueryOperand { + QueryExpression(ExprOper oper, const QueryOperand* operand1, const QueryOperand* operand2); + QueryExpression(QueryExpressionImpl* impl); + virtual ~QueryExpression(); + bool evaluate(const Object* object) const; + + QueryExpressionImpl* impl; + }; + + class Query { + public: + Query(const char* className, const char* packageName); + Query(const SchemaClassKey* key); + Query(const ObjectId* oid); + Query(const Query& from); + ~Query(); + + void setSelect(const QueryOperand* criterion); + void setLimit(uint32_t maxResults); + void setOrderBy(const char* attrName, bool decreasing); + + const char* getPackage() const; + const char* getClass() const; + const ObjectId* getObjectId() const; + + bool haveSelect() const; + bool haveLimit() const; + bool haveOrderBy() const; + const QueryOperand* getSelect() const; + uint32_t getLimit() const; + const char* getOrderBy() const; + bool getDecreasing() const; + + private: + friend struct QueryImpl; + friend class BrokerProxyImpl; + Query(QueryImpl* impl); + QueryImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/ResilientConnection.h b/qpid/cpp/include/qmf/engine/ResilientConnection.h new file mode 100644 index 0000000000..359c8ea6ff --- /dev/null +++ b/qpid/cpp/include/qmf/engine/ResilientConnection.h @@ -0,0 +1,165 @@ +#ifndef _QmfEngineResilientConnection_ +#define _QmfEngineResilientConnection_ + +/* + * 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 +#include +#include + +namespace qmf { +namespace engine { + + class ResilientConnectionImpl; + + /** + * Represents events that occur, unsolicited, from ResilientConnection. + */ + struct ResilientConnectionEvent { + enum EventKind { + CONNECTED = 1, + DISCONNECTED = 2, + SESSION_CLOSED = 3, + RECV = 4 + }; + + EventKind kind; + void* sessionContext; // SESSION_CLOSED, RECV + char* errorText; // DISCONNECTED, SESSION_CLOSED + Message message; // RECV + }; + + class SessionHandle { + friend class ResilientConnectionImpl; + void* impl; + }; + + /** + * ResilientConnection represents a Qpid connection that is resilient. + * + * Upon creation, ResilientConnection attempts to establish a connection to the + * messaging broker. If it fails, it will continue to retry at an interval that + * increases over time (to a maximum interval). If an extablished connection is + * dropped, a reconnect will be attempted. + */ + class ResilientConnection { + public: + + /** + * Create a new resilient connection. + *@param settings Settings that define how the connection is to be made. + *@param delayMin Minimum delay (in seconds) between retries. + *@param delayMax Maximum delay (in seconds) between retries. + *@param delayFactor Factor to multiply retry delay by after each failure. + */ + ResilientConnection(const ConnectionSettings& settings); + ~ResilientConnection(); + + /** + * Get the connected status of the resilient connection. + *@return true iff the connection is established. + */ + bool isConnected() const; + + /** + * Get the next event (if present) from the connection. + *@param event Returned event if one is available. + *@return true if event is valid, false if there are no more events to handle. + */ + bool getEvent(ResilientConnectionEvent& event); + + /** + * Discard the event on the front of the queue. This should be invoked after processing + * the event from getEvent. + */ + void popEvent(); + + /** + * Create a new AMQP session. + *@param name Unique name for the session. + *@param sessionContext Optional user-context value that will be provided in events + * pertaining to this session. + *@param handle Output handle to be stored and used in subsequent calls pertaining to + * this session. + *@return true iff the session was successfully created. + */ + bool createSession(const char* name, void* sessionContext, SessionHandle& handle); + + /** + * Destroy a created session. + *@param handle SessionHandle returned by createSession. + */ + void destroySession(SessionHandle handle); + + /** + * Send a message into the AMQP broker via a session. + *@param handle The session handle of the session to transmit through. + *@param message The QMF message to transmit. + */ + void sendMessage(SessionHandle handle, Message& message); + + /** + * Declare an exclusive, auto-delete queue for a session. + *@param handle The session handle for the owner of the queue. + *@param queue The name of the queue. + */ + void declareQueue(SessionHandle handle, char* queue); + + /** + * Delete a queue. + *@param handle The session handle for the owner of the queue. + *@param queue The name of the queue. + */ + void deleteQueue(SessionHandle handle, char* queue); + + /** + * Bind a queue to an exchange. + *@param handle The session handle of the session to use for binding. + *@param exchange The name of the exchange for binding. + *@param queue The name of the queue for binding. + *@param key The binding key. + */ + void bind(SessionHandle handle, char* exchange, char* queue, char* key); + + /** + * Remove a binding. + *@param handle The session handle of the session to use for un-binding. + *@param exchange The name of the exchange. + *@param queue The name of the queue. + *@param key The binding key. + */ + void unbind(SessionHandle handle, char* exchange, char* queue, char* key); + + /** + * Establish a file descriptor for event notification. + *@param fd A file descriptor into which the connection shall write a character each + * time an event is enqueued. This fd may be in a pair, the other fd of which + * is used in a select loop to control execution. + */ + void setNotifyFd(int fd); + + private: + ResilientConnectionImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/Schema.h b/qpid/cpp/include/qmf/engine/Schema.h new file mode 100644 index 0000000000..fceb29990d --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Schema.h @@ -0,0 +1,209 @@ +#ifndef _QmfEngineSchema_ +#define _QmfEngineSchema_ + +/* + * 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 +#include + +namespace qmf { +namespace engine { + + enum Access { ACCESS_READ_CREATE = 1, ACCESS_READ_WRITE = 2, ACCESS_READ_ONLY = 3 }; + enum Direction { DIR_IN = 1, DIR_OUT = 2, DIR_IN_OUT = 3 }; + enum ClassKind { CLASS_OBJECT = 1, CLASS_EVENT = 2 }; + + struct SchemaArgumentImpl; + struct SchemaMethodImpl; + struct SchemaPropertyImpl; + struct SchemaStatisticImpl; + struct SchemaObjectClassImpl; + struct SchemaEventClassImpl; + struct SchemaClassKeyImpl; + + /** + */ + class SchemaArgument { + public: + SchemaArgument(const char* name, Typecode typecode); + SchemaArgument(const SchemaArgument& from); + ~SchemaArgument(); + void setDirection(Direction dir); + void setUnit(const char* val); + void setDesc(const char* desc); + const char* getName() const; + Typecode getType() const; + Direction getDirection() const; + const char* getUnit() const; + const char* getDesc() const; + + private: + friend struct SchemaArgumentImpl; + friend struct SchemaMethodImpl; + friend struct SchemaEventClassImpl; + SchemaArgument(SchemaArgumentImpl* impl); + SchemaArgumentImpl* impl; + }; + + /** + */ + class SchemaMethod { + public: + SchemaMethod(const char* name); + SchemaMethod(const SchemaMethod& from); + ~SchemaMethod(); + void addArgument(const SchemaArgument* argument); + void setDesc(const char* desc); + const char* getName() const; + const char* getDesc() const; + int getArgumentCount() const; + const SchemaArgument* getArgument(int idx) const; + + private: + friend struct SchemaMethodImpl; + friend struct SchemaObjectClassImpl; + friend class AgentImpl; + SchemaMethod(SchemaMethodImpl* impl); + SchemaMethodImpl* impl; + }; + + /** + */ + class SchemaProperty { + public: + SchemaProperty(const char* name, Typecode typecode); + SchemaProperty(const SchemaProperty& from); + ~SchemaProperty(); + void setAccess(Access access); + void setIndex(bool val); + void setOptional(bool val); + void setUnit(const char* val); + void setDesc(const char* desc); + const char* getName() const; + Typecode getType() const; + Access getAccess() const; + bool isIndex() const; + bool isOptional() const; + const char* getUnit() const; + const char* getDesc() const; + + private: + friend struct SchemaPropertyImpl; + friend struct SchemaObjectClassImpl; + SchemaProperty(SchemaPropertyImpl* impl); + SchemaPropertyImpl* impl; + }; + + /** + */ + class SchemaStatistic { + public: + SchemaStatistic(const char* name, Typecode typecode); + SchemaStatistic(const SchemaStatistic& from); + ~SchemaStatistic(); + void setUnit(const char* val); + void setDesc(const char* desc); + const char* getName() const; + Typecode getType() const; + const char* getUnit() const; + const char* getDesc() const; + + private: + friend struct SchemaStatisticImpl; + friend struct SchemaObjectClassImpl; + SchemaStatistic(SchemaStatisticImpl* impl); + SchemaStatisticImpl* impl; + }; + + /** + */ + class SchemaClassKey { + public: + SchemaClassKey(const SchemaClassKey& from); + ~SchemaClassKey(); + + const char* getPackageName() const; + const char* getClassName() const; + const uint8_t* getHash() const; + + bool operator==(const SchemaClassKey& other) const; + bool operator<(const SchemaClassKey& other) const; + + private: + friend struct SchemaClassKeyImpl; + friend class BrokerProxyImpl; + friend struct ConsoleImpl; + SchemaClassKey(SchemaClassKeyImpl* impl); + SchemaClassKeyImpl* impl; + }; + + /** + */ + class SchemaObjectClass { + public: + SchemaObjectClass(const char* package, const char* name); + SchemaObjectClass(const SchemaObjectClass& from); + ~SchemaObjectClass(); + void addProperty(const SchemaProperty* property); + void addStatistic(const SchemaStatistic* statistic); + void addMethod(const SchemaMethod* method); + + const SchemaClassKey* getClassKey() const; + int getPropertyCount() const; + int getStatisticCount() const; + int getMethodCount() const; + const SchemaProperty* getProperty(int idx) const; + const SchemaStatistic* getStatistic(int idx) const; + const SchemaMethod* getMethod(int idx) const; + + private: + friend struct SchemaObjectClassImpl; + friend class BrokerProxyImpl; + friend class AgentImpl; + SchemaObjectClass(SchemaObjectClassImpl* impl); + SchemaObjectClassImpl* impl; + }; + + /** + */ + class SchemaEventClass { + public: + SchemaEventClass(const char* package, const char* name); + SchemaEventClass(const SchemaEventClass& from); + ~SchemaEventClass(); + void addArgument(const SchemaArgument* argument); + void setDesc(const char* desc); + + const SchemaClassKey* getClassKey() const; + int getArgumentCount() const; + const SchemaArgument* getArgument(int idx) const; + + private: + friend struct SchemaEventClassImpl; + friend class BrokerProxyImpl; + friend class AgentImpl; + SchemaEventClass(SchemaEventClassImpl* impl); + SchemaEventClassImpl* impl; + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/Typecode.h b/qpid/cpp/include/qmf/engine/Typecode.h new file mode 100644 index 0000000000..613f96a483 --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Typecode.h @@ -0,0 +1,53 @@ +#ifndef _QmfEngineTypecode_ +#define _QmfEngineTypecode_ + +/* + * 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. + */ + +namespace qmf { +namespace engine { + + enum Typecode { + TYPE_UINT8 = 1, + TYPE_UINT16 = 2, + TYPE_UINT32 = 3, + TYPE_UINT64 = 4, + TYPE_SSTR = 6, + TYPE_LSTR = 7, + TYPE_ABSTIME = 8, + TYPE_DELTATIME = 9, + TYPE_REF = 10, + TYPE_BOOL = 11, + TYPE_FLOAT = 12, + TYPE_DOUBLE = 13, + TYPE_UUID = 14, + TYPE_MAP = 15, + TYPE_INT8 = 16, + TYPE_INT16 = 17, + TYPE_INT32 = 18, + TYPE_INT64 = 19, + TYPE_OBJECT = 20, + TYPE_LIST = 21, + TYPE_ARRAY = 22 + }; +} +} + +#endif + diff --git a/qpid/cpp/include/qmf/engine/Value.h b/qpid/cpp/include/qmf/engine/Value.h new file mode 100644 index 0000000000..8eae382caf --- /dev/null +++ b/qpid/cpp/include/qmf/engine/Value.h @@ -0,0 +1,121 @@ +#ifndef _QmfEngineValue_ +#define _QmfEngineValue_ + +/* + * 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 +#include + +namespace qmf { +namespace engine { + + class Object; + struct ValueImpl; + + class Value { + public: + // Value(); + Value(const Value& from); + Value(Typecode t, Typecode arrayType = TYPE_UINT8); + ~Value(); + + Typecode getType() const; + bool isNull() const; + void setNull(); + + bool isObjectId() const; + const ObjectId& asObjectId() const; + void setObjectId(const ObjectId& oid); + + bool isUint() const; + uint32_t asUint() const; + void setUint(uint32_t val); + + bool isInt() const; + int32_t asInt() const; + void setInt(int32_t val); + + bool isUint64() const; + uint64_t asUint64() const; + void setUint64(uint64_t val); + + bool isInt64() const; + int64_t asInt64() const; + void setInt64(int64_t val); + + bool isString() const; + const char* asString() const; + void setString(const char* val); + + bool isBool() const; + bool asBool() const; + void setBool(bool val); + + bool isFloat() const; + float asFloat() const; + void setFloat(float val); + + bool isDouble() const; + double asDouble() const; + void setDouble(double val); + + bool isUuid() const; + const uint8_t* asUuid() const; + void setUuid(const uint8_t* val); + + bool isObject() const; + const Object* asObject() const; + void setObject(Object* val); + + bool isMap() const; + bool keyInMap(const char* key) const; + Value* byKey(const char* key); + const Value* byKey(const char* key) const; + void deleteKey(const char* key); + void insert(const char* key, Value* val); + uint32_t keyCount() const; + const char* key(uint32_t idx) const; + + bool isList() const; + uint32_t listItemCount() const; + Value* listItem(uint32_t idx); + void appendToList(Value* val); + void deleteListItem(uint32_t idx); + + bool isArray() const; + Typecode arrayType() const; + uint32_t arrayItemCount() const; + Value* arrayItem(uint32_t idx); + void appendToArray(Value* val); + void deleteArrayItem(uint32_t idx); + + private: + friend struct ValueImpl; + friend class BrokerProxyImpl; + friend struct ObjectImpl; + friend class AgentImpl; + Value(ValueImpl* impl); + ValueImpl* impl; + }; +} +} + +#endif + -- cgit v1.2.1 From 70cf28cc70064a4f693cd8549aa12a698bcee967 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Sun, 27 Sep 2009 19:13:59 +0000 Subject: Adding missing file git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@819381 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/ConnectionSettings.h | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 qpid/cpp/include/qmf/ConnectionSettings.h (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h new file mode 100644 index 0000000000..11af73d797 --- /dev/null +++ b/qpid/cpp/include/qmf/ConnectionSettings.h @@ -0,0 +1,32 @@ +#ifndef _QmfConnectionSettings_ +#define _QmfConnectionSettings_ + +/* + * 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. + */ + +namespace qmf { + namespace engine { + class ConnectionSettings; + } + + typedef class engine::ConnectionSettings ConnectionSettings; +} + +#endif + -- cgit v1.2.1 From 74fecbf7759d549824bf92266c51a3d5180b6b33 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 29 Sep 2009 03:21:49 +0000 Subject: QMF Engine updates: - Connected console handler callbacks - Added string representations for a number of object classes - Added a feature that completes query requests sent to disconnected agents git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@819819 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Console.h | 7 ++++++- qpid/cpp/include/qmf/engine/ObjectId.h | 1 + qpid/cpp/include/qmf/engine/Schema.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h index 49cf41f2bc..f53f351760 100644 --- a/qpid/cpp/include/qmf/engine/Console.h +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -94,12 +94,14 @@ namespace engine { EventKind kind; AgentProxy* agent; // (AGENT_[ADDED|DELETED|HEARTBEAT]) char* name; // (NEW_PACKAGE) - SchemaClassKey* classKey; // (NEW_CLASS) + const SchemaClassKey* classKey; // (NEW_CLASS) Object* object; // (OBJECT_UPDATE) void* context; // (OBJECT_UPDATE) Event* event; // (EVENT_RECEIVED) uint64_t timestamp; // (AGENT_HEARTBEAT) QueryResponse* queryResponse; // (QUERY_COMPLETE) + bool hasProps; + bool hasStats; }; /** @@ -136,6 +138,8 @@ namespace engine { const char* getLabel() const; private: + friend struct StaticContext; + friend struct QueryContext; friend struct AgentProxyImpl; friend class BrokerProxyImpl; AgentProxy(AgentProxyImpl* impl); @@ -219,6 +223,7 @@ namespace engine { private: friend class BrokerProxyImpl; friend struct AgentProxyImpl; + friend struct StaticContext; ConsoleImpl* impl; }; } diff --git a/qpid/cpp/include/qmf/engine/ObjectId.h b/qpid/cpp/include/qmf/engine/ObjectId.h index a4b868b578..b71473a799 100644 --- a/qpid/cpp/include/qmf/engine/ObjectId.h +++ b/qpid/cpp/include/qmf/engine/ObjectId.h @@ -38,6 +38,7 @@ namespace engine { uint32_t getObjectNumHi() const; uint32_t getObjectNumLo() const; bool isDurable() const; + const char* str() const; bool operator==(const ObjectId& other) const; bool operator<(const ObjectId& other) const; diff --git a/qpid/cpp/include/qmf/engine/Schema.h b/qpid/cpp/include/qmf/engine/Schema.h index fceb29990d..16f11a83f9 100644 --- a/qpid/cpp/include/qmf/engine/Schema.h +++ b/qpid/cpp/include/qmf/engine/Schema.h @@ -142,6 +142,7 @@ namespace engine { const char* getPackageName() const; const char* getClassName() const; const uint8_t* getHash() const; + const char* asString() const; bool operator==(const SchemaClassKey& other) const; bool operator<(const SchemaClassKey& other) const; -- cgit v1.2.1 From 0f7c02dae11afed532bf60302cf2185f422fd23c Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 2 Oct 2009 17:45:58 +0000 Subject: QMF Fixes: - In ruby: waitForStable => wait_for_stable - Setting an unknown attribute on connection settings now throws an exception - Added connected? accessor to Connection git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@821109 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/ConnectionSettings.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/ConnectionSettings.h b/qpid/cpp/include/qmf/engine/ConnectionSettings.h index 33f7c85a94..36312400b1 100644 --- a/qpid/cpp/include/qmf/engine/ConnectionSettings.h +++ b/qpid/cpp/include/qmf/engine/ConnectionSettings.h @@ -79,8 +79,10 @@ namespace engine { * * @param value Reference to a value to be stored as the attribute. The type of the value * is specific to the key. + * + * @return True if success, False if invalid attribute */ - QMFE_EXTERN void setAttr(const char* key, const Value& value); + QMFE_EXTERN bool setAttr(const char* key, const Value& value); /** * Get the value of an attribute. -- cgit v1.2.1 From 2df0b393db42d098f590f6b00fb96b0c15b1f6f9 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 2 Oct 2009 21:43:22 +0000 Subject: QMF Fixes in Ruby Console: - AgentProxy object now has broker_bank and agent_bank accessors - Fixed a bug in the returning og reference values (ObjectId) - Added package_name accessor to SchemaObjectClass - Added accessors for agent/broker bank to ObjectId git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@821181 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Console.h | 2 ++ qpid/cpp/include/qmf/engine/ObjectId.h | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h index f53f351760..ce72360da7 100644 --- a/qpid/cpp/include/qmf/engine/Console.h +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -136,6 +136,8 @@ namespace engine { public: ~AgentProxy(); const char* getLabel() const; + uint32_t getBrokerBank() const; + uint32_t getAgentBank() const; private: friend struct StaticContext; diff --git a/qpid/cpp/include/qmf/engine/ObjectId.h b/qpid/cpp/include/qmf/engine/ObjectId.h index b71473a799..2055972c00 100644 --- a/qpid/cpp/include/qmf/engine/ObjectId.h +++ b/qpid/cpp/include/qmf/engine/ObjectId.h @@ -39,6 +39,10 @@ namespace engine { uint32_t getObjectNumLo() const; bool isDurable() const; const char* str() const; + uint8_t getFlags() const; + uint16_t getSequence() const; + uint32_t getBrokerBank() const; + uint32_t getAgentBank() const; bool operator==(const ObjectId& other) const; bool operator<(const ObjectId& other) const; -- cgit v1.2.1 From 98b1f8a8787b6b0f6b5f269a1b62364abf7b7068 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 22 Oct 2009 13:51:14 +0000 Subject: Added operators for present/not-present in the object (i.e. for optional properties). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@828694 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Query.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/Query.h b/qpid/cpp/include/qmf/engine/Query.h index 1b11ea83f2..3ed08c5d8e 100644 --- a/qpid/cpp/include/qmf/engine/Query.h +++ b/qpid/cpp/include/qmf/engine/Query.h @@ -40,7 +40,9 @@ namespace engine { O_GT = 5, O_GE = 6, O_RE_MATCH = 7, - O_RE_NOMATCH = 8 + O_RE_NOMATCH = 8, + O_PRESENT = 9, + O_NOT_PRESENT = 10 }; struct QueryOperand { -- cgit v1.2.1 From 0207a7cd0c71cec7f488c8c326ce05825073a57a Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 23 Oct 2009 18:31:10 +0000 Subject: Removed references to broker and agent bank from API, replaced with the more generic (and forward compatible) "key". In the Ruby binding, ensured that ruby objects reference their own copies of the wrapped c++ objects to protect from problems when the c++ objects are deleted out from under the wrappers. Added agent discriminator to the console::objects method. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@829167 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Console.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h index ce72360da7..8463023468 100644 --- a/qpid/cpp/include/qmf/engine/Console.h +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -134,6 +134,7 @@ namespace engine { */ class AgentProxy { public: + AgentProxy(const AgentProxy& from); ~AgentProxy(); const char* getLabel() const; uint32_t getBrokerBank() const; -- cgit v1.2.1 From ced68fb0d3acea6919f417444f8d00401c080b55 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Fri, 30 Oct 2009 22:50:51 +0000 Subject: Correct the macro used to detect DLL building to match the new target name changed in CMakeLists.txt a while back. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@831482 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/QmfEngineImportExport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h index 70164c749f..373617e046 100644 --- a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h +++ b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h @@ -21,7 +21,7 @@ */ #if defined(WIN32) && !defined(QPID_DECLARE_STATIC) -# if defined(QMF_EXPORT) || defined (qmfcommon_EXPORTS) +# if defined(QMF_EXPORT) || defined (qmfengine_EXPORTS) # define QMFE_EXTERN __declspec(dllexport) # else # define QMFE_EXTERN __declspec(dllimport) -- cgit v1.2.1 From 2f97b506e14dc6935a37e9356d4f57563518fe83 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Fri, 30 Oct 2009 22:51:17 +0000 Subject: Refer to struct/class consistently across files. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@831483 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Console.h | 6 +++--- qpid/cpp/include/qmf/engine/Schema.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h index 8463023468..03b3993395 100644 --- a/qpid/cpp/include/qmf/engine/Console.h +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -33,7 +33,7 @@ namespace qmf { namespace engine { class Console; - struct ConsoleImpl; + class ConsoleImpl; class BrokerProxyImpl; class AgentProxy; struct AgentProxyImpl; @@ -54,7 +54,7 @@ namespace engine { private: friend struct MethodResponseImpl; - friend struct ConsoleImpl; + friend class ConsoleImpl; MethodResponse(MethodResponseImpl* impl); MethodResponseImpl* impl; }; @@ -173,7 +173,7 @@ namespace engine { void sendQuery(const Query& query, void* context, const AgentProxy* agent = 0); private: - friend struct ConsoleImpl; + friend class ConsoleImpl; friend struct StaticContext; BrokerProxyImpl* impl; }; diff --git a/qpid/cpp/include/qmf/engine/Schema.h b/qpid/cpp/include/qmf/engine/Schema.h index 16f11a83f9..9f5b444558 100644 --- a/qpid/cpp/include/qmf/engine/Schema.h +++ b/qpid/cpp/include/qmf/engine/Schema.h @@ -150,7 +150,7 @@ namespace engine { private: friend struct SchemaClassKeyImpl; friend class BrokerProxyImpl; - friend struct ConsoleImpl; + friend class ConsoleImpl; SchemaClassKey(SchemaClassKeyImpl* impl); SchemaClassKeyImpl* impl; }; -- cgit v1.2.1 From fd64f22be60f12e03df8974b547cd9b3af331601 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 13 Jan 2010 11:57:19 +0000 Subject: Added raise_event support to the Ruby and Python wrapped agent APIs. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@898727 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Event.h | 17 +++++++++++++++++ qpid/cpp/include/qmf/engine/Schema.h | 4 +++- qpid/cpp/include/qmf/engine/Value.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/Event.h b/qpid/cpp/include/qmf/engine/Event.h index 50ab5c1200..4e5200a0a8 100644 --- a/qpid/cpp/include/qmf/engine/Event.h +++ b/qpid/cpp/include/qmf/engine/Event.h @@ -23,7 +23,24 @@ namespace qmf { namespace engine { + class SchemaEventClass; + class Value; + struct EventImpl; + class Event { + public: + Event(const SchemaEventClass* type); + Event(const Event& from); + ~Event(); + + const SchemaEventClass* getClass() const; + Value* getValue(const char* key) const; + + private: + friend struct EventImpl; + friend struct AgentImpl; + Event(EventImpl* impl); + EventImpl* impl; }; } } diff --git a/qpid/cpp/include/qmf/engine/Schema.h b/qpid/cpp/include/qmf/engine/Schema.h index 9f5b444558..f53e84324a 100644 --- a/qpid/cpp/include/qmf/engine/Schema.h +++ b/qpid/cpp/include/qmf/engine/Schema.h @@ -29,6 +29,7 @@ namespace engine { enum Access { ACCESS_READ_CREATE = 1, ACCESS_READ_WRITE = 2, ACCESS_READ_ONLY = 3 }; enum Direction { DIR_IN = 1, DIR_OUT = 2, DIR_IN_OUT = 3 }; enum ClassKind { CLASS_OBJECT = 1, CLASS_EVENT = 2 }; + enum Severity { SEV_EMERG = 0, SEV_ALERT = 1, SEV_CRIT = 2, SEV_ERROR = 3, SEV_WARN = 4, SEV_NOTICE = 5, SEV_INFORM = 6, SEV_DEBUG = 7 }; struct SchemaArgumentImpl; struct SchemaMethodImpl; @@ -186,13 +187,14 @@ namespace engine { */ class SchemaEventClass { public: - SchemaEventClass(const char* package, const char* name); + SchemaEventClass(const char* package, const char* name, Severity severity); SchemaEventClass(const SchemaEventClass& from); ~SchemaEventClass(); void addArgument(const SchemaArgument* argument); void setDesc(const char* desc); const SchemaClassKey* getClassKey() const; + Severity getSeverity() const; int getArgumentCount() const; const SchemaArgument* getArgument(int idx) const; diff --git a/qpid/cpp/include/qmf/engine/Value.h b/qpid/cpp/include/qmf/engine/Value.h index 8eae382caf..5b45061b78 100644 --- a/qpid/cpp/include/qmf/engine/Value.h +++ b/qpid/cpp/include/qmf/engine/Value.h @@ -110,6 +110,7 @@ namespace engine { friend struct ValueImpl; friend class BrokerProxyImpl; friend struct ObjectImpl; + friend struct EventImpl; friend class AgentImpl; Value(ValueImpl* impl); ValueImpl* impl; -- cgit v1.2.1 From 640f833fecec770d75eae4392ef4dd56df109ea3 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 21 Jan 2010 18:24:04 +0000 Subject: Fixes to make Win32 port build again (and remove some warnings) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@901816 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/Event.h b/qpid/cpp/include/qmf/engine/Event.h index 4e5200a0a8..647b88dbf8 100644 --- a/qpid/cpp/include/qmf/engine/Event.h +++ b/qpid/cpp/include/qmf/engine/Event.h @@ -38,7 +38,7 @@ namespace engine { private: friend struct EventImpl; - friend struct AgentImpl; + friend class AgentImpl; Event(EventImpl* impl); EventImpl* impl; }; -- cgit v1.2.1 From 9523fa332a8fd0f713c3c12c941b061316597d84 Mon Sep 17 00:00:00 2001 From: Kenneth Anthony Giusti Date: Mon, 8 Feb 2010 21:33:54 +0000 Subject: QPID-2396: add assignment operator to ObjectId class. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@907808 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/ObjectId.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/ObjectId.h b/qpid/cpp/include/qmf/engine/ObjectId.h index 2055972c00..51eb2bc9e7 100644 --- a/qpid/cpp/include/qmf/engine/ObjectId.h +++ b/qpid/cpp/include/qmf/engine/ObjectId.h @@ -49,6 +49,7 @@ namespace engine { bool operator>(const ObjectId& other) const; bool operator<=(const ObjectId& other) const; bool operator>=(const ObjectId& other) const; + ObjectId& operator=(const ObjectId &other); private: friend struct ObjectIdImpl; -- cgit v1.2.1 From 6febb06e1476898cd18d59cc0edf212af3d1efb8 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 12 Feb 2010 18:23:47 +0000 Subject: QPID-2328 - Applied patch from Ian Main git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@909548 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/ResilientConnection.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/ResilientConnection.h b/qpid/cpp/include/qmf/engine/ResilientConnection.h index 359c8ea6ff..c03d08cb96 100644 --- a/qpid/cpp/include/qmf/engine/ResilientConnection.h +++ b/qpid/cpp/include/qmf/engine/ResilientConnection.h @@ -155,6 +155,14 @@ namespace engine { */ void setNotifyFd(int fd); + /** + * Send a byte into the notify file descriptor. + * + * This can be used to wake up the event processing portion of the engine from either the + * wrapped implementation or the engine itself. + */ + void notify(); + private: ResilientConnectionImpl* impl; }; -- cgit v1.2.1 From 5afdc67935d07852c7c166741401ec4a77604d9b Mon Sep 17 00:00:00 2001 From: Kenneth Anthony Giusti Date: Fri, 21 May 2010 17:39:51 +0000 Subject: QMF: add bindEvent api to allow filtering of unsolicted events. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@947084 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/engine/Console.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/engine/Console.h b/qpid/cpp/include/qmf/engine/Console.h index 03b3993395..bd40c63c6c 100644 --- a/qpid/cpp/include/qmf/engine/Console.h +++ b/qpid/cpp/include/qmf/engine/Console.h @@ -217,6 +217,9 @@ namespace engine { void bindClass(const SchemaClassKey* key); void bindClass(const char* packageName, const char* className); + void bindEvent(const SchemaClassKey *key); + void bindEvent(const char* packageName, const char* eventName); + /* void startSync(const Query& query, void* context, SyncQuery& sync); void touchSync(SyncQuery& sync); -- cgit v1.2.1 From 642860379c66cb08dcca723da10e2749ac44e3b8 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 27 Jul 2010 20:33:42 +0000 Subject: Removed unused header files. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@979857 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 287 ------------------------------ qpid/cpp/include/qmf/AgentObject.h | 95 ---------- qpid/cpp/include/qmf/Connection.h | 125 ------------- qpid/cpp/include/qmf/ConnectionSettings.h | 32 ---- qpid/cpp/include/qmf/ConsoleObject.h | 94 ---------- qpid/cpp/include/qmf/QmfImportExport.h | 33 ---- 6 files changed, 666 deletions(-) delete mode 100644 qpid/cpp/include/qmf/Agent.h delete mode 100644 qpid/cpp/include/qmf/AgentObject.h delete mode 100644 qpid/cpp/include/qmf/Connection.h delete mode 100644 qpid/cpp/include/qmf/ConnectionSettings.h delete mode 100644 qpid/cpp/include/qmf/ConsoleObject.h delete mode 100644 qpid/cpp/include/qmf/QmfImportExport.h (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h deleted file mode 100644 index e61cd737d0..0000000000 --- a/qpid/cpp/include/qmf/Agent.h +++ /dev/null @@ -1,287 +0,0 @@ -#ifndef _QmfAgent_ -#define _QmfAgent_ - -/* - * 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/QmfImportExport.h" - -namespace qmf { - - class AgentImpl; - class Connection; - class ObjectId; - class AgentObject; - class Value; - class Event; - class SchemaObjectClass; - - /** - * AgentListener is used by agents that select the internalStore=false option (see Agent - * constructor) or by agents that wish to provide access control for queries and methods. - * - * \ingroup qmfapi - */ - class AgentListener { - QMF_EXTERN virtual ~AgentListener(); - - /** - * allowQuery is called before a query operation is executed. If true is returned - * by this function, the query will proceed. If false is returned, the query will - * be forbidden. - * - * @param q The query being requested. - * @param userId The authenticated identity of the user requesting the query. - */ - virtual bool allowQuery(const Query& q, const char* userId); - - /** - * allowMethod is called before a method call is executed. If true is returned - * by this function, the method call will proceed. If false is returned, the method - * call will be forbidden. - * - * @param name The name of the method being called. - * @param args A value object (of type "map") that contains both input and output arguments. - * @param oid The objectId that identifies the instance of the object being called. - * @param cls The Schema describing the object being called. - * @param userId The authenticated identity of the requesting user. - */ - virtual bool allowMethod(const char* name, const Value& args, const ObjectId& oid, - const SchemaObjectClass& cls, const char* userId); - - /** - * query is called when the agent receives a query request. The handler must invoke - * Agent::queryResponse zero or more times (using the supplied context) followed by - * a single invocation of Agent::queryComplete. These calls do not need to be made - * synchronously in the context of this function. They may occur before or after this - * function returns. - * - * This function will only be invoked if internalStore=false in the Agent's constructor. - * - * @param context A context value to use in resulting calls to queryResponse and quertComplete. - * @param q The query requested by the console. - * @param userId the authenticated identity of the user requesting the query. - */ - virtual void query(uint32_t context, const Query& q, const char* userId); - - /** - * syncStart is called when a console requests a standing query. This function must - * behave exactly like AgentListener::query (i.e. send zero or more responses followed - * by a queryComplete) except it then remembers the context and the query and makes - * subsequent queryResponse calls whenever appropriate according the the query. - * - * The standing query shall stay in effect until syncStop is called with the same context - * value or until a specified period of time elapses without receiving a syncTouch for the - * context. - * - * This function will only be invoked if internalStore=false in the Agent's constructor. - * - * @param context A context value to use in resulting calls to queryResponse and queryComplete. - * @param q The query requested by the console. - * @param userId the authenticated identity of the user requesting the query. - */ - virtual void syncStart(uint32_t context, const Query& q, const char* userId); - - /** - * syncTouch is called when the console that requested a standing query refreshes its - * interest in the query. The console must periodically "touch" a standing query to keep - * it alive. This prevents standing queries from accumulating when the console disconnects - * before it can stop the query. - * - * This function will only be invoked if internalStore=false in the Agent's constructor. - * - * @param context The context supplied in a previous call to syncStart. - * @param userId The authenticated identity of the requesting user. - */ - virtual void syncTouch(uint32_t context, const char* userId); - - /** - * syncStop is called when the console that requested a standing query no longer wishes to - * receive data associated with that query. The application shall stop processing this - * query and shall remove its record of the context value. - * - * This function will only be invoked if internalStore=false in the Agent's constructor. - * - * @param context The context supplied in a previous call to syncStart. - * @param userId The authenticated identity of the requesting user. - */ - virtual void syncStop(uint32_t context, const char* userId); - - /** - * methodCall is called when a console invokes a method on a QMF object. The application - * must call Agent::methodResponse once in response to this function. The response does - * not need to be called synchronously in the context of this function. It may be called - * before or after this function returns. - * - * This function will only be invoked if internalStore=false in the Agent's constructor. - * - * @param context A context value to use in resulting call to methodResponse. - * @param name The name of the method being called. - * @param args A value object (of type "map") that contains both input and output arguments. - * @param oid The objectId that identifies the instance of the object being called. - * @param cls The Schema describing the object being called. - * @param userId The authenticated identity of the requesting user. - */ - virtual void methodCall(uint32_t context, const char* name, Value& args, - const ObjectId& oid, const SchemaObjectClass& cls, const char* userId); - }; - - /** - * The Agent class is the QMF Agent portal. It should be instantiated once and associated with a - * Connection (setConnection) to connect an agent to the QMF infrastructure. - * - * \ingroup qmfapi - */ - class Agent { - public: - /** - * Create an instance of the Agent class. - * - * @param label An optional string label that can be used to identify the agent. - * - * @param internalStore If true, objects shall be tracked internally by the agent. - * If false, the user of the agent must track the objects. - * If the agent is tracking the objects, queries and syncs are handled by - * the agent. The only involvement the user has is to optionally authorize - * individual operations. If the user is tracking the objects, the user code - * must implement queries and syncs (standing queries). - * - * @param listener A pointer to a class that implements the AgentListener interface. - * This must be supplied if any of the following conditions are true: - * - The agent model contains methods - * - The user wishes to individually authorize query and sync operations. - * - internalStore = false - */ - QMF_EXTERN Agent(char* label="qmfa", bool internalStore=true, AgentListener* listener=0); - - /** - * Destroy an instance of the Agent class. - */ - QMF_EXTERN ~Agent(); - - /** - * Set the persistent store file. This file, if specified, is used to store state information - * about the Agent. For example, if object-ids must be persistent across restarts of the Agent - * program, this file path must be supplied. - * - * @param path Full path to a file that is both writable and readable by the Agent program. - */ - QMF_EXTERN void setStoreDir(const char* path); - - /** - * Provide a connection (to a Qpid broker) over which the agent can communicate. - * - * @param conn Pointer to a Connection object. - */ - QMF_EXTERN void setConnection(Connection* conn); - - /** - * Register a class schema (object or event) with the agent. The agent must have a registered - * schema for an object class or an event class before it can handle objects or events of that - * class. - * - * @param cls Pointer to the schema structure describing the class. - */ - QMF_EXTERN void registerClass(SchemaObjectClass* cls); - QMF_EXTERN void registerClass(SchemaEventClass* cls); - - /** - * Add an object to the agent (for internal storage mode only). - * - * @param obj Reference to the object to be managed by the agent. - * - * @param persistent Iff true, the object ID assigned to the object shall indicate persistence - * (i.e. the object ID shall be the same across restarts of the agent program). - * - * @param oid 64-bit value for the oid (if zero, the agent will assign the value). - * - * @param oidLo 32-bit value for the lower 32-bits of the oid. - * - * @param oidHi 32-bit value for the upper 32-bits of the oid. - */ - QMF_EXTERN const ObjectId* addObject(AgentObject& obj, bool persistent=false, uint64_t oid=0); - QMF_EXTERN const ObjectId* addObject(AgentObject& obj, bool persistent, uint32_t oidLo, uint32_t oidHi); - - /** - * Allocate an object ID for an object (for external storage mode only). - * - * @param persistent Iff true, the object ID allocated shall indicate persistence - * (i.e. the object ID shall be the same across restarts of the agent program). - * - * @param oid 64-bit value for the oid (if zero, the agent will assign the value). - * - * @param oidLo 32-bit value for the lower 32-bits of the oid. - * - * @param oidHi 32-bit value for the upper 32-bits of the oid. - */ - QMF_EXTERN const ObjectId* allocObjectId(bool persistent=false, uint64_t oid=0); - QMF_EXTERN const ObjectId* allocObjectId(bool persistent, uint32_t oidLo, uint32_t oidHi); - - /** - * Raise a QMF event. - * - * @param event Reference to an event object to be raised to the QMF infrastructure. - */ - QMF_EXTERN void raiseEvent(Event& event); - - /** - * Provide a response to a query (for external storage mode only). - * - * @param context The context value supplied in the query (via the AgentListener interface). - * - * @param object A reference to the agent that matched the query criteria. - * - * @param prop If true, transmit the property attributes of this object. - * - * @param stat If true, transmit the statistic attributes of this object. - */ - QMF_EXTERN void queryResponse(uint32_t context, AgentObject& object, bool prop = true, bool stat = true); - - /** - * Indicate that a query (or the initial dump of a sync) is complete (for external storage mode only). - * - * @param context The context value supplied in the query/sync (via the AgentListener interface). - */ - QMF_EXTERN void queryComplete(uint32_t context); - - /** - * Provide the response to a method call. - * - * @param context The context value supplied in the method request (via the AgentListener interface). - * - * @param args The argument list from the method call. Must include the output arguments (may include - * the input arguments). - * - * @param status Numerical return status: zero indicates no error, non-zero indicates error. - * - * @param exception Pointer to an exception value. If status is non-zero, the exception value is - * sent to the caller. It is optional (i.e. leave the pointer as 0), or may be - * set to any legal value. A string may be supplied, but an unmanaged object of - * any schema may also be passed. - */ - QMF_EXTERN void methodResponse(uint32_t context, const Value& args, uint32_t status=0, - const Value* exception=0); - - private: - AgentImpl* impl; - }; - -} - -#endif diff --git a/qpid/cpp/include/qmf/AgentObject.h b/qpid/cpp/include/qmf/AgentObject.h deleted file mode 100644 index a1878605eb..0000000000 --- a/qpid/cpp/include/qmf/AgentObject.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef _QmfAgentObject_ -#define _QmfAgentObject_ - -/* - * 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/QmfImportExport.h" - -namespace qmf { - - class AgentObjectImpl; - class SchemaObjectClass; - class ObjectId; - class Value; - class Agent; - - /** - * AgentObject is an extension of Object with agent-specific methods added. - * - * \ingroup qmfapi - */ - class AgentObject : public Object { - public: - /** - * Create a new Object of a specific type. - * - * @param type Pointer to the schema class to use as a type for this object. - */ - QMF_EXTERN AgentObject(const SchemaObjectClass* type); - - /** - * Schedule this object for deletion. Agent objects should never be directly - * destroyed, rather this method should be called and all pointers to this - * object dropped. The agent will clean up and properly delete the object at - * the appropraite time. - */ - QMF_EXTERN void destroy(); - - /** - * Set the object ID for this object if it is to be managed by the agent. - * - * @param oid The new object ID for the managed object. - */ - QMF_EXTERN void setObjectId(ObjectId& oid); - - /** - * Handler for invoked method calls. This will only be called for objects that - * are being managed and stored by an agent (see internalStore argument in Agent::Agent). - * If this function is not overridden in a child class, the default implementation will - * cause AgentListener::methodCall to be invoked in the application program. - * - * If this function is overridden in a sub-class, the implementation must perform - * the actions associated with the method call (i.e. implement the method). Once the - * method execution is complete, it must call Agent::methodResponse with the result - * of the method execution. Agent::methodResponse does not need to be called - * synchronously in the context of this function call. It may be called at a later - * time from a different thread. - * - * @param context Context supplied by the agent and required to be passed in the - * call to Agent::methodResponse - * - * @param name The name of the method. - * - * @param args A Value (of type map) that contains the input and output arguments. - * - * @param userId The authenticated identity of the user who invoked the method. - */ - QMF_EXTERN virtual void methodInvoked(uint32_t context, const char* name, Value& args, - const char* userId); - private: - friend class Agent; - virtual ~AgentObject(); - void setAgent(Agent* agent); - AgentObjectImpl* impl; - }; - -} - -#endif diff --git a/qpid/cpp/include/qmf/Connection.h b/qpid/cpp/include/qmf/Connection.h deleted file mode 100644 index f648b1427f..0000000000 --- a/qpid/cpp/include/qmf/Connection.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef _QmfConnection_ -#define _QmfConnection_ - -/* - * 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/QmfImportExport.h" -#include "qmf/ConnectionSettings.h" - -namespace qmf { - - /** - * Operational states for Connections. - * - * \ingroup qmfapi - */ - enum ConnectionState { - CONNECTION_UP = 1, - CONNECTION_DOWN = 2 - }; - - /** - * Implement a subclass of ConnectionListener and provide it with the - * Connection constructor to receive notification of changes in the - * connection state. - * - * \ingroup qmfapi - */ - class ConnectionListener { - QMF_EXTERN virtual ~ConnectionListener(); - - /** - * Called each time the state of the connection changes. - * - * @param state the new state - */ - virtual void newState(ConnectionState state); - - /** - * Called if the connection requires input from an interactive client. - * - * @param prompt Text of the prompt - describes what information is required. - * @param answer The interactive user input. - * @param answerLen on Input - the maximum number of bytes that can be copied to answer. - * on Output - the number of bytes copied to answer. - */ - virtual void interactivePrompt(const char* prompt, char* answer, uint32_t answerLen); - }; - - class ConnectionImpl; - - /** - * The Connection class represents a connection to a QPID broker that can - * be used by agents and consoles, possibly multiple at the same time. - * - * \ingroup qmfapi - */ - class Connection { - public: - - /** - * Creates a connection object and begins the process of attempting to - * connect to the QPID broker. - * - * @param settings The settings that control how the connection is set - * up. - * - * @param listener An optional pointer to a subclass of - * ConnectionListener to receive notifications of events related to - * this connection. - */ - QMF_EXTERN Connection(const ConnectionSettings& settings, - const ConnectionListener* listener = 0); - - /** - * Destroys a connection, causing the connection to be closed. - */ - QMF_EXTERN ~Connection(); - - /** - * Set the administrative state of the connection (enabled or disabled). - * - * @param enabled True => enable connection, False => disable connection - */ - QMF_EXTERN void setAdminState(bool enabled); - - /** - * Return the current operational state of the connection (up or down). - * - * @return the current connection state. - */ - QMF_EXTERN ConnectionState getOperState() const; - - /** - * Get the error message from the last failure to connect. - * - * @return Null-terminated string containing the error message. - */ - QMF_EXTERN const char* getLastError() const; - - private: - friend class AgentImpl; - friend class ConsoleImpl; - ConnectionImpl* impl; - }; - -} - -#endif diff --git a/qpid/cpp/include/qmf/ConnectionSettings.h b/qpid/cpp/include/qmf/ConnectionSettings.h deleted file mode 100644 index 11af73d797..0000000000 --- a/qpid/cpp/include/qmf/ConnectionSettings.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _QmfConnectionSettings_ -#define _QmfConnectionSettings_ - -/* - * 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. - */ - -namespace qmf { - namespace engine { - class ConnectionSettings; - } - - typedef class engine::ConnectionSettings ConnectionSettings; -} - -#endif - diff --git a/qpid/cpp/include/qmf/ConsoleObject.h b/qpid/cpp/include/qmf/ConsoleObject.h deleted file mode 100644 index acbc285e05..0000000000 --- a/qpid/cpp/include/qmf/ConsoleObject.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef _QmfConsoleObject_ -#define _QmfConsoleObject_ - -/* - * 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/QmfImportExport.h" - -namespace qmf { - - class ConsoleObjectImpl; - class SchemaObjectClass; - class ObjectId; - class Value; - - /** - * ConsoleObject is an extension of Object with console-specific methods added. - * - * \ingroup qmfapi - */ - class ConsoleObject : public Object { - public: - /** - * Create a new Object of a specific type. - * - * @param type Pointer to the schema class to use as a type for this object. - */ - QMF_EXTERN ConsoleObject(const SchemaObjectClass* type); - - /** - * Destroy the object. - */ - QMF_EXTERN virtual ~ConsoleObject(); - - /** - * - */ - QMF_EXTERN const SchemaObjectClass* getSchema() const; - - /** - * - */ - QMF_EXTERN ObjectId* getObjectId() const; - - /** - * - */ - QMF_EXTERN uint64_t getCurrentTime() const; - QMF_EXTERN uint64_t getCreateTime() const; - QMF_EXTERN uint64_t getDeleteTime() const; - - /** - * - */ - QMF_EXTERN bool isDeleted() const; - - /** - * - */ - QMF_EXTERN void update(); - - /** - * - */ - QMF_EXTERN void invokeMethod(const char* name, const Value* arguments, MethodResult& result); - - /** - * - */ - QMF_EXTERN uint32_t invokeMethodAsync(const char* name, const Value* arguments = 0); - - private: - ConsoleObjectImpl* impl; - }; - -} - -#endif diff --git a/qpid/cpp/include/qmf/QmfImportExport.h b/qpid/cpp/include/qmf/QmfImportExport.h deleted file mode 100644 index f5e1d9127c..0000000000 --- a/qpid/cpp/include/qmf/QmfImportExport.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef QMF_IMPORT_EXPORT_H -#define QMF_IMPORT_EXPORT_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. - */ - -#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 -#else -# define QMF_EXTERN -#endif - -#endif -- cgit v1.2.1 From 03b589ce68fd45bdf2634c211b02bdc5f3cbdba5 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 12 Aug 2010 22:28:09 +0000 Subject: QPID-2792 - QMF Clients in C++ following the ABI-stable pattern of the new messaging API git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@985016 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 84 +++++++++++++++++++++++++++++++ qpid/cpp/include/qmf/AgentEvent.h | 74 ++++++++++++++++++++++++++++ qpid/cpp/include/qmf/AgentSession.h | 93 +++++++++++++++++++++++++++++++++++ qpid/cpp/include/qmf/ConsoleEvent.h | 73 +++++++++++++++++++++++++++ qpid/cpp/include/qmf/ConsoleSession.h | 65 ++++++++++++++++++++++++ qpid/cpp/include/qmf/Data.h | 71 ++++++++++++++++++++++++++ qpid/cpp/include/qmf/DataAddr.h | 62 +++++++++++++++++++++++ qpid/cpp/include/qmf/Handle.h | 70 ++++++++++++++++++++++++++ qpid/cpp/include/qmf/ImportExport.h | 33 +++++++++++++ qpid/cpp/include/qmf/Query.h | 65 ++++++++++++++++++++++++ qpid/cpp/include/qmf/Schema.h | 76 ++++++++++++++++++++++++++++ qpid/cpp/include/qmf/SchemaId.h | 61 +++++++++++++++++++++++ qpid/cpp/include/qmf/SchemaMethod.h | 65 ++++++++++++++++++++++++ qpid/cpp/include/qmf/SchemaProperty.h | 74 ++++++++++++++++++++++++++++ qpid/cpp/include/qmf/SchemaTypes.h | 56 +++++++++++++++++++++ qpid/cpp/include/qmf/exceptions.h | 59 ++++++++++++++++++++++ 16 files changed, 1081 insertions(+) create mode 100644 qpid/cpp/include/qmf/Agent.h create mode 100644 qpid/cpp/include/qmf/AgentEvent.h create mode 100644 qpid/cpp/include/qmf/AgentSession.h create mode 100644 qpid/cpp/include/qmf/ConsoleEvent.h create mode 100644 qpid/cpp/include/qmf/ConsoleSession.h create mode 100644 qpid/cpp/include/qmf/Data.h create mode 100644 qpid/cpp/include/qmf/DataAddr.h create mode 100644 qpid/cpp/include/qmf/Handle.h create mode 100644 qpid/cpp/include/qmf/ImportExport.h create mode 100644 qpid/cpp/include/qmf/Query.h create mode 100644 qpid/cpp/include/qmf/Schema.h create mode 100644 qpid/cpp/include/qmf/SchemaId.h create mode 100644 qpid/cpp/include/qmf/SchemaMethod.h create mode 100644 qpid/cpp/include/qmf/SchemaProperty.h create mode 100644 qpid/cpp/include/qmf/SchemaTypes.h create mode 100644 qpid/cpp/include/qmf/exceptions.h (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h new file mode 100644 index 0000000000..8ddea0fae9 --- /dev/null +++ b/qpid/cpp/include/qmf/Agent.h @@ -0,0 +1,84 @@ +#ifndef QMF_AGENT_H +#define QMF_AGENT_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 +#include "qmf/Handle.h" +#include "qmf/exceptions.h" +#include "qpid/messaging/Duration.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class AgentImpl; + class ConsoleEvent; + class Query; + class DataAddr; + class SchemaId; + class Schema; + + class Agent : public qmf::Handle { + public: + QMF_EXTERN Agent(AgentImpl* impl = 0); + QMF_EXTERN Agent(const Agent&); + QMF_EXTERN Agent& operator=(const Agent&); + QMF_EXTERN ~Agent(); + + QMF_EXTERN std::string getName() const; + QMF_EXTERN uint32_t getEpoch() const; + QMF_EXTERN std::string getVendor() const; + QMF_EXTERN std::string getProduct() const; + QMF_EXTERN std::string getInstance() const; + QMF_EXTERN const qpid::types::Variant& getAttribute(const std::string&) const; + QMF_EXTERN const qpid::types::Variant::Map& getAttributes() const; + + QMF_EXTERN ConsoleEvent query(const Query&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); + QMF_EXTERN ConsoleEvent query(const std::string&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); + QMF_EXTERN uint32_t queryAsync(const Query&); + QMF_EXTERN uint32_t queryAsync(const std::string&); + + QMF_EXTERN ConsoleEvent callMethod(const std::string&, const qpid::types::Variant::Map&, const DataAddr&, + qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); + QMF_EXTERN uint32_t callMethodAsync(const std::string&, const qpid::types::Variant::Map&, const DataAddr&); + + QMF_EXTERN uint32_t getPackageCount() const; + QMF_EXTERN const std::string& getPackage(uint32_t) const; + QMF_EXTERN uint32_t getSchemaIdCount(const std::string&) const; + QMF_EXTERN SchemaId getSchemaId(const std::string&, uint32_t) const; + QMF_EXTERN Schema getSchema(const SchemaId&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); + + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct AgentImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/AgentEvent.h b/qpid/cpp/include/qmf/AgentEvent.h new file mode 100644 index 0000000000..59a41c3267 --- /dev/null +++ b/qpid/cpp/include/qmf/AgentEvent.h @@ -0,0 +1,74 @@ +#ifndef QMF_AGENT_EVENT_H +#define QMF_AGENT_EVENT_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 +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class AgentEventImpl; + class Query; + class DataAddr; + + enum AgentEventCode { + AGENT_AUTH_QUERY = 1, + AGENT_AUTH_SUBSCRIBE = 2, + AGENT_QUERY = 3, + AGENT_METHOD = 4, + AGENT_SUBSCRIBE_BEGIN = 5, + AGENT_SUBSCRIBE_TOUCH = 6, + AGENT_SUBSCRIBE_END = 7, + AGENT_THREAD_FAILED = 8 + }; + + class AgentEvent : public qmf::Handle { + public: + QMF_EXTERN AgentEvent(AgentEventImpl* impl = 0); + QMF_EXTERN AgentEvent(const AgentEvent&); + QMF_EXTERN AgentEvent& operator=(const AgentEvent&); + QMF_EXTERN ~AgentEvent(); + + QMF_EXTERN AgentEventCode getType() const; + QMF_EXTERN const std::string& getUserId() const; + QMF_EXTERN Query getQuery() const; + QMF_EXTERN bool hasDataAddr() const; + QMF_EXTERN DataAddr getDataAddr() const; + QMF_EXTERN const std::string& getMethodName() const; + QMF_EXTERN qpid::types::Variant::Map& getArguments(); + QMF_EXTERN qpid::types::Variant::Map& getArgumentSubtypes(); + QMF_EXTERN void addReturnArgument(const std::string&, const qpid::types::Variant&, const std::string& st=""); + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct AgentEventImplAccess; +#endif + }; +} + +#endif diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h new file mode 100644 index 0000000000..5259aee360 --- /dev/null +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -0,0 +1,93 @@ +#ifndef QMF_AGENT_SESSION_H +#define QMF_AGENT_SESSION_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 +#include "qmf/Handle.h" +#include "qpid/messaging/Duration.h" +#include "qpid/messaging/Connection.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class AgentSessionImpl; + class AgentEvent; + class Schema; + class Data; + class DataAddr; + + class AgentSession : public qmf::Handle { + public: + QMF_EXTERN AgentSession(AgentSessionImpl* impl = 0); + QMF_EXTERN AgentSession(const AgentSession&); + QMF_EXTERN AgentSession& operator=(const AgentSession&); + QMF_EXTERN ~AgentSession(); + + /** + * + * The options string is of the form "{key:value,key:value}". The following keys are supported: + * + * interval:N - Heartbeat interval in seconds [default: 60] + * external:{True,False} - Use external data storage (queries are pass-through) [default: False] + * allow-queries:{True,False} - If True: automatically allow all queries [default] + * If False: generate an AUTH_QUERY event to allow per-query authorization + * allow-methods:{True,False} - If True: automatically allow all methods [default] + * If False: generate an AUTH_METHOD event to allow per-method authorization + */ + QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); + QMF_EXTERN void setDomain(const std::string&); + QMF_EXTERN void setVendor(const std::string&); + QMF_EXTERN void setProduct(const std::string&); + QMF_EXTERN void setInstance(const std::string&); + QMF_EXTERN void setAttribute(const std::string&, const qpid::types::Variant&); + QMF_EXTERN const std::string& getName() const; + QMF_EXTERN void open(); + QMF_EXTERN void close(); + QMF_EXTERN bool nextEvent(AgentEvent&, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + + QMF_EXTERN void registerSchema(Schema&); + QMF_EXTERN DataAddr addData(Data&, const std::string& name="", bool persistent=false); + QMF_EXTERN void delData(const DataAddr&); + + 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 raiseEvent(const Data&); + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/ConsoleEvent.h b/qpid/cpp/include/qmf/ConsoleEvent.h new file mode 100644 index 0000000000..61f625b137 --- /dev/null +++ b/qpid/cpp/include/qmf/ConsoleEvent.h @@ -0,0 +1,73 @@ +#ifndef QMF_CONSOLE_EVENT_H +#define QMF_CONSOLE_EVENT_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 +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class ConsoleEventImpl; + class Agent; + class Data; + + enum ConsoleEventCode { + CONSOLE_AGENT_ADD = 1, + CONSOLE_AGENT_AGE = 2, + CONSOLE_EVENT = 3, + CONSOLE_QUERY_RESPONSE = 4, + CONSOLE_METHOD_RESPONSE = 5, + CONSOLE_EXCEPTION = 6, + CONSOLE_SUBSCRIBE_UPDATE = 7, + CONSOLE_THREAD_FAILED = 8 + }; + + class ConsoleEvent : public qmf::Handle { + public: + QMF_EXTERN ConsoleEvent(ConsoleEventImpl* impl = 0); + QMF_EXTERN ConsoleEvent(const ConsoleEvent&); + QMF_EXTERN ConsoleEvent& operator=(const ConsoleEvent&); + QMF_EXTERN ~ConsoleEvent(); + + QMF_EXTERN ConsoleEventCode getType() const; + QMF_EXTERN uint32_t getCorrelator() const; + QMF_EXTERN Agent getAgent() const; + QMF_EXTERN uint32_t getDataCount() const; + QMF_EXTERN Data getData(uint32_t) const; + QMF_EXTERN bool isFinal() const; + QMF_EXTERN const qpid::types::Variant::Map& getArguments() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct ConsoleEventImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h new file mode 100644 index 0000000000..0e58a647d6 --- /dev/null +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -0,0 +1,65 @@ +#ifndef QMF_CONSOLE_SESSION_H +#define QMF_CONSOLE_SESSION_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 +#include "qmf/Handle.h" +#include "qmf/Agent.h" +#include "qpid/messaging/Duration.h" +#include "qpid/messaging/Connection.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class ConsoleSessionImpl; + class ConsoleEvent; + + class ConsoleSession : public qmf::Handle { + public: + QMF_EXTERN ConsoleSession(ConsoleSessionImpl* impl = 0); + QMF_EXTERN ConsoleSession(const ConsoleSession&); + QMF_EXTERN ConsoleSession& operator=(const ConsoleSession&); + QMF_EXTERN ~ConsoleSession(); + + 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(); + QMF_EXTERN void close(); + QMF_EXTERN bool nextEvent(ConsoleEvent&, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + QMF_EXTERN uint32_t getAgentCount() const; + QMF_EXTERN Agent getAgent(uint32_t) const; + QMF_EXTERN Agent getConnectedBrokerAgent() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/Data.h b/qpid/cpp/include/qmf/Data.h new file mode 100644 index 0000000000..27af1c4b04 --- /dev/null +++ b/qpid/cpp/include/qmf/Data.h @@ -0,0 +1,71 @@ +#ifndef QMF_DATA_H +#define QMF_DATA_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 +#include "qmf/Handle.h" +#include "qmf/exceptions.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class DataImpl; + class SchemaId; + class DataAddr; + class Agent; + + class Data : public qmf::Handle { + public: + QMF_EXTERN Data(DataImpl* impl = 0); + QMF_EXTERN Data(const Data&); + QMF_EXTERN Data& operator=(const Data&); + QMF_EXTERN ~Data(); + + QMF_EXTERN Data(const SchemaId&); + QMF_EXTERN void setSchema(const SchemaId&); + QMF_EXTERN void setAddr(const DataAddr&); + QMF_EXTERN void setProperty(const std::string&, const qpid::types::Variant&); + QMF_EXTERN void overwriteProperties(const qpid::types::Variant::Map&); + QMF_EXTERN bool hasSchema() const; + QMF_EXTERN bool hasAddr() const; + QMF_EXTERN const SchemaId& getSchemaId() const; + QMF_EXTERN const DataAddr& getAddr() const; + QMF_EXTERN const qpid::types::Variant& getProperty(const std::string&) const; + QMF_EXTERN const qpid::types::Variant::Map& getProperties() const; + QMF_EXTERN bool hasAgent() const; + QMF_EXTERN const Agent& getAgent() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct DataImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/DataAddr.h b/qpid/cpp/include/qmf/DataAddr.h new file mode 100644 index 0000000000..fd8a8599c1 --- /dev/null +++ b/qpid/cpp/include/qmf/DataAddr.h @@ -0,0 +1,62 @@ +#ifndef QMF_DATA_ADDR_H +#define QMF_DATA_ADDR_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 +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class DataAddrImpl; + + class DataAddr : public qmf::Handle { + public: + QMF_EXTERN DataAddr(DataAddrImpl* impl = 0); + QMF_EXTERN DataAddr(const DataAddr&); + QMF_EXTERN DataAddr& operator=(const DataAddr&); + QMF_EXTERN ~DataAddr(); + + QMF_EXTERN bool operator==(const DataAddr&); + QMF_EXTERN bool operator<(const DataAddr&); + + QMF_EXTERN DataAddr(const std::string& name, const std::string& agentName, uint32_t agentEpoch=0); + QMF_EXTERN const std::string& getName() const; + QMF_EXTERN const std::string& getAgentName() const; + QMF_EXTERN uint32_t getAgentEpoch() const; + QMF_EXTERN qpid::types::Variant::Map asMap() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct DataAddrImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/Handle.h b/qpid/cpp/include/qmf/Handle.h new file mode 100644 index 0000000000..510e2993aa --- /dev/null +++ b/qpid/cpp/include/qmf/Handle.h @@ -0,0 +1,70 @@ +#ifndef QMF_HANDLE_H +#define QMF_HANDLE_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" + +namespace qmf { + +template class PrivateImplRef; + +/** \ingroup qmf + * A handle is like a pointer: refers to an underlying implementation object. + * Copying the handle does not copy the object. + * + * Handles can be null, like a 0 pointer. Use isValid(), isNull() or the + * conversion to bool to test for a null handle. + */ +template class Handle { + public: + + /**@return true if handle is valid, i.e. not null. */ + QMF_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; } + + /** Conversion to bool supports idiom if (handle) { handle->... } */ + QMF_EXTERN operator bool() const { return impl; } + + /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */ + QMF_EXTERN bool operator !() const { return !impl; } + + void swap(Handle& h) { T* t = h.impl; h.impl = impl; impl = t; } + + protected: + typedef T Impl; + QMF_EXTERN Handle() :impl() {} + + // Not implemented,subclasses must implement. + QMF_EXTERN Handle(const Handle&); + QMF_EXTERN Handle& operator=(const Handle&); + + Impl* impl; + + friend class PrivateImplRef; +}; + +} // namespace qmf + +#endif /*!QMF_HANDLE_H*/ diff --git a/qpid/cpp/include/qmf/ImportExport.h b/qpid/cpp/include/qmf/ImportExport.h new file mode 100644 index 0000000000..f5e1d9127c --- /dev/null +++ b/qpid/cpp/include/qmf/ImportExport.h @@ -0,0 +1,33 @@ +#ifndef QMF_IMPORT_EXPORT_H +#define QMF_IMPORT_EXPORT_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. + */ + +#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 +#else +# define QMF_EXTERN +#endif + +#endif diff --git a/qpid/cpp/include/qmf/Query.h b/qpid/cpp/include/qmf/Query.h new file mode 100644 index 0000000000..71ef31b104 --- /dev/null +++ b/qpid/cpp/include/qmf/Query.h @@ -0,0 +1,65 @@ +#ifndef QMF_QUERY_H +#define QMF_QUERY_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 +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class QueryImpl; + class SchemaId; + class DataAddr; + + class Query : public qmf::Handle { + public: + QMF_EXTERN Query(QueryImpl* impl = 0); + QMF_EXTERN Query(const Query&); + QMF_EXTERN Query& operator=(const Query&); + QMF_EXTERN ~Query(); + + QMF_EXTERN Query(const std::string& className, const std::string& package="", const std::string& predicate=""); + QMF_EXTERN Query(const SchemaId&); + QMF_EXTERN Query(const DataAddr&); + + QMF_EXTERN const DataAddr& getDataAddr() const; + QMF_EXTERN const SchemaId& getSchemaId() const; + QMF_EXTERN const std::string& getClassName() const; + QMF_EXTERN const std::string& getPackageName() const; + QMF_EXTERN void addPredicate(const std::string&, const qpid::types::Variant&); + QMF_EXTERN const qpid::types::Variant::Map& getPredicate() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/Schema.h b/qpid/cpp/include/qmf/Schema.h new file mode 100644 index 0000000000..cf316138c1 --- /dev/null +++ b/qpid/cpp/include/qmf/Schema.h @@ -0,0 +1,76 @@ +#ifndef QMF_SCHEMA_H +#define QMF_SCHEMA_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 +#include "qpid/sys/IntegerTypes.h" +#include "qmf/Handle.h" +#include "qmf/SchemaTypes.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class SchemaImpl; + class SchemaId; + class SchemaProperty; + class SchemaMethod; + + class Schema : public qmf::Handle { + public: + QMF_EXTERN Schema(SchemaImpl* impl = 0); + QMF_EXTERN Schema(const Schema&); + QMF_EXTERN Schema& operator=(const Schema&); + QMF_EXTERN ~Schema(); + + QMF_EXTERN Schema(int, const std::string&, const std::string&); + QMF_EXTERN const SchemaId& getSchemaId() const; + + QMF_EXTERN void finalize(); + QMF_EXTERN bool isFinalized() const; + QMF_EXTERN void addProperty(const SchemaProperty&); + QMF_EXTERN void addMethod(const SchemaMethod&); + QMF_EXTERN void setDesc(const std::string&); + QMF_EXTERN const std::string& getDesc() const; + + QMF_EXTERN void setDefaultSeverity(int); + QMF_EXTERN int getDefaultSeverity() const; + + QMF_EXTERN uint32_t getPropertyCount() const; + QMF_EXTERN SchemaProperty getProperty(uint32_t) const; + + QMF_EXTERN uint32_t getMethodCount() const; + QMF_EXTERN SchemaMethod getMethod(uint32_t) const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct SchemaImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/SchemaId.h b/qpid/cpp/include/qmf/SchemaId.h new file mode 100644 index 0000000000..13fb1cb902 --- /dev/null +++ b/qpid/cpp/include/qmf/SchemaId.h @@ -0,0 +1,61 @@ +#ifndef QMF_SCHEMA_ID_H +#define QMF_SCHEMA_ID_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 +#include "qmf/Handle.h" +#include "qpid/types/Uuid.h" +#include "qmf/SchemaTypes.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class SchemaIdImpl; + + class SchemaId : public qmf::Handle { + public: + QMF_EXTERN SchemaId(SchemaIdImpl* impl = 0); + QMF_EXTERN SchemaId(const SchemaId&); + QMF_EXTERN SchemaId& operator=(const SchemaId&); + QMF_EXTERN ~SchemaId(); + + QMF_EXTERN SchemaId(int, const std::string&, const std::string&); + QMF_EXTERN void setHash(const qpid::types::Uuid&); + QMF_EXTERN int getType() const; + QMF_EXTERN const std::string& getPackageName() const; + QMF_EXTERN const std::string& getName() const; + QMF_EXTERN const qpid::types::Uuid& getHash() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct SchemaIdImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/SchemaMethod.h b/qpid/cpp/include/qmf/SchemaMethod.h new file mode 100644 index 0000000000..47302b62b9 --- /dev/null +++ b/qpid/cpp/include/qmf/SchemaMethod.h @@ -0,0 +1,65 @@ +#ifndef QMF_SCHEMA_METHOD_H +#define QMF_SCHEMA_METHOD_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 "qpid/sys/IntegerTypes.h" +#include "qmf/Handle.h" +#include "qmf/SchemaTypes.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class SchemaMethodImpl; + class SchemaProperty; + + class SchemaMethod : public qmf::Handle { + public: + QMF_EXTERN SchemaMethod(SchemaMethodImpl* impl = 0); + QMF_EXTERN SchemaMethod(const SchemaMethod&); + QMF_EXTERN SchemaMethod& operator=(const SchemaMethod&); + QMF_EXTERN ~SchemaMethod(); + + QMF_EXTERN SchemaMethod(const std::string&, const std::string& o=""); + + QMF_EXTERN void setDesc(const std::string&); + QMF_EXTERN void addArgument(const SchemaProperty&); + + QMF_EXTERN const std::string& getName() const; + QMF_EXTERN const std::string& getDesc() const; + QMF_EXTERN uint32_t getArgumentCount() const; + QMF_EXTERN SchemaProperty getArgument(uint32_t) const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct SchemaMethodImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/SchemaProperty.h b/qpid/cpp/include/qmf/SchemaProperty.h new file mode 100644 index 0000000000..2e770c2ef1 --- /dev/null +++ b/qpid/cpp/include/qmf/SchemaProperty.h @@ -0,0 +1,74 @@ +#ifndef QMF_SCHEMA_PROPERTY_H +#define QMF_SCHEMA_PROPERTY_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 +#include "qmf/Handle.h" +#include "qpid/types/Uuid.h" +#include "qpid/types/Variant.h" +#include "qmf/SchemaTypes.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class SchemaPropertyImpl; + + class SchemaProperty : public Handle { + public: + QMF_EXTERN SchemaProperty(SchemaPropertyImpl* impl = 0); + QMF_EXTERN SchemaProperty(const SchemaProperty&); + QMF_EXTERN SchemaProperty& operator=(const SchemaProperty&); + QMF_EXTERN ~SchemaProperty(); + + QMF_EXTERN SchemaProperty(const std::string&, int, const std::string& o=""); + + QMF_EXTERN void setAccess(int); + QMF_EXTERN void setIndex(bool); + QMF_EXTERN void setOptional(bool); + QMF_EXTERN void setUnit(const std::string&); + QMF_EXTERN void setDesc(const std::string&); + QMF_EXTERN void setSubtype(const std::string&); + QMF_EXTERN void setDirection(int); + + QMF_EXTERN const std::string& getName() const; + QMF_EXTERN int getAccess() const; + QMF_EXTERN bool isIndex() const; + QMF_EXTERN bool isOptional() const; + QMF_EXTERN const std::string& getUnit() const; + QMF_EXTERN const std::string& getDesc() const; + QMF_EXTERN const std::string& getSubtype() const; + QMF_EXTERN int getDirection() const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend struct SchemaPropertyImplAccess; +#endif + }; + +} + +#endif diff --git a/qpid/cpp/include/qmf/SchemaTypes.h b/qpid/cpp/include/qmf/SchemaTypes.h new file mode 100644 index 0000000000..af3da612e5 --- /dev/null +++ b/qpid/cpp/include/qmf/SchemaTypes.h @@ -0,0 +1,56 @@ +#ifndef QMF_SCHEMA_TYPES_H +#define QMF_SCHEMA_TYPES_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. + * + */ + +namespace qmf { + + const int SCHEMA_TYPE_DATA = 1; + const int SCHEMA_TYPE_EVENT = 2; + + const int SCHEMA_DATA_VOID = 1; + const int SCHEMA_DATA_BOOL = 2; + const int SCHEMA_DATA_INT = 3; + const int SCHEMA_DATA_FLOAT = 4; + const int SCHEMA_DATA_STRING = 5; + const int SCHEMA_DATA_MAP = 6; + const int SCHEMA_DATA_LIST = 7; + const int SCHEMA_DATA_UUID = 8; + + const int ACCESS_READ_CREATE = 1; + const int ACCESS_READ_WRITE = 2; + const int ACCESS_READ_ONLY = 3; + + const int DIR_IN = 1; + const int DIR_OUT = 2; + const int DIR_IN_OUT = 3; + + const int SEV_EMERG = 0; + const int SEV_ALERT = 1; + const int SEV_CRIT = 2; + const int SEV_ERROR = 3; + const int SEV_WARN = 4; + const int SEV_NOTICE = 5; + const int SEV_INFORM = 6; + const int SEV_DEBUG = 7; +} + +#endif diff --git a/qpid/cpp/include/qmf/exceptions.h b/qpid/cpp/include/qmf/exceptions.h new file mode 100644 index 0000000000..7959499d63 --- /dev/null +++ b/qpid/cpp/include/qmf/exceptions.h @@ -0,0 +1,59 @@ +#ifndef QMF_EXCEPTIONS_H +#define QMF_EXCEPTIONS_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 "qpid/types/Exception.h" +#include "qpid/types/Variant.h" + +namespace qmf { + +/** \ingroup qmf + */ + + struct 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 { + QMF_EXTERN KeyNotFound(const std::string& msg); + QMF_EXTERN virtual ~KeyNotFound() throw(); + }; + + struct IndexOutOfRange : public QmfException { + QMF_EXTERN IndexOutOfRange(); + QMF_EXTERN virtual ~IndexOutOfRange() throw(); + }; + + struct OperationTimedOut : public QmfException { + QMF_EXTERN OperationTimedOut(); + QMF_EXTERN virtual ~OperationTimedOut() throw(); + }; + +} + +#endif + -- cgit v1.2.1 From 58c7fd662a4d37ff3b387575e0c0d3b80e7e7368 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 13 Aug 2010 02:25:28 +0000 Subject: QPID-2793 - Added doxygen text git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@985074 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/AgentSession.h | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 5259aee360..4ac2b2f3ed 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -48,6 +48,11 @@ namespace qmf { QMF_EXTERN ~AgentSession(); /** + * AgentSession + * A session that runs over an AMQP connection for QMF agent operation. + * + * @param connection - An opened qpid::messaging::Connection + * @param options - An optional string containing options * * The options string is of the form "{key:value,key:value}". The following keys are supported: * @@ -59,20 +64,88 @@ namespace qmf { * If False: generate an AUTH_METHOD event to allow per-method authorization */ QMF_EXTERN AgentSession(qpid::messaging::Connection&, 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&); + + /** + * Set identifying attributes of this agent. + * setVendor - Set the vendor string + * setProduct - Set the product name string + * 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&); + + /** + * 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&); + + /** + * Get the identifying name of the agent. + */ QMF_EXTERN const std::string& getName() const; + + /** + * Open the agent session. After opening the session, the domain, identifying strings, and attributes cannot + * be changed. + */ QMF_EXTERN void open(); + + /** + * Close the session. Once closed, the session no longer communicates on the messaging network. + */ QMF_EXTERN void close(); + + /** + * 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. + */ QMF_EXTERN bool nextEvent(AgentEvent&, qpid::messaging::Duration timeout=qpid::messaging::Duration::FOREVER); + /** + * Register a schema to be exposed by this agent. + */ QMF_EXTERN void registerSchema(Schema&); + + /** + * Add data to be managed internally by the agent. If the option external:True is selected, this call + * should not be used. + * + * @param data - The data object being managed by the agent. + * @param name - A name unique to this object to be used to address the object. + * If left default, a unique name will be assigned by the agent. + * @param persistent - Set this to true if the data object is to be considered persistent + * 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); + + /** + * Delete data from internal agent management. + */ QMF_EXTERN void delData(const DataAddr&); + /** + * The following methods are used to respond to events received in nextEvent. + * + * authAccept - Accept an authorization request. + * authReject - Reject/forbid an authorization request. + * raiseException - indicate failure of an operation (i.e. query or method call). + * response - Provide data in response to a query (only for option: external:True) + * complete - Indicate that the response to a query is complete (external:true only) + * 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&); @@ -80,6 +153,10 @@ namespace qmf { QMF_EXTERN void response(AgentEvent&, const Data&); QMF_EXTERN void complete(AgentEvent&); QMF_EXTERN void methodSuccess(AgentEvent&); + + /** + * Raise an event to be sent into the QMF network. + */ QMF_EXTERN void raiseEvent(const Data&); #ifndef SWIG -- cgit v1.2.1 From d47927b3e150057f6d615a0d00c8eff6c83320ac Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 21 Sep 2010 21:48:41 +0000 Subject: QMFv2 Additions: - QMFv2 schema encoding completed - Schema queries handled by the agent and initiated by the console by user request - Full query support with predicates evaluated on the agent (regex not yet implemented) - Agent filtering in the console - Agent aging in the console - Unit tests git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@999662 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 42 +++++++++++++++++++++++++++++++++++ qpid/cpp/include/qmf/ConsoleEvent.h | 32 +++++++++++++++++--------- qpid/cpp/include/qmf/ConsoleSession.h | 13 +++++++++++ qpid/cpp/include/qmf/Query.h | 21 +++++++++++++----- qpid/cpp/include/qmf/SchemaProperty.h | 1 + 5 files changed, 93 insertions(+), 16 deletions(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h index 8ddea0fae9..8d427ab2fb 100644 --- a/qpid/cpp/include/qmf/Agent.h +++ b/qpid/cpp/include/qmf/Agent.h @@ -65,10 +65,52 @@ namespace qmf { qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); QMF_EXTERN uint32_t callMethodAsync(const std::string&, const qpid::types::Variant::Map&, const DataAddr&); + /** + * Query the agent for a list of schema classes that it exposes. This operation comes in both + * synchronous (blocking) and asynchronous flavors. + * + * This method will typically be used after receiving an AGENT_SCHEMA_UPDATE event from the console session. + * It may also be used on a newly discovered agent to learn what schemata are exposed. + * + * querySchema returns a ConsoleEvent that contains a list of SchemaId objects exposed by the agent. + * This list is cached locally and can be locally queried using getPackage[Count] and getSchemaId[Count]. + */ + QMF_EXTERN ConsoleEvent querySchema(qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); + QMF_EXTERN uint32_t querySchemaAsync(); + + /** + * Get the list of schema packages exposed by the agent. + * + * getPackageCount returns the number of packages exposed. + * getPackage returns the name of the package by index (0..package-count) + * + * Note that both of these calls are synchronous and non-blocking. They only return locally cached data + * and will not send any messages to the remote agent. Use querySchema[Async] to get the latest schema + * information from the remote agent. + */ QMF_EXTERN uint32_t getPackageCount() const; QMF_EXTERN const std::string& getPackage(uint32_t) const; + + /** + * Get the list of schema identifiers for a particular package. + * + * getSchemaIdCount returns the number of IDs in the indicates package. + * getSchemaId returns the SchemaId by index (0..schema-id-count) + * + * Note that both of these calls are synchronous and non-blocking. They only return locally cached data + * and will not send any messages to the remote agent. Use querySchema[Async] to get the latest schema + * information from the remote agent. + */ QMF_EXTERN uint32_t getSchemaIdCount(const std::string&) const; QMF_EXTERN SchemaId getSchemaId(const std::string&, uint32_t) const; + + /** + * Get detailed schema information for a specified schema ID. + * + * This call will return cached information if it is available. If not, it will send a query message to the + * remote agent and block waiting for a response. The timeout argument specifies the maximum time to wait + * for a response from the agent. + */ QMF_EXTERN Schema getSchema(const SchemaId&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); diff --git a/qpid/cpp/include/qmf/ConsoleEvent.h b/qpid/cpp/include/qmf/ConsoleEvent.h index 61f625b137..3e75631a61 100644 --- a/qpid/cpp/include/qmf/ConsoleEvent.h +++ b/qpid/cpp/include/qmf/ConsoleEvent.h @@ -23,6 +23,9 @@ #include #include "qmf/Handle.h" +#include "qmf/Agent.h" +#include "qmf/Data.h" +#include "qmf/SchemaId.h" #include "qpid/types/Variant.h" namespace qmf { @@ -32,18 +35,24 @@ namespace qmf { #endif class ConsoleEventImpl; - class Agent; - class Data; enum ConsoleEventCode { - CONSOLE_AGENT_ADD = 1, - CONSOLE_AGENT_AGE = 2, - CONSOLE_EVENT = 3, - CONSOLE_QUERY_RESPONSE = 4, - CONSOLE_METHOD_RESPONSE = 5, - CONSOLE_EXCEPTION = 6, - CONSOLE_SUBSCRIBE_UPDATE = 7, - CONSOLE_THREAD_FAILED = 8 + CONSOLE_AGENT_ADD = 1, + CONSOLE_AGENT_DEL = 2, + CONSOLE_AGENT_RESTART = 3, + CONSOLE_AGENT_SCHEMA_UPDATE = 4, + CONSOLE_AGENT_SCHEMA_RESPONSE = 5, + CONSOLE_EVENT = 6, + CONSOLE_QUERY_RESPONSE = 7, + CONSOLE_METHOD_RESPONSE = 8, + CONSOLE_EXCEPTION = 9, + CONSOLE_SUBSCRIBE_UPDATE = 10, + CONSOLE_THREAD_FAILED = 11 + }; + + enum AgentDelReason { + AGENT_DEL_AGED = 1, + AGENT_DEL_FILTER = 2 }; class ConsoleEvent : public qmf::Handle { @@ -56,6 +65,9 @@ namespace qmf { QMF_EXTERN ConsoleEventCode getType() const; QMF_EXTERN uint32_t getCorrelator() const; QMF_EXTERN Agent getAgent() const; + QMF_EXTERN AgentDelReason getAgentDelReason() const; + QMF_EXTERN uint32_t getSchemaIdCount() const; + QMF_EXTERN SchemaId getSchemaId(uint32_t) const; QMF_EXTERN uint32_t getDataCount() const; QMF_EXTERN Data getData(uint32_t) const; QMF_EXTERN bool isFinal() const; diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index 0e58a647d6..c17f4510f1 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -44,6 +44,19 @@ namespace qmf { QMF_EXTERN ConsoleSession& operator=(const ConsoleSession&); QMF_EXTERN ~ConsoleSession(); + /** + * ConsoleSession + * A session that runs over an AMQP connection for QMF console operation. + * + * @param connection - An opened qpid::messaging::Connection + * @param options - An optional string containing options + * + * The options string is of the form "{key:value,key:value}". The following keys are supported: + * + * domain:NAME - QMF Domain to join [default: "default"] + * max-agent-age:N - Maximum time, in minutes, that we will tolerate not hearing from + * an agent before deleting it [default: 5] + */ QMF_EXTERN ConsoleSession(qpid::messaging::Connection&, const std::string& options=""); QMF_EXTERN void setDomain(const std::string&); QMF_EXTERN void setAgentFilter(const std::string&); diff --git a/qpid/cpp/include/qmf/Query.h b/qpid/cpp/include/qmf/Query.h index 71ef31b104..fec4660bd7 100644 --- a/qpid/cpp/include/qmf/Query.h +++ b/qpid/cpp/include/qmf/Query.h @@ -36,6 +36,13 @@ namespace qmf { class SchemaId; class DataAddr; + enum QueryTarget { + QUERY_OBJECT = 1, + QUERY_OBJECT_ID = 2, + QUERY_SCHEMA = 3, + QUERY_SCHEMA_ID = 4 + }; + class Query : public qmf::Handle { public: QMF_EXTERN Query(QueryImpl* impl = 0); @@ -43,20 +50,22 @@ namespace qmf { QMF_EXTERN Query& operator=(const Query&); QMF_EXTERN ~Query(); - QMF_EXTERN Query(const std::string& className, const std::string& package="", const std::string& predicate=""); - QMF_EXTERN Query(const SchemaId&); + QMF_EXTERN Query(QueryTarget, const std::string& predicate=""); + QMF_EXTERN Query(QueryTarget, const std::string& className, const std::string& package, const std::string& predicate=""); + QMF_EXTERN Query(QueryTarget, const SchemaId&, const std::string& predicate=""); QMF_EXTERN Query(const DataAddr&); + QMF_EXTERN QueryTarget getTarget() const; QMF_EXTERN const DataAddr& getDataAddr() const; QMF_EXTERN const SchemaId& getSchemaId() const; - QMF_EXTERN const std::string& getClassName() const; - QMF_EXTERN const std::string& getPackageName() const; - QMF_EXTERN void addPredicate(const std::string&, const qpid::types::Variant&); - QMF_EXTERN const qpid::types::Variant::Map& getPredicate() const; + QMF_EXTERN void setPredicate(const qpid::types::Variant::List&); + QMF_EXTERN const qpid::types::Variant::List& getPredicate() const; + QMF_EXTERN bool matchesPredicate(const qpid::types::Variant::Map& map) const; #ifndef SWIG private: friend class qmf::PrivateImplRef; + friend class QueryImplAccess; #endif }; diff --git a/qpid/cpp/include/qmf/SchemaProperty.h b/qpid/cpp/include/qmf/SchemaProperty.h index 2e770c2ef1..a3a328b60b 100644 --- a/qpid/cpp/include/qmf/SchemaProperty.h +++ b/qpid/cpp/include/qmf/SchemaProperty.h @@ -54,6 +54,7 @@ namespace qmf { QMF_EXTERN void setDirection(int); QMF_EXTERN const std::string& getName() const; + QMF_EXTERN int getType() const; QMF_EXTERN int getAccess() const; QMF_EXTERN bool isIndex() const; QMF_EXTERN bool isOptional() const; -- cgit v1.2.1 From b1cd22ae277d9a987d37e2538aded2f3521bc362 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Mon, 10 Jan 2011 14:06:16 +0000 Subject: Updates to the C++ implementation of QMFv2: 1) Consolidated string constants for the protocol into a definition file. 2) Added hooks for subscription handling. 3) Added checks to validate properties and arguments against the schema (if there is a schema). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1057199 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 7 +++ qpid/cpp/include/qmf/AgentSession.h | 9 +++- qpid/cpp/include/qmf/ConsoleEvent.h | 6 ++- qpid/cpp/include/qmf/ConsoleSession.h | 11 +++++ qpid/cpp/include/qmf/Data.h | 4 +- qpid/cpp/include/qmf/Subscription.h | 82 +++++++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 qpid/cpp/include/qmf/Subscription.h (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h index 8d427ab2fb..8c0f48b8b1 100644 --- a/qpid/cpp/include/qmf/Agent.h +++ b/qpid/cpp/include/qmf/Agent.h @@ -23,6 +23,7 @@ #include #include "qmf/Handle.h" +//#include "qmf/Subscription.h" #include "qmf/exceptions.h" #include "qpid/messaging/Duration.h" #include "qpid/types/Variant.h" @@ -61,6 +62,12 @@ namespace qmf { QMF_EXTERN uint32_t queryAsync(const Query&); QMF_EXTERN uint32_t queryAsync(const std::string&); + /** + * Create a subscription to this agent + */ + //QMF_EXTERN Subscription subscribe(const Query&, const std::string& options = ""); + //QMF_EXTERN Subscription subscribe(const std::string&, const std::string& options = ""); + QMF_EXTERN ConsoleEvent callMethod(const std::string&, const qpid::types::Variant::Map&, const DataAddr&, qpid::messaging::Duration timeout=qpid::messaging::Duration::MINUTE); QMF_EXTERN uint32_t callMethodAsync(const std::string&, const qpid::types::Variant::Map&, const DataAddr&); diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 4ac2b2f3ed..090017779f 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -57,11 +57,16 @@ namespace qmf { * The options string is of the form "{key:value,key:value}". The following keys are supported: * * interval:N - Heartbeat interval in seconds [default: 60] - * external:{True,False} - Use external data storage (queries are pass-through) [default: False] + * external:{True,False} - Use external data storage (queries and subscriptions are pass-through) [default: False] * allow-queries:{True,False} - If True: automatically allow all queries [default] * If False: generate an AUTH_QUERY event to allow per-query authorization * allow-methods:{True,False} - If True: automatically allow all methods [default] * If False: generate an AUTH_METHOD event to allow per-method authorization + * max-subscriptions:N - Maximum number of concurrent subscription queries permitted [default: 64] + * min-sub-interval:N - Minimum publish interval (in milliseconds) permitted for a subscription [default: 3000] + * sub-lifetime:N - Lifetime (in seconds with no keepalive) for a subscription [default: 300] + * public-events:{True,False} - If True: QMF events are sent to the topic exchange [default] + * If False: QMF events are only sent to authorized subscribers */ QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); @@ -143,7 +148,7 @@ namespace qmf { * authReject - Reject/forbid an authorization request. * raiseException - indicate failure of an operation (i.e. query or method call). * response - Provide data in response to a query (only for option: external:True) - * complete - Indicate that the response to a query is complete (external:true only) + * complete - Indicate that the response to a query is complete (external:True only) * methodSuccess - Indicate the successful completion of a method call. */ QMF_EXTERN void authAccept(AgentEvent&); diff --git a/qpid/cpp/include/qmf/ConsoleEvent.h b/qpid/cpp/include/qmf/ConsoleEvent.h index 3e75631a61..54272334a4 100644 --- a/qpid/cpp/include/qmf/ConsoleEvent.h +++ b/qpid/cpp/include/qmf/ConsoleEvent.h @@ -46,8 +46,10 @@ namespace qmf { CONSOLE_QUERY_RESPONSE = 7, CONSOLE_METHOD_RESPONSE = 8, CONSOLE_EXCEPTION = 9, - CONSOLE_SUBSCRIBE_UPDATE = 10, - CONSOLE_THREAD_FAILED = 11 + CONSOLE_SUBSCRIBE_ADD = 10, + CONSOLE_SUBSCRIBE_UPDATE = 11, + CONSOLE_SUBSCRIBE_DEL = 12, + CONSOLE_THREAD_FAILED = 13 }; enum AgentDelReason { diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index c17f4510f1..ba8b3de92f 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -24,6 +24,7 @@ #include #include "qmf/Handle.h" #include "qmf/Agent.h" +#include "qmf/Subscription.h" #include "qpid/messaging/Duration.h" #include "qpid/messaging/Connection.h" #include @@ -67,6 +68,16 @@ namespace qmf { QMF_EXTERN Agent getAgent(uint32_t) const; QMF_EXTERN Agent getConnectedBrokerAgent() const; + /** + * Create a subscription that involves a subset of the known agents. The set of known agents is defined by + * the session's agent-filter (see setAgentFilter). The agentFilter argument to the subscribe method is used + * to further refine the set of agents. If agentFilter is the empty string (i.e. match-all) the subscription + * will involve all known agents. If agentFilter is non-empty, it will be applied only to the set of known + * agents. A subscription cannot be created that involves an agent not known by the session. + */ + QMF_EXTERN Subscription subscribe(const Query&, const std::string& agentFilter = "", const std::string& options = ""); + QMF_EXTERN Subscription subscribe(const std::string&, const std::string& agentFilter = "", const std::string& options = ""); + #ifndef SWIG private: friend class qmf::PrivateImplRef; diff --git a/qpid/cpp/include/qmf/Data.h b/qpid/cpp/include/qmf/Data.h index 27af1c4b04..82f1569a0b 100644 --- a/qpid/cpp/include/qmf/Data.h +++ b/qpid/cpp/include/qmf/Data.h @@ -34,6 +34,7 @@ namespace qmf { #endif class DataImpl; + class Schema; class SchemaId; class DataAddr; class Agent; @@ -45,8 +46,7 @@ namespace qmf { QMF_EXTERN Data& operator=(const Data&); QMF_EXTERN ~Data(); - QMF_EXTERN Data(const SchemaId&); - QMF_EXTERN void setSchema(const SchemaId&); + QMF_EXTERN Data(const Schema&); QMF_EXTERN void setAddr(const DataAddr&); QMF_EXTERN void setProperty(const std::string&, const qpid::types::Variant&); QMF_EXTERN void overwriteProperties(const qpid::types::Variant::Map&); diff --git a/qpid/cpp/include/qmf/Subscription.h b/qpid/cpp/include/qmf/Subscription.h new file mode 100644 index 0000000000..4e60eb984e --- /dev/null +++ b/qpid/cpp/include/qmf/Subscription.h @@ -0,0 +1,82 @@ +#ifndef QMF_SUBSCRIPTION_H +#define QMF_SUBSCRIPTION_H +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include +#include "qmf/Handle.h" +#include "qpid/types/Variant.h" +#include + +namespace qmf { + +#ifndef SWIG + template class PrivateImplRef; +#endif + + class SubscriptionImpl; + class Data; + + class Subscription : public qmf::Handle { + public: + QMF_EXTERN Subscription(SubscriptionImpl* impl = 0); + QMF_EXTERN Subscription(const Subscription&); + QMF_EXTERN Subscription& operator=(const Subscription&); + QMF_EXTERN ~Subscription(); + + /** + * Construction: A subscription is created by calling ConsoleSession::subscribe. + */ + + /** + * Cancel subscriptions to all subscribed agents. After this is called, the subscription + * shall be inactive. + */ + QMF_EXTERN void cancel(); + + /** + * Check to see if this subscription is active. It is active if it has a live subscription + * on at least one agent. If it is not active, there is nothing that can be done to make it + * active, it can only be deleted. + */ + QMF_EXTERN bool isActive() const; + + /** + * lock and unlock should be used to bracket a traversal of the data set. After lock is called, + * the subscription will not change its set of available data objects. Between calls to getDataCount + * and getData, no data objects will be added or removed. After unlock is called, the set of data + * will catch up to any activity that occurred while the lock was in effect. + */ + QMF_EXTERN void lock(); + QMF_EXTERN void unlock(); + QMF_EXTERN uint32_t getDataCount() const; + QMF_EXTERN Data getData(uint32_t) const; + +#ifndef SWIG + private: + friend class qmf::PrivateImplRef; + friend class SubscriptionImplAccess; +#endif + }; + +} + +#endif -- cgit v1.2.1 From 8850626ab31ff00e0eca619fda60a72775005eaa Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 11 Jan 2011 16:02:23 +0000 Subject: QMFv2 API change: 1) Added public constructor for DataAddr(Variant::Map) 2) Fixed Python and Ruby typemaps to support Variant::Map& and Variant::List& with const 3) Added support for building Queries based on object-id maps in both Python and Ruby wrappers git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1057709 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/DataAddr.h | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/DataAddr.h b/qpid/cpp/include/qmf/DataAddr.h index fd8a8599c1..72de0c986a 100644 --- a/qpid/cpp/include/qmf/DataAddr.h +++ b/qpid/cpp/include/qmf/DataAddr.h @@ -44,6 +44,7 @@ namespace qmf { QMF_EXTERN bool operator==(const DataAddr&); QMF_EXTERN bool operator<(const DataAddr&); + QMF_EXTERN DataAddr(const qpid::types::Variant::Map&); QMF_EXTERN DataAddr(const std::string& name, const std::string& agentName, uint32_t agentEpoch=0); QMF_EXTERN const std::string& getName() const; QMF_EXTERN const std::string& getAgentName() const; -- cgit v1.2.1 From 1e77b7bcf6766afbf161137284edbf2a6a255447 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 2 Feb 2011 18:16:57 +0000 Subject: QPID-3032 - Modifications to the QMFv2 implementation: 1) Use the topic exchange as the base for direct and reply-to addresses. 2) Add a strict-security option to the Console and Agent APIs that narrows the messaging patterns used such that they can easily be controlled by broker ACL policy. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1066562 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/AgentSession.h | 4 ++++ qpid/cpp/include/qmf/ConsoleSession.h | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 090017779f..23058c56c6 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -67,6 +67,10 @@ namespace qmf { * sub-lifetime:N - Lifetime (in seconds with no keepalive) for a subscription [default: 300] * public-events:{True,False} - If True: QMF events are sent to the topic exchange [default] * If False: QMF events are only sent to authorized subscribers + * listen-on-direct:{True,False} - If True: Listen on legacy direct-exchange address for backward compatibility [default] + * If False: Listen only on the routable direct address + * strict-security:{True,False} - If True: Cooperate with the broker to enforce string access control to the network + * - If False: Operate more flexibly with regard to use of messaging facilities [default] */ QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index ba8b3de92f..2422383fa3 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -57,6 +57,10 @@ namespace qmf { * domain:NAME - QMF Domain to join [default: "default"] * max-agent-age:N - Maximum time, in minutes, that we will tolerate not hearing from * an agent before deleting it [default: 5] + * listen-on-direct:{True,False} - If True: Listen on legacy direct-exchange address for backward compatibility [default] + * If False: Listen only on the routable direct address + * strict-security:{True,False} - If True: Cooperate with the broker to enforce string access control to the network + * - If False: Operate more flexibly with regard to use of messaging facilities [default] */ QMF_EXTERN ConsoleSession(qpid::messaging::Connection&, const std::string& options=""); QMF_EXTERN void setDomain(const std::string&); -- cgit v1.2.1 From bc413d94f96b787f1a5f20f15100545a138cf62f Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 3 Feb 2011 02:46:01 +0000 Subject: Added severity and timestamp fields to raised events. Enhanced the example agent to illustrate the raising of events. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1066726 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/AgentSession.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 23058c56c6..d6ac5adf83 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -165,8 +165,14 @@ namespace qmf { /** * Raise an event to be sent into the QMF network. + * + * @param data - A data object that contains the event contents. + * @param severity - Explicit severity (from qmf/SchemaTypes.h). If omitted, the severity is set to + * the default severity for the data's schema. If the data has no schema, the severity defaults + * to SEV_NOTICE. */ - QMF_EXTERN void raiseEvent(const Data&); + QMF_EXTERN void raiseEvent(const Data& data); + QMF_EXTERN void raiseEvent(const Data& data, int severity); #ifndef SWIG private: -- cgit v1.2.1 From eaa84eeb11e11c41da59844675b13ef1a7aaf198 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 4 Feb 2011 05:19:43 +0000 Subject: Fixed typos in the documentation text. Fixed bug in the propagation of exceptions in query-processing. Added user-id to messages sent by the console. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1067087 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/AgentSession.h | 2 +- qpid/cpp/include/qmf/ConsoleSession.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index d6ac5adf83..9e29d6b54b 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -69,7 +69,7 @@ namespace qmf { * If False: QMF events are only sent to authorized subscribers * listen-on-direct:{True,False} - If True: Listen on legacy direct-exchange address for backward compatibility [default] * If False: Listen only on the routable direct address - * strict-security:{True,False} - If True: Cooperate with the broker to enforce string access control to the network + * 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] */ QMF_EXTERN AgentSession(qpid::messaging::Connection&, const std::string& options=""); diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index 2422383fa3..0c73e7a6db 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -59,7 +59,7 @@ namespace qmf { * an agent before deleting it [default: 5] * listen-on-direct:{True,False} - If True: Listen on legacy direct-exchange address for backward compatibility [default] * If False: Listen only on the routable direct address - * strict-security:{True,False} - If True: Cooperate with the broker to enforce string access control to the network + * 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] */ QMF_EXTERN ConsoleSession(qpid::messaging::Connection&, const std::string& options=""); -- cgit v1.2.1 From 6b455d864349e7b90369fd424051210599fc9565 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Fri, 4 Feb 2011 08:22:30 +0000 Subject: Added missing even handling in the console. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1067111 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/ConsoleEvent.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/ConsoleEvent.h b/qpid/cpp/include/qmf/ConsoleEvent.h index 54272334a4..b836b629af 100644 --- a/qpid/cpp/include/qmf/ConsoleEvent.h +++ b/qpid/cpp/include/qmf/ConsoleEvent.h @@ -74,6 +74,8 @@ namespace qmf { QMF_EXTERN Data getData(uint32_t) const; QMF_EXTERN bool isFinal() const; QMF_EXTERN const qpid::types::Variant::Map& getArguments() const; + QMF_EXTERN int getSeverity() const; + QMF_EXTERN uint64_t getTimestamp() const; #ifndef SWIG private: -- cgit v1.2.1 From 5edf77f2c04c8428117a04d1d1a4b4cfc1770072 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Thu, 3 Mar 2011 13:55:11 +0000 Subject: QPID-3046 - Updates - Additional header comments - Added pendingEvents method to ConsoleSession and AgentSession - Ensure that nextEvent will not block if timeout is IMMEDIATE (ConsoleSession and AgentSession). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1076625 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/AgentSession.h | 40 ++++++++++++++++------------- qpid/cpp/include/qmf/ConsoleSession.h | 48 ++++++++++++++++++++++++++++++----- 2 files changed, 64 insertions(+), 24 deletions(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 9e29d6b54b..39d921a8ec 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -72,14 +72,14 @@ namespace qmf { * 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] */ - 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 +88,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 +119,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 +144,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 +161,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. diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index 0c73e7a6db..896f8ffda7 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -62,14 +62,48 @@ namespace qmf { * 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] */ - 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 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 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,8 +113,8 @@ 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: -- cgit v1.2.1 From 36228697da7e1288b2ab808346710fa4228d9b06 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Mon, 9 May 2011 19:55:29 +0000 Subject: QPID-3004: Get Clang to compile qpid c++ - Change class/struct declarations to be consistent with the definition to avoid warnings git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1101178 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Query.h | 2 +- qpid/cpp/include/qmf/Subscription.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/Query.h b/qpid/cpp/include/qmf/Query.h index fec4660bd7..1867b59d81 100644 --- a/qpid/cpp/include/qmf/Query.h +++ b/qpid/cpp/include/qmf/Query.h @@ -65,7 +65,7 @@ namespace qmf { #ifndef SWIG private: friend class qmf::PrivateImplRef; - friend class QueryImplAccess; + friend struct QueryImplAccess; #endif }; diff --git a/qpid/cpp/include/qmf/Subscription.h b/qpid/cpp/include/qmf/Subscription.h index 4e60eb984e..0a01b7c526 100644 --- a/qpid/cpp/include/qmf/Subscription.h +++ b/qpid/cpp/include/qmf/Subscription.h @@ -73,7 +73,7 @@ namespace qmf { #ifndef SWIG private: friend class qmf::PrivateImplRef; - friend class SubscriptionImplAccess; + friend struct SubscriptionImplAccess; #endif }; -- cgit v1.2.1 From 2d0338895a2d3629b674f4a3aabea58c77f76504 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Tue, 17 May 2011 21:02:34 +0000 Subject: QPID-3186 - Import Export generalization to support a larger set of compilers and run time environments git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1104559 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qmf/Agent.h | 2 +- qpid/cpp/include/qmf/AgentEvent.h | 2 +- qpid/cpp/include/qmf/AgentSession.h | 2 +- qpid/cpp/include/qmf/ConsoleEvent.h | 2 +- qpid/cpp/include/qmf/ConsoleSession.h | 2 +- qpid/cpp/include/qmf/Data.h | 2 +- qpid/cpp/include/qmf/DataAddr.h | 2 +- qpid/cpp/include/qmf/Handle.h | 10 +++++----- qpid/cpp/include/qmf/ImportExport.h | 16 +++++++++------- qpid/cpp/include/qmf/Query.h | 2 +- qpid/cpp/include/qmf/Schema.h | 2 +- qpid/cpp/include/qmf/SchemaId.h | 2 +- qpid/cpp/include/qmf/SchemaMethod.h | 2 +- qpid/cpp/include/qmf/SchemaProperty.h | 2 +- qpid/cpp/include/qmf/Subscription.h | 2 +- qpid/cpp/include/qmf/engine/QmfEngineImportExport.h | 9 +++++++++ qpid/cpp/include/qmf/exceptions.h | 8 ++++---- 17 files changed, 40 insertions(+), 29 deletions(-) (limited to 'qpid/cpp/include/qmf') diff --git a/qpid/cpp/include/qmf/Agent.h b/qpid/cpp/include/qmf/Agent.h index 8c0f48b8b1..94083be4f3 100644 --- a/qpid/cpp/include/qmf/Agent.h +++ b/qpid/cpp/include/qmf/Agent.h @@ -42,7 +42,7 @@ namespace qmf { class SchemaId; class Schema; - class Agent : public qmf::Handle { + class QMF_CLASS_EXTERN Agent : public qmf::Handle { public: QMF_EXTERN Agent(AgentImpl* impl = 0); QMF_EXTERN Agent(const Agent&); diff --git a/qpid/cpp/include/qmf/AgentEvent.h b/qpid/cpp/include/qmf/AgentEvent.h index 59a41c3267..0f93a9bb0a 100644 --- a/qpid/cpp/include/qmf/AgentEvent.h +++ b/qpid/cpp/include/qmf/AgentEvent.h @@ -46,7 +46,7 @@ namespace qmf { AGENT_THREAD_FAILED = 8 }; - class AgentEvent : public qmf::Handle { + class QMF_CLASS_EXTERN AgentEvent : public qmf::Handle { public: QMF_EXTERN AgentEvent(AgentEventImpl* impl = 0); QMF_EXTERN AgentEvent(const AgentEvent&); diff --git a/qpid/cpp/include/qmf/AgentSession.h b/qpid/cpp/include/qmf/AgentSession.h index 39d921a8ec..1eeb252143 100644 --- a/qpid/cpp/include/qmf/AgentSession.h +++ b/qpid/cpp/include/qmf/AgentSession.h @@ -40,7 +40,7 @@ namespace qmf { class Data; class DataAddr; - class AgentSession : public qmf::Handle { + class QMF_CLASS_EXTERN AgentSession : public qmf::Handle { public: QMF_EXTERN AgentSession(AgentSessionImpl* impl = 0); QMF_EXTERN AgentSession(const AgentSession&); diff --git a/qpid/cpp/include/qmf/ConsoleEvent.h b/qpid/cpp/include/qmf/ConsoleEvent.h index b836b629af..94600f9357 100644 --- a/qpid/cpp/include/qmf/ConsoleEvent.h +++ b/qpid/cpp/include/qmf/ConsoleEvent.h @@ -57,7 +57,7 @@ namespace qmf { AGENT_DEL_FILTER = 2 }; - class ConsoleEvent : public qmf::Handle { + class QMF_CLASS_EXTERN ConsoleEvent : public qmf::Handle { public: QMF_EXTERN ConsoleEvent(ConsoleEventImpl* impl = 0); QMF_EXTERN ConsoleEvent(const ConsoleEvent&); diff --git a/qpid/cpp/include/qmf/ConsoleSession.h b/qpid/cpp/include/qmf/ConsoleSession.h index 896f8ffda7..6008036eec 100644 --- a/qpid/cpp/include/qmf/ConsoleSession.h +++ b/qpid/cpp/include/qmf/ConsoleSession.h @@ -38,7 +38,7 @@ namespace qmf { class ConsoleSessionImpl; class ConsoleEvent; - class ConsoleSession : public qmf::Handle { + class QMF_CLASS_EXTERN ConsoleSession : public qmf::Handle { public: QMF_EXTERN ConsoleSession(ConsoleSessionImpl* impl = 0); QMF_EXTERN ConsoleSession(const ConsoleSession&); diff --git a/qpid/cpp/include/qmf/Data.h b/qpid/cpp/include/qmf/Data.h index 82f1569a0b..487a02fe95 100644 --- a/qpid/cpp/include/qmf/Data.h +++ b/qpid/cpp/include/qmf/Data.h @@ -39,7 +39,7 @@ namespace qmf { class DataAddr; class Agent; - class Data : public qmf::Handle { + class QMF_CLASS_EXTERN Data : public qmf::Handle { public: QMF_EXTERN Data(DataImpl* impl = 0); QMF_EXTERN Data(const Data&); diff --git a/qpid/cpp/include/qmf/DataAddr.h b/qpid/cpp/include/qmf/DataAddr.h index 72de0c986a..63d309cc4b 100644 --- a/qpid/cpp/include/qmf/DataAddr.h +++ b/qpid/cpp/include/qmf/DataAddr.h @@ -34,7 +34,7 @@ namespace qmf { class DataAddrImpl; - class DataAddr : public qmf::Handle { + class QMF_CLASS_EXTERN DataAddr : public qmf::Handle { public: QMF_EXTERN DataAddr(DataAddrImpl* impl = 0); QMF_EXTERN DataAddr(const DataAddr&); diff --git a/qpid/cpp/include/qmf/Handle.h b/qpid/cpp/include/qmf/Handle.h index 510e2993aa..50971ea626 100644 --- a/qpid/cpp/include/qmf/Handle.h +++ b/qpid/cpp/include/qmf/Handle.h @@ -39,22 +39,22 @@ template 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& 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/qpid/cpp/include/qmf/ImportExport.h b/qpid/cpp/include/qmf/ImportExport.h index f5e1d9127c..7405c15259 100644 --- a/qpid/cpp/include/qmf/ImportExport.h +++ b/qpid/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/qpid/cpp/include/qmf/Query.h b/qpid/cpp/include/qmf/Query.h index 1867b59d81..c1264f8901 100644 --- a/qpid/cpp/include/qmf/Query.h +++ b/qpid/cpp/include/qmf/Query.h @@ -43,7 +43,7 @@ namespace qmf { QUERY_SCHEMA_ID = 4 }; - class Query : public qmf::Handle { + class QMF_CLASS_EXTERN Query : public qmf::Handle { public: QMF_EXTERN Query(QueryImpl* impl = 0); QMF_EXTERN Query(const Query&); diff --git a/qpid/cpp/include/qmf/Schema.h b/qpid/cpp/include/qmf/Schema.h index cf316138c1..6cfd2e2a56 100644 --- a/qpid/cpp/include/qmf/Schema.h +++ b/qpid/cpp/include/qmf/Schema.h @@ -38,7 +38,7 @@ namespace qmf { class SchemaProperty; class SchemaMethod; - class Schema : public qmf::Handle { + class QMF_CLASS_EXTERN Schema : public qmf::Handle { public: QMF_EXTERN Schema(SchemaImpl* impl = 0); QMF_EXTERN Schema(const Schema&); diff --git a/qpid/cpp/include/qmf/SchemaId.h b/qpid/cpp/include/qmf/SchemaId.h index 13fb1cb902..2dafc1c091 100644 --- a/qpid/cpp/include/qmf/SchemaId.h +++ b/qpid/cpp/include/qmf/SchemaId.h @@ -35,7 +35,7 @@ namespace qmf { class SchemaIdImpl; - class SchemaId : public qmf::Handle { + class QMF_CLASS_EXTERN SchemaId : public qmf::Handle { public: QMF_EXTERN SchemaId(SchemaIdImpl* impl = 0); QMF_EXTERN SchemaId(const SchemaId&); diff --git a/qpid/cpp/include/qmf/SchemaMethod.h b/qpid/cpp/include/qmf/SchemaMethod.h index 47302b62b9..b5944dc29e 100644 --- a/qpid/cpp/include/qmf/SchemaMethod.h +++ b/qpid/cpp/include/qmf/SchemaMethod.h @@ -36,7 +36,7 @@ namespace qmf { class SchemaMethodImpl; class SchemaProperty; - class SchemaMethod : public qmf::Handle { + class QMF_CLASS_EXTERN SchemaMethod : public qmf::Handle { public: QMF_EXTERN SchemaMethod(SchemaMethodImpl* impl = 0); QMF_EXTERN SchemaMethod(const SchemaMethod&); diff --git a/qpid/cpp/include/qmf/SchemaProperty.h b/qpid/cpp/include/qmf/SchemaProperty.h index a3a328b60b..bbb603fa50 100644 --- a/qpid/cpp/include/qmf/SchemaProperty.h +++ b/qpid/cpp/include/qmf/SchemaProperty.h @@ -36,7 +36,7 @@ namespace qmf { class SchemaPropertyImpl; - class SchemaProperty : public Handle { + class QMF_CLASS_EXTERN SchemaProperty : public Handle { public: QMF_EXTERN SchemaProperty(SchemaPropertyImpl* impl = 0); QMF_EXTERN SchemaProperty(const SchemaProperty&); diff --git a/qpid/cpp/include/qmf/Subscription.h b/qpid/cpp/include/qmf/Subscription.h index 0a01b7c526..398a45b922 100644 --- a/qpid/cpp/include/qmf/Subscription.h +++ b/qpid/cpp/include/qmf/Subscription.h @@ -35,7 +35,7 @@ namespace qmf { class SubscriptionImpl; class Data; - class Subscription : public qmf::Handle { + class QMF_CLASS_EXTERN Subscription : public qmf::Handle { public: QMF_EXTERN Subscription(SubscriptionImpl* impl = 0); QMF_EXTERN Subscription(const Subscription&); diff --git a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h b/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h index 373617e046..cf8fffdb17 100644 --- a/qpid/cpp/include/qmf/engine/QmfEngineImportExport.h +++ b/qpid/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/qpid/cpp/include/qmf/exceptions.h b/qpid/cpp/include/qmf/exceptions.h index 7959499d63..c7ffa68ce2 100644 --- a/qpid/cpp/include/qmf/exceptions.h +++ b/qpid/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(); }; -- cgit v1.2.1