You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2010/08/13 00:28:11 UTC
svn commit: r985016 [1/3] - in /qpid/trunk/qpid/cpp: include/qmf/ src/
src/qmf/
Author: tross
Date: Thu Aug 12 22:28:09 2010
New Revision: 985016
URL: http://svn.apache.org/viewvc?rev=985016&view=rev
Log:
QPID-2792 - QMF Clients in C++ following the ABI-stable pattern of the new messaging API
Added:
qpid/trunk/qpid/cpp/include/qmf/Agent.h
qpid/trunk/qpid/cpp/include/qmf/AgentEvent.h
qpid/trunk/qpid/cpp/include/qmf/AgentSession.h
qpid/trunk/qpid/cpp/include/qmf/ConsoleEvent.h
qpid/trunk/qpid/cpp/include/qmf/ConsoleSession.h
qpid/trunk/qpid/cpp/include/qmf/Data.h
qpid/trunk/qpid/cpp/include/qmf/DataAddr.h
qpid/trunk/qpid/cpp/include/qmf/Handle.h
qpid/trunk/qpid/cpp/include/qmf/ImportExport.h
qpid/trunk/qpid/cpp/include/qmf/Query.h
qpid/trunk/qpid/cpp/include/qmf/Schema.h
qpid/trunk/qpid/cpp/include/qmf/SchemaId.h
qpid/trunk/qpid/cpp/include/qmf/SchemaMethod.h
qpid/trunk/qpid/cpp/include/qmf/SchemaProperty.h
qpid/trunk/qpid/cpp/include/qmf/SchemaTypes.h
qpid/trunk/qpid/cpp/include/qmf/exceptions.h
qpid/trunk/qpid/cpp/src/qmf/Agent.cpp
qpid/trunk/qpid/cpp/src/qmf/AgentEvent.cpp
qpid/trunk/qpid/cpp/src/qmf/AgentEventImpl.h
qpid/trunk/qpid/cpp/src/qmf/AgentImpl.h
qpid/trunk/qpid/cpp/src/qmf/AgentSession.cpp
qpid/trunk/qpid/cpp/src/qmf/ConsoleEvent.cpp
qpid/trunk/qpid/cpp/src/qmf/ConsoleEventImpl.h
qpid/trunk/qpid/cpp/src/qmf/ConsoleSession.cpp
qpid/trunk/qpid/cpp/src/qmf/ConsoleSessionImpl.h
qpid/trunk/qpid/cpp/src/qmf/Data.cpp
qpid/trunk/qpid/cpp/src/qmf/DataAddr.cpp
qpid/trunk/qpid/cpp/src/qmf/DataAddrImpl.h
qpid/trunk/qpid/cpp/src/qmf/DataImpl.h
qpid/trunk/qpid/cpp/src/qmf/Hash.cpp
qpid/trunk/qpid/cpp/src/qmf/Hash.h
qpid/trunk/qpid/cpp/src/qmf/PrivateImplRef.h
qpid/trunk/qpid/cpp/src/qmf/Query.cpp
qpid/trunk/qpid/cpp/src/qmf/Schema.cpp
qpid/trunk/qpid/cpp/src/qmf/SchemaCache.cpp
qpid/trunk/qpid/cpp/src/qmf/SchemaCache.h
qpid/trunk/qpid/cpp/src/qmf/SchemaId.cpp
qpid/trunk/qpid/cpp/src/qmf/SchemaIdImpl.h
qpid/trunk/qpid/cpp/src/qmf/SchemaImpl.h
qpid/trunk/qpid/cpp/src/qmf/SchemaMethod.cpp
qpid/trunk/qpid/cpp/src/qmf/SchemaMethodImpl.h
qpid/trunk/qpid/cpp/src/qmf/SchemaProperty.cpp
qpid/trunk/qpid/cpp/src/qmf/SchemaPropertyImpl.h
qpid/trunk/qpid/cpp/src/qmf/exceptions.cpp
Modified:
qpid/trunk/qpid/cpp/src/qmf.mk
Added: qpid/trunk/qpid/cpp/include/qmf/Agent.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/Agent.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/Agent.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/Agent.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qmf/Handle.h"
+#include "qmf/exceptions.h"
+#include "qpid/messaging/Duration.h"
+#include "qpid/types/Variant.h"
+#include <string>
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> class PrivateImplRef;
+#endif
+
+ class AgentImpl;
+ class ConsoleEvent;
+ class Query;
+ class DataAddr;
+ class SchemaId;
+ class Schema;
+
+ class Agent : public qmf::Handle<AgentImpl> {
+ 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<Agent>;
+ friend struct AgentImplAccess;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/AgentEvent.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/AgentEvent.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/AgentEvent.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/AgentEvent.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qmf/Handle.h"
+#include "qpid/types/Variant.h"
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> 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<AgentEventImpl> {
+ 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<AgentEvent>;
+ friend struct AgentEventImplAccess;
+#endif
+ };
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/AgentSession.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/AgentSession.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/AgentSession.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/AgentSession.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qmf/Handle.h"
+#include "qpid/messaging/Duration.h"
+#include "qpid/messaging/Connection.h"
+#include "qpid/types/Variant.h"
+#include <string>
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> class PrivateImplRef;
+#endif
+
+ class AgentSessionImpl;
+ class AgentEvent;
+ class Schema;
+ class Data;
+ class DataAddr;
+
+ class AgentSession : public qmf::Handle<AgentSessionImpl> {
+ 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<AgentSession>;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/ConsoleEvent.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/ConsoleEvent.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/ConsoleEvent.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/ConsoleEvent.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qmf/Handle.h"
+#include "qpid/types/Variant.h"
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> 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<ConsoleEventImpl> {
+ 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<ConsoleEvent>;
+ friend struct ConsoleEventImplAccess;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/ConsoleSession.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/ConsoleSession.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/ConsoleSession.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/ConsoleSession.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qmf/Handle.h"
+#include "qmf/Agent.h"
+#include "qpid/messaging/Duration.h"
+#include "qpid/messaging/Connection.h"
+#include <string>
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> class PrivateImplRef;
+#endif
+
+ class ConsoleSessionImpl;
+ class ConsoleEvent;
+
+ class ConsoleSession : public qmf::Handle<ConsoleSessionImpl> {
+ 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<ConsoleSession>;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/Data.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/Data.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/Data.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/Data.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qmf/Handle.h"
+#include "qmf/exceptions.h"
+#include "qpid/types/Variant.h"
+#include <string>
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> class PrivateImplRef;
+#endif
+
+ class DataImpl;
+ class SchemaId;
+ class DataAddr;
+ class Agent;
+
+ class Data : public qmf::Handle<DataImpl> {
+ 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<Data>;
+ friend struct DataImplAccess;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/DataAddr.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/DataAddr.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/DataAddr.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/DataAddr.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qmf/Handle.h"
+#include "qpid/types/Variant.h"
+#include <string>
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> class PrivateImplRef;
+#endif
+
+ class DataAddrImpl;
+
+ class DataAddr : public qmf::Handle<DataAddrImpl> {
+ 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<DataAddr>;
+ friend struct DataAddrImplAccess;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/Handle.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/Handle.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/Handle.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/Handle.h Thu Aug 12 22:28:09 2010
@@ -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> 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 T> 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<T>& 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<T>;
+};
+
+} // namespace qmf
+
+#endif /*!QMF_HANDLE_H*/
Added: qpid/trunk/qpid/cpp/include/qmf/ImportExport.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/ImportExport.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/ImportExport.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/ImportExport.h Thu Aug 12 22:28:09 2010
@@ -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
Added: qpid/trunk/qpid/cpp/include/qmf/Query.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/Query.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/Query.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/Query.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qmf/Handle.h"
+#include "qpid/types/Variant.h"
+#include <string>
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> class PrivateImplRef;
+#endif
+
+ class QueryImpl;
+ class SchemaId;
+ class DataAddr;
+
+ class Query : public qmf::Handle<QueryImpl> {
+ 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<Query>;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/Schema.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/Schema.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/Schema.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/Schema.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qpid/sys/IntegerTypes.h"
+#include "qmf/Handle.h"
+#include "qmf/SchemaTypes.h"
+#include <string>
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> class PrivateImplRef;
+#endif
+
+ class SchemaImpl;
+ class SchemaId;
+ class SchemaProperty;
+ class SchemaMethod;
+
+ class Schema : public qmf::Handle<SchemaImpl> {
+ 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<Schema>;
+ friend struct SchemaImplAccess;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/SchemaId.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/SchemaId.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/SchemaId.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/SchemaId.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qmf/Handle.h"
+#include "qpid/types/Uuid.h"
+#include "qmf/SchemaTypes.h"
+#include <string>
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> class PrivateImplRef;
+#endif
+
+ class SchemaIdImpl;
+
+ class SchemaId : public qmf::Handle<SchemaIdImpl> {
+ 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<SchemaId>;
+ friend struct SchemaIdImplAccess;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/SchemaMethod.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/SchemaMethod.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/SchemaMethod.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/SchemaMethod.h Thu Aug 12 22:28:09 2010
@@ -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 <string>
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> class PrivateImplRef;
+#endif
+
+ class SchemaMethodImpl;
+ class SchemaProperty;
+
+ class SchemaMethod : public qmf::Handle<SchemaMethodImpl> {
+ 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<SchemaMethod>;
+ friend struct SchemaMethodImplAccess;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/SchemaProperty.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/SchemaProperty.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/SchemaProperty.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/SchemaProperty.h Thu Aug 12 22:28:09 2010
@@ -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 <qmf/ImportExport.h>
+#include "qmf/Handle.h"
+#include "qpid/types/Uuid.h"
+#include "qpid/types/Variant.h"
+#include "qmf/SchemaTypes.h"
+#include <string>
+
+namespace qmf {
+
+#ifndef SWIG
+ template <class> class PrivateImplRef;
+#endif
+
+ class SchemaPropertyImpl;
+
+ class SchemaProperty : public Handle<SchemaPropertyImpl> {
+ 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<SchemaProperty>;
+ friend struct SchemaPropertyImplAccess;
+#endif
+ };
+
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/include/qmf/SchemaTypes.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/SchemaTypes.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/SchemaTypes.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/SchemaTypes.h Thu Aug 12 22:28:09 2010
@@ -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
Added: qpid/trunk/qpid/cpp/include/qmf/exceptions.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qmf/exceptions.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/include/qmf/exceptions.h (added)
+++ qpid/trunk/qpid/cpp/include/qmf/exceptions.h Thu Aug 12 22:28:09 2010
@@ -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
+
Modified: qpid/trunk/qpid/cpp/src/qmf.mk
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf.mk?rev=985016&r1=985015&r2=985016&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf.mk (original)
+++ qpid/trunk/qpid/cpp/src/qmf.mk Thu Aug 12 22:28:09 2010
@@ -22,7 +22,8 @@
#
lib_LTLIBRARIES += \
libqmf.la \
- libqmfengine.la
+ libqmfengine.la \
+ libqmf2.la
#
# Public headers for the QMF API
@@ -30,6 +31,29 @@ lib_LTLIBRARIES += \
QMF_API = \
../include/qpid/agent/ManagementAgent.h \
../include/qpid/agent/QmfAgentImportExport.h
+
+#
+# Public headers for the QMF2 API
+#
+QMF2_API = \
+ ../include/qmf/AgentEvent.h \
+ ../include/qmf/Agent.h \
+ ../include/qmf/AgentSession.h \
+ ../include/qmf/ConsoleEvent.h \
+ ../include/qmf/ConsoleSession.h \
+ ../include/qmf/DataAddr.h \
+ ../include/qmf/Data.h \
+ ../include/qmf/exceptions.h \
+ ../include/qmf/Handle.h \
+ ../include/qmf/ImportExport.h \
+ ../include/qmf/Query.h \
+ ../include/qmf/Schema.h \
+ ../include/qmf/SchemaId.h \
+ ../include/qmf/SchemaMethod.h \
+ ../include/qmf/SchemaProperty.h \
+ ../include/qmf/SchemaTypes.h
+
+
#
# Public headers for the QMF Engine API
#
@@ -51,13 +75,45 @@ QMF_ENGINE_API = \
# Public header files
nobase_include_HEADERS += \
$(QMF_API) \
- $(QMF_ENGINE_API)
+ $(QMF_ENGINE_API) \
+ $(QMF2_API)
libqmf_la_SOURCES = \
$(QMF_API) \
qpid/agent/ManagementAgentImpl.cpp \
qpid/agent/ManagementAgentImpl.h
+libqmf2_la_SOURCES = \
+ $(QMF2_API) \
+ qmf/Agent.cpp \
+ qmf/AgentEvent.cpp \
+ qmf/AgentEventImpl.h \
+ qmf/AgentImpl.h \
+ qmf/AgentSession.cpp \
+ qmf/ConsoleEvent.cpp \
+ qmf/ConsoleEventImpl.h \
+ qmf/ConsoleSession.cpp \
+ qmf/ConsoleSessionImpl.h \
+ qmf/DataAddr.cpp \
+ qmf/DataAddrImpl.h \
+ qmf/Data.cpp \
+ qmf/DataImpl.h \
+ qmf/exceptions.cpp \
+ qmf/Hash.cpp \
+ qmf/Hash.h \
+ qmf/PrivateImplRef.h \
+ qmf/Query.cpp \
+ qmf/Schema.cpp \
+ qmf/SchemaCache.cpp \
+ qmf/SchemaCache.h \
+ qmf/SchemaId.cpp \
+ qmf/SchemaIdImpl.h \
+ qmf/SchemaImpl.h \
+ qmf/SchemaMethod.cpp \
+ qmf/SchemaMethodImpl.h \
+ qmf/SchemaProperty.cpp \
+ qmf/SchemaPropertyImpl.h
+
libqmfengine_la_SOURCES = \
$(QMF_ENGINE_API) \
qmf/engine/Agent.cpp \
@@ -88,10 +144,13 @@ libqmfengine_la_SOURCES = \
qmf/engine/ValueImpl.h
libqmf_la_LIBADD = libqmfengine.la
+libqmf2_la_LIBADD = libqpidmessaging.la libqpidtypes.la
libqmfengine_la_LIBADD = libqpidclient.la
QMF_VERSION_INFO = 1:0:0
+QMF2_VERSION_INFO = 1:0:0
QMFENGINE_VERSION_INFO = 1:1:0
libqmf_la_LDFLAGS = -version-info $(QMF_VERSION_INFO)
+libqmf2_la_LDFLAGS = -version-info $(QMF2_VERSION_INFO)
libqmfengine_la_LDFLAGS = -version-info $(QMFENGINE_VERSION_INFO)
Added: qpid/trunk/qpid/cpp/src/qmf/Agent.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/Agent.cpp?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/Agent.cpp (added)
+++ qpid/trunk/qpid/cpp/src/qmf/Agent.cpp Thu Aug 12 22:28:09 2010
@@ -0,0 +1,578 @@
+/*
+ *
+ * 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/AgentImpl.h"
+#include "qmf/PrivateImplRef.h"
+#include "qmf/ConsoleEventImpl.h"
+#include "qmf/ConsoleSession.h"
+#include "qmf/DataImpl.h"
+#include "qmf/Query.h"
+#include "qpid/messaging/Sender.h"
+#include "qpid/messaging/AddressParser.h"
+#include "qpid/management/Buffer.h"
+#include "qpid/log/Statement.h"
+#include <boost/lexical_cast.hpp>
+
+using qpid::types::Variant;
+using qpid::messaging::Duration;
+using qpid::messaging::Message;
+using qpid::messaging::Sender;
+using namespace std;
+using namespace qmf;
+
+typedef PrivateImplRef<Agent> PI;
+
+Agent::Agent(AgentImpl* impl) { PI::ctor(*this, impl); }
+Agent::Agent(const Agent& s) : qmf::Handle<AgentImpl>() { PI::copy(*this, s); }
+Agent::~Agent() { PI::dtor(*this); }
+Agent& Agent::operator=(const Agent& s) { return PI::assign(*this, s); }
+string Agent::getName() const { return isValid() ? impl->getName() : ""; }
+uint32_t Agent::getEpoch() const { return isValid() ? impl->getEpoch() : 0; }
+string Agent::getVendor() const { return isValid() ? impl->getVendor() : ""; }
+string Agent::getProduct() const { return isValid() ? impl->getProduct() : ""; }
+string Agent::getInstance() const { return isValid() ? impl->getInstance() : ""; }
+const Variant& Agent::getAttribute(const string& k) const { return impl->getAttribute(k); }
+const Variant::Map& Agent::getAttributes() const { return impl->getAttributes(); }
+ConsoleEvent Agent::query(const Query& q, Duration t) { return impl->query(q, t); }
+ConsoleEvent Agent::query(const string& q, Duration t) { return impl->query(q, t); }
+uint32_t Agent::queryAsync(const Query& q) { return impl->queryAsync(q); }
+uint32_t Agent::queryAsync(const string& q) { return impl->queryAsync(q); }
+ConsoleEvent Agent::callMethod(const string& m, const Variant::Map& a, const DataAddr& d, Duration t) { return impl->callMethod(m, a, d, t); }
+uint32_t Agent::callMethodAsync(const string& m, const Variant::Map& a, const DataAddr& d) { return impl->callMethodAsync(m, a, d); }
+uint32_t Agent::getPackageCount() const { return impl->getPackageCount(); }
+const string& Agent::getPackage(uint32_t i) const { return impl->getPackage(i); }
+uint32_t Agent::getSchemaIdCount(const string& p) const { return impl->getSchemaIdCount(p); }
+SchemaId Agent::getSchemaId(const string& p, uint32_t i) const { return impl->getSchemaId(p, i); }
+Schema Agent::getSchema(const SchemaId& s, Duration t) { return impl->getSchema(s, t); }
+
+
+
+AgentImpl::AgentImpl(const std::string& n, uint32_t e, ConsoleSessionImpl& s) :
+ name(n), epoch(e), session(s), touched(true), untouchedCount(0),
+ nextCorrelator(1), schemaCache(s.schemaCache)
+{
+}
+
+const Variant& AgentImpl::getAttribute(const string& k) const
+{
+ Variant::Map::const_iterator iter = attributes.find(k);
+ if (iter == attributes.end())
+ throw KeyNotFound(k);
+ return iter->second;
+}
+
+ConsoleEvent AgentImpl::query(const Query& query, Duration timeout)
+{
+ boost::shared_ptr<SyncContext> context(new SyncContext());
+ uint32_t correlator;
+ ConsoleEvent result;
+
+ {
+ qpid::sys::Mutex::ScopedLock l(lock);
+ correlator = nextCorrelator++;
+ contextMap[correlator] = context;
+ }
+ try {
+ sendQuery(query, correlator);
+ {
+ uint64_t milliseconds = timeout.getMilliseconds();
+ qpid::sys::Mutex::ScopedLock cl(context->lock);
+ if (!context->response.isValid() || !context->response.isFinal())
+ context->cond.wait(context->lock,
+ qpid::sys::AbsTime(qpid::sys::now(),
+ qpid::sys::Duration(milliseconds * qpid::sys::TIME_MSEC)));
+ if (context->response.isValid() && context->response.isFinal())
+ result = context->response;
+ else {
+ auto_ptr<ConsoleEventImpl> impl(new ConsoleEventImpl(CONSOLE_EXCEPTION));
+ Data exception(new DataImpl());
+ exception.setProperty("error_text", "Timed out waiting for the agent to respond");
+ impl->addData(exception);
+ result = ConsoleEvent(impl.release());
+ }
+ }
+ } catch (qpid::types::Exception&) {
+ }
+
+ {
+ qpid::sys::Mutex::ScopedLock l(lock);
+ contextMap.erase(correlator);
+ }
+
+ return result;
+}
+
+
+ConsoleEvent AgentImpl::query(const string& text, Duration timeout)
+{
+ return query(stringToQuery(text), timeout);
+}
+
+
+uint32_t AgentImpl::queryAsync(const Query& query)
+{
+ uint32_t correlator;
+
+ {
+ qpid::sys::Mutex::ScopedLock l(lock);
+ correlator = nextCorrelator++;
+ }
+
+ sendQuery(query, correlator);
+ return correlator;
+}
+
+
+uint32_t AgentImpl::queryAsync(const string& text)
+{
+ return queryAsync(stringToQuery(text));
+}
+
+
+ConsoleEvent AgentImpl::callMethod(const string& method, const Variant::Map& args, const DataAddr& addr, Duration timeout)
+{
+ boost::shared_ptr<SyncContext> context(new SyncContext());
+ uint32_t correlator;
+ ConsoleEvent result;
+
+ {
+ qpid::sys::Mutex::ScopedLock l(lock);
+ correlator = nextCorrelator++;
+ contextMap[correlator] = context;
+ }
+ try {
+ sendMethod(method, args, addr, correlator);
+ {
+ uint64_t milliseconds = timeout.getMilliseconds();
+ qpid::sys::Mutex::ScopedLock cl(context->lock);
+ if (!context->response.isValid())
+ context->cond.wait(context->lock,
+ qpid::sys::AbsTime(qpid::sys::now(),
+ qpid::sys::Duration(milliseconds * qpid::sys::TIME_MSEC)));
+ if (context->response.isValid())
+ result = context->response;
+ else {
+ auto_ptr<ConsoleEventImpl> impl(new ConsoleEventImpl(CONSOLE_EXCEPTION));
+ Data exception(new DataImpl());
+ exception.setProperty("error_text", "Timed out waiting for the agent to respond");
+ impl->addData(exception);
+ result = ConsoleEvent(impl.release());
+ }
+ }
+ } catch (qpid::types::Exception&) {
+ }
+
+ {
+ qpid::sys::Mutex::ScopedLock l(lock);
+ contextMap.erase(correlator);
+ }
+
+ return result;
+}
+
+
+uint32_t AgentImpl::callMethodAsync(const string& method, const Variant::Map& args, const DataAddr& addr)
+{
+ uint32_t correlator;
+
+ {
+ qpid::sys::Mutex::ScopedLock l(lock);
+ correlator = nextCorrelator++;
+ }
+
+ sendMethod(method, args, addr, correlator);
+ return correlator;
+}
+
+
+uint32_t AgentImpl::getPackageCount() const
+{
+ qpid::sys::Mutex::ScopedLock l(lock);
+
+ //
+ // Populate the package set.
+ //
+ for (set<SchemaId>::const_iterator iter = schemaIdSet.begin(); iter != schemaIdSet.end(); iter++)
+ packageSet.insert(iter->getPackageName());
+
+ return packageSet.size();
+}
+
+
+const string& AgentImpl::getPackage(uint32_t idx) const
+{
+ qpid::sys::Mutex::ScopedLock l(lock);
+ uint32_t count(0);
+ for (set<string>::const_iterator iter = packageSet.begin(); iter != packageSet.end(); iter++) {
+ if (idx == count)
+ return *iter;
+ count++;
+ }
+ throw IndexOutOfRange();
+}
+
+
+uint32_t AgentImpl::getSchemaIdCount(const string& pname) const
+{
+ qpid::sys::Mutex::ScopedLock l(lock);
+ uint32_t count(0);
+ for (set<SchemaId>::const_iterator iter = schemaIdSet.begin(); iter != schemaIdSet.end(); iter++)
+ if (iter->getPackageName() == pname)
+ count++;
+ return count;
+}
+
+
+SchemaId AgentImpl::getSchemaId(const string& pname, uint32_t idx) const
+{
+ qpid::sys::Mutex::ScopedLock l(lock);
+ uint32_t count(0);
+ for (set<SchemaId>::const_iterator iter = schemaIdSet.begin(); iter != schemaIdSet.end(); iter++) {
+ if (iter->getPackageName() == pname) {
+ if (idx == count)
+ return *iter;
+ count++;
+ }
+ }
+ throw IndexOutOfRange();
+}
+
+
+Schema AgentImpl::getSchema(const SchemaId& id, Duration timeout)
+{
+ qpid::sys::Mutex::ScopedLock l(lock);
+ if (!schemaCache->haveSchema(id))
+ //
+ // The desired schema is not in the cache. We need to asynchronously query the remote
+ // agent for the information. The call to schemaCache->getSchema will block waiting for
+ // the response to be received.
+ //
+ sendSchemaRequest(id);
+
+ return schemaCache->getSchema(id, timeout);
+}
+
+
+void AgentImpl::handleException(const Variant::Map& content, const Message& msg)
+{
+ const string& cid(msg.getCorrelationId());
+ Variant::Map::const_iterator aIter;
+ uint32_t correlator;
+ boost::shared_ptr<SyncContext> context;
+
+ try { correlator = boost::lexical_cast<uint32_t>(cid); }
+ catch(const boost::bad_lexical_cast&) { correlator = 0; }
+
+ {
+ qpid::sys::Mutex::ScopedLock l(lock);
+ map<uint32_t, boost::shared_ptr<SyncContext> >::iterator iter = contextMap.find(correlator);
+ if (iter != contextMap.end())
+ context = iter->second;
+ }
+
+ if (context.get() != 0) {
+ //
+ // This exception is associated with a synchronous request.
+ //
+ qpid::sys::Mutex::ScopedLock cl(context->lock);
+ context->response = ConsoleEvent(new ConsoleEventImpl(CONSOLE_EXCEPTION));
+ ConsoleEventImplAccess::get(context->response).addData(new DataImpl(content, this));
+ ConsoleEventImplAccess::get(context->response).setAgent(this);
+ context->cond.notify();
+ } else {
+ //
+ // This exception is associated with an asynchronous request.
+ //
+ auto_ptr<ConsoleEventImpl> eventImpl(new ConsoleEventImpl(CONSOLE_EXCEPTION));
+ eventImpl->setCorrelator(correlator);
+ eventImpl->setAgent(this);
+ eventImpl->addData(new DataImpl(content, this));
+ session.enqueueEvent(eventImpl.release());
+ }
+}
+
+
+void AgentImpl::handleMethodResponse(const Variant::Map& response, const Message& msg)
+{
+ const string& cid(msg.getCorrelationId());
+ Variant::Map::const_iterator aIter;
+ Variant::Map argMap;
+ uint32_t correlator;
+ boost::shared_ptr<SyncContext> context;
+
+ QPID_LOG(trace, "RCVD MethodResponse map=" << response);
+
+ aIter = response.find("_arguments");
+ if (aIter != response.end())
+ argMap = aIter->second.asMap();
+
+ try { correlator = boost::lexical_cast<uint32_t>(cid); }
+ catch(const boost::bad_lexical_cast&) { correlator = 0; }
+
+ {
+ qpid::sys::Mutex::ScopedLock l(lock);
+ map<uint32_t, boost::shared_ptr<SyncContext> >::iterator iter = contextMap.find(correlator);
+ if (iter != contextMap.end())
+ context = iter->second;
+ }
+
+ if (context.get() != 0) {
+ //
+ // This response is associated with a synchronous request.
+ //
+ qpid::sys::Mutex::ScopedLock cl(context->lock);
+ context->response = ConsoleEvent(new ConsoleEventImpl(CONSOLE_METHOD_RESPONSE));
+ ConsoleEventImplAccess::get(context->response).setArguments(argMap);
+ ConsoleEventImplAccess::get(context->response).setAgent(this);
+ context->cond.notify();
+ } else {
+ //
+ // This response is associated with an asynchronous request.
+ //
+ auto_ptr<ConsoleEventImpl> eventImpl(new ConsoleEventImpl(CONSOLE_METHOD_RESPONSE));
+ eventImpl->setCorrelator(correlator);
+ eventImpl->setAgent(this);
+ eventImpl->setArguments(argMap);
+ session.enqueueEvent(eventImpl.release());
+ }
+}
+
+
+void AgentImpl::handleDataIndication(const Variant::List&, const Message&)
+{
+ // TODO
+}
+
+
+void AgentImpl::handleQueryResponse(const Variant::List& list, const Message& msg)
+{
+ const string& cid(msg.getCorrelationId());
+ Variant::Map::const_iterator aIter;
+ const Variant::Map& props(msg.getProperties());
+ uint32_t correlator;
+ bool final(false);
+ boost::shared_ptr<SyncContext> context;
+
+ aIter = props.find("partial");
+ if (aIter == props.end())
+ final = true;
+
+ try { correlator = boost::lexical_cast<uint32_t>(cid); }
+ catch(const boost::bad_lexical_cast&) { correlator = 0; }
+
+ {
+ qpid::sys::Mutex::ScopedLock l(lock);
+ map<uint32_t, boost::shared_ptr<SyncContext> >::iterator iter = contextMap.find(correlator);
+ if (iter != contextMap.end())
+ context = iter->second;
+ }
+
+ if (context.get() != 0) {
+ //
+ // This response is associated with a synchronous request.
+ //
+ qpid::sys::Mutex::ScopedLock cl(context->lock);
+ if (!context->response.isValid())
+ context->response = ConsoleEvent(new ConsoleEventImpl(CONSOLE_QUERY_RESPONSE));
+ for (Variant::List::const_iterator lIter = list.begin(); lIter != list.end(); lIter++) {
+ Data data(new DataImpl(lIter->asMap(), this));
+ ConsoleEventImplAccess::get(context->response).addData(data);
+ if (data.hasSchema())
+ learnSchemaId(data.getSchemaId());
+ }
+ if (final) {
+ ConsoleEventImplAccess::get(context->response).setFinal();
+ ConsoleEventImplAccess::get(context->response).setAgent(this);
+ context->cond.notify();
+ }
+ } else {
+ //
+ // This response is associated with an asynchronous request.
+ //
+ auto_ptr<ConsoleEventImpl> eventImpl(new ConsoleEventImpl(CONSOLE_QUERY_RESPONSE));
+ eventImpl->setCorrelator(correlator);
+ eventImpl->setAgent(this);
+ for (Variant::List::const_iterator lIter = list.begin(); lIter != list.end(); lIter++) {
+ Data data(new DataImpl(lIter->asMap(), this));
+ eventImpl->addData(data);
+ if (data.hasSchema())
+ learnSchemaId(data.getSchemaId());
+ }
+ if (final)
+ eventImpl->setFinal();
+ session.enqueueEvent(eventImpl.release());
+ }
+}
+
+
+Query AgentImpl::stringToQuery(const std::string& text)
+{
+ qpid::messaging::AddressParser parser(text);
+ Variant::Map map;
+ Variant::Map::const_iterator iter;
+ string className;
+ string packageName;
+
+ parser.parseMap(map);
+
+ iter = map.find("class");
+ if (iter != map.end())
+ className = iter->second.asString();
+
+ iter = map.find("package");
+ if (iter != map.end())
+ packageName = iter->second.asString();
+
+ Query query(className, packageName);
+
+ iter = map.find("where");
+ if (iter != map.end()) {
+ const Variant::Map& pred(iter->second.asMap());
+ for (iter = pred.begin(); iter != pred.end(); iter++)
+ query.addPredicate(iter->first, iter->second);
+ }
+
+ return query;
+}
+
+
+void AgentImpl::sendQuery(const Query& query, uint32_t correlator)
+{
+ Message msg;
+ Variant::Map map;
+ Variant::Map& headers(msg.getProperties());
+
+ headers["method"] = "request";
+ headers["qmf.opcode"] = "_query_request";
+ headers["x-amqp-0-10.app-id"] = "qmf2";
+
+ map["_what"] = "OBJECT";
+
+ const DataAddr& dataAddr(query.getDataAddr());
+ const SchemaId& schemaId(query.getSchemaId());
+
+ if (dataAddr.isValid())
+ map["_object_id"] = dataAddr.asMap();
+ else {
+ string className;
+ string packageName;
+ if (schemaId.isValid()) {
+ className = schemaId.getName();
+ packageName = schemaId.getPackageName();
+ } else {
+ className = query.getClassName();
+ if (className.empty())
+ throw QmfException("Invalid Query");
+ packageName = query.getPackageName();
+ }
+ Variant::Map idMap;
+ idMap["_class_name"] = className;
+ if (!packageName.empty())
+ idMap["_package_name"] = packageName;
+ map["_schema_id"] = idMap;
+ }
+
+ //
+ // TODO: Encode a simple-predicate if present.
+ //
+
+ msg.setReplyTo(session.replyAddress);
+ msg.setCorrelationId(boost::lexical_cast<string>(correlator));
+ encode(map, msg);
+ Sender sender(session.session.createSender(session.directBase + "/" + name));
+ sender.send(msg);
+ sender.close();
+
+ QPID_LOG(trace, "SENT QueryRequest to=" << name);
+}
+
+
+void AgentImpl::sendMethod(const string& method, const Variant::Map& args, const DataAddr& addr, uint32_t correlator)
+{
+ Message msg;
+ Variant::Map map;
+ Variant::Map& headers(msg.getProperties());
+
+ headers["method"] = "request";
+ headers["qmf.opcode"] = "_method_request";
+ headers["x-amqp-0-10.app-id"] = "qmf2";
+
+ map["_method_name"] = method;
+ map["_object_id"] = addr.asMap();
+ map["_arguments"] = args;
+
+ msg.setReplyTo(session.replyAddress);
+ msg.setCorrelationId(boost::lexical_cast<string>(correlator));
+ encode(map, msg);
+ Sender sender(session.session.createSender(session.directBase + "/" + name));
+ sender.send(msg);
+ sender.close();
+
+ QPID_LOG(trace, "SENT MethodRequest method=" << method << " to=" << name);
+}
+
+void AgentImpl::sendSchemaRequest(const SchemaId& id)
+{
+ // TODO: Check agent's capability value to determine which kind of schema request to make
+
+#define RAW_BUFFER_SIZE 1024
+ char rawBuffer[RAW_BUFFER_SIZE];
+ qpid::management::Buffer buffer(rawBuffer, RAW_BUFFER_SIZE);
+
+ buffer.putOctet('A');
+ buffer.putOctet('M');
+ buffer.putOctet('2');
+ buffer.putOctet('S');
+ buffer.putLong(nextCorrelator++);
+ buffer.putShortString(id.getPackageName());
+ buffer.putShortString(id.getName());
+ buffer.putBin128(id.getHash().data());
+
+ string content(rawBuffer, buffer.getPosition());
+
+ Message msg;
+ msg.setReplyTo(session.replyAddress);
+ msg.setContent(content);
+ Sender sender(session.session.createSender(session.directBase + "/" + name));
+ sender.send(msg);
+ sender.close();
+
+ QPID_LOG(trace, "SENT V1SchemaRequest to=" << name);
+}
+
+
+void AgentImpl::learnSchemaId(const SchemaId& id)
+{
+ schemaCache->declareSchemaId(id);
+ schemaIdSet.insert(id);
+}
+
+
+AgentImpl& AgentImplAccess::get(Agent& item)
+{
+ return *item.impl;
+}
+
+
+const AgentImpl& AgentImplAccess::get(const Agent& item)
+{
+ return *item.impl;
+}
Added: qpid/trunk/qpid/cpp/src/qmf/AgentEvent.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/AgentEvent.cpp?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/AgentEvent.cpp (added)
+++ qpid/trunk/qpid/cpp/src/qmf/AgentEvent.cpp Thu Aug 12 22:28:09 2010
@@ -0,0 +1,82 @@
+/*
+ *
+ * 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/AgentEventImpl.h"
+#include "qmf/PrivateImplRef.h"
+
+using namespace std;
+using namespace qmf;
+using qpid::types::Variant;
+
+typedef PrivateImplRef<AgentEvent> PI;
+
+AgentEvent::AgentEvent(AgentEventImpl* impl) { PI::ctor(*this, impl); }
+AgentEvent::AgentEvent(const AgentEvent& s) : qmf::Handle<AgentEventImpl>() { PI::copy(*this, s); }
+AgentEvent::~AgentEvent() { PI::dtor(*this); }
+AgentEvent& AgentEvent::operator=(const AgentEvent& s) { return PI::assign(*this, s); }
+
+AgentEventCode AgentEvent::getType() const { return impl->getType(); }
+const string& AgentEvent::getUserId() const { return impl->getUserId(); }
+Query AgentEvent::getQuery() const { return impl->getQuery(); }
+bool AgentEvent::hasDataAddr() const { return impl->hasDataAddr(); }
+DataAddr AgentEvent::getDataAddr() const { return impl->getDataAddr(); }
+const string& AgentEvent::getMethodName() const { return impl->getMethodName(); }
+qpid::types::Variant::Map& AgentEvent::getArguments() { return impl->getArguments(); }
+qpid::types::Variant::Map& AgentEvent::getArgumentSubtypes() { return impl->getArgumentSubtypes(); }
+void AgentEvent::addReturnArgument(const std::string& k, const qpid::types::Variant& v, const std::string& s) { impl->addReturnArgument(k, v, s); }
+
+uint32_t AgentEventImpl::enqueueData(const Data& data)
+{
+ qpid::sys::Mutex::ScopedLock l(lock);
+ dataQueue.push(data);
+ return dataQueue.size();
+}
+
+
+Data AgentEventImpl::dequeueData()
+{
+ qpid::sys::Mutex::ScopedLock l(lock);
+ if (dataQueue.empty())
+ return Data();
+ Data data(dataQueue.front());
+ dataQueue.pop();
+ return data;
+}
+
+
+void AgentEventImpl::addReturnArgument(const string& key, const Variant& val, const string& subtype)
+{
+ outArguments[key] = val;
+ if (!subtype.empty())
+ outArgumentSubtypes[key] = subtype;
+}
+
+
+AgentEventImpl& AgentEventImplAccess::get(AgentEvent& item)
+{
+ return *item.impl;
+}
+
+
+const AgentEventImpl& AgentEventImplAccess::get(const AgentEvent& item)
+{
+ return *item.impl;
+}
Added: qpid/trunk/qpid/cpp/src/qmf/AgentEventImpl.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/AgentEventImpl.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/AgentEventImpl.h (added)
+++ qpid/trunk/qpid/cpp/src/qmf/AgentEventImpl.h Thu Aug 12 22:28:09 2010
@@ -0,0 +1,93 @@
+#ifndef _QMF_AGENT_EVENT_IMPL_H_
+#define _QMF_AGENT_EVENT_IMPL_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 "qpid/RefCounted.h"
+#include "qpid/sys/Mutex.h"
+#include "qpid/sys/IntegerTypes.h"
+#include "qpid/messaging/Address.h"
+#include "qmf/AgentEvent.h"
+#include "qmf/Query.h"
+#include "qmf/DataAddr.h"
+#include "qmf/Data.h"
+#include <queue>
+
+namespace qmf {
+ class AgentEventImpl : public virtual qpid::RefCounted {
+ public:
+ //
+ // Impl-only methods
+ //
+ AgentEventImpl(AgentEventCode e) : eventType(e) {}
+ void setUserId(const std::string& u) { userId = u; }
+ void setQuery(const Query& q) { query = q; }
+ void setDataAddr(const DataAddr& d) { dataAddr = d; }
+ void setMethodName(const std::string& m) { methodName = m; }
+ void setArguments(const qpid::types::Variant::Map& a) { arguments = a; }
+ void setArgumentSubtypes(const qpid::types::Variant::Map& a) { argumentSubtypes = a; }
+ void setReplyTo(const qpid::messaging::Address& r) { replyTo = r; }
+ const qpid::messaging::Address& getReplyTo() { return replyTo; }
+ void setCorrelationId(const std::string& c) { correlationId = c; }
+ const std::string& getCorrelationId() { return correlationId; }
+ const qpid::types::Variant::Map& getReturnArguments() const { return outArguments; }
+ const qpid::types::Variant::Map& getReturnArgumentSubtypes() const { return outArgumentSubtypes; }
+ uint32_t enqueueData(const Data&);
+ Data dequeueData();
+
+ //
+ // Methods from API handle
+ //
+ AgentEventCode getType() const { return eventType; }
+ const std::string& getUserId() const { return userId; }
+ Query getQuery() const { return query; }
+ bool hasDataAddr() const { return dataAddr.isValid(); }
+ DataAddr getDataAddr() const { return dataAddr; }
+ const std::string& getMethodName() const { return methodName; }
+ qpid::types::Variant::Map& getArguments() { return arguments; }
+ qpid::types::Variant::Map& getArgumentSubtypes() { return argumentSubtypes; }
+ void addReturnArgument(const std::string&, const qpid::types::Variant&, const std::string&);
+
+ private:
+ const AgentEventCode eventType;
+ std::string userId;
+ qpid::messaging::Address replyTo;
+ std::string correlationId;
+ Query query;
+ DataAddr dataAddr;
+ std::string methodName;
+ qpid::types::Variant::Map arguments;
+ qpid::types::Variant::Map argumentSubtypes;
+ qpid::types::Variant::Map outArguments;
+ qpid::types::Variant::Map outArgumentSubtypes;
+
+ qpid::sys::Mutex lock;
+ std::queue<Data> dataQueue;
+ };
+
+ struct AgentEventImplAccess
+ {
+ static AgentEventImpl& get(AgentEvent&);
+ static const AgentEventImpl& get(const AgentEvent&);
+ };
+}
+
+#endif
Added: qpid/trunk/qpid/cpp/src/qmf/AgentImpl.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/AgentImpl.h?rev=985016&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/AgentImpl.h (added)
+++ qpid/trunk/qpid/cpp/src/qmf/AgentImpl.h Thu Aug 12 22:28:09 2010
@@ -0,0 +1,112 @@
+#ifndef _QMF_AGENT_IMPL_H_
+#define _QMF_AGENT_IMPL_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 "qpid/RefCounted.h"
+#include "qmf/Agent.h"
+#include "qmf/ConsoleEventImpl.h"
+#include "qmf/ConsoleSessionImpl.h"
+#include "qmf/SchemaCache.h"
+#include "qpid/messaging/Session.h"
+#include "qpid/messaging/Message.h"
+#include "qpid/sys/Mutex.h"
+#include "qpid/sys/Condition.h"
+#include <boost/shared_ptr.hpp>
+#include <map>
+#include <set>
+
+namespace qmf {
+ class AgentImpl : public virtual qpid::RefCounted {
+ public:
+ //
+ // Impl-only methods
+ //
+ AgentImpl(const std::string& n, uint32_t e, ConsoleSessionImpl& s);
+ void setAttribute(const std::string& k, const qpid::types::Variant& v) { attributes[k] = v; }
+ void setAttribute(const std::string& k, const std::string& v) { attributes[k] = v; }
+ void touch() { touched = true; }
+ uint32_t age() { untouchedCount = touched ? 0 : untouchedCount + 1; return untouchedCount; }
+ void handleException(const qpid::types::Variant::Map&, const qpid::messaging::Message&);
+ void handleMethodResponse(const qpid::types::Variant::Map&, const qpid::messaging::Message&);
+ void handleDataIndication(const qpid::types::Variant::List&, const qpid::messaging::Message&);
+ void handleQueryResponse(const qpid::types::Variant::List&, const qpid::messaging::Message&);
+
+ //
+ // Methods from API handle
+ //
+ const std::string& getName() const { return name; }
+ uint32_t getEpoch() const { return epoch; }
+ std::string getVendor() const { return getAttribute("_vendor").asString(); }
+ std::string getProduct() const { return getAttribute("_product").asString(); }
+ std::string getInstance() const { return getAttribute("_instance").asString(); }
+ const qpid::types::Variant& getAttribute(const std::string& k) const;
+ const qpid::types::Variant::Map& getAttributes() const { return attributes; }
+
+ ConsoleEvent query(const Query& q, qpid::messaging::Duration t);
+ ConsoleEvent query(const std::string& q, qpid::messaging::Duration t);
+ uint32_t queryAsync(const Query& q);
+ uint32_t queryAsync(const std::string& q);
+
+ ConsoleEvent callMethod(const std::string& m, const qpid::types::Variant::Map& a, const DataAddr&, qpid::messaging::Duration t);
+ uint32_t callMethodAsync(const std::string& m, const qpid::types::Variant::Map& a, const DataAddr&);
+
+ uint32_t getPackageCount() const;
+ const std::string& getPackage(uint32_t i) const;
+ uint32_t getSchemaIdCount(const std::string& p) const;
+ SchemaId getSchemaId(const std::string& p, uint32_t i) const;
+ Schema getSchema(const SchemaId& s, qpid::messaging::Duration t);
+
+ private:
+ struct SyncContext {
+ qpid::sys::Mutex lock;
+ qpid::sys::Condition cond;
+ ConsoleEvent response;
+ };
+
+ mutable qpid::sys::Mutex lock;
+ std::string name;
+ uint32_t epoch;
+ ConsoleSessionImpl& session;
+ bool touched;
+ uint32_t untouchedCount;
+ qpid::types::Variant::Map attributes;
+ uint32_t nextCorrelator;
+ std::map<uint32_t, boost::shared_ptr<SyncContext> > contextMap;
+ boost::shared_ptr<SchemaCache> schemaCache;
+ mutable std::set<std::string> packageSet;
+ std::set<SchemaId> schemaIdSet;
+
+ Query stringToQuery(const std::string&);
+ void sendQuery(const Query&, uint32_t);
+ void sendMethod(const std::string&, const qpid::types::Variant::Map&, const DataAddr&, uint32_t);
+ void sendSchemaRequest(const SchemaId&);
+ void learnSchemaId(const SchemaId&);
+ };
+
+ struct AgentImplAccess
+ {
+ static AgentImpl& get(Agent&);
+ static const AgentImpl& get(const Agent&);
+ };
+}
+
+#endif
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org