summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qmf/AgentEngine.cpp96
-rw-r--r--qpid/cpp/src/qmf/AgentEngine.h2
-rw-r--r--qpid/cpp/src/qmf/BrokerProxyImpl.cpp135
-rw-r--r--qpid/cpp/src/qmf/BrokerProxyImpl.h83
-rw-r--r--qpid/cpp/src/qmf/ConnectionSettingsImpl.cpp91
-rw-r--r--qpid/cpp/src/qmf/ConnectionSettingsImpl.h5
-rw-r--r--qpid/cpp/src/qmf/ConsoleEngine.h10
-rw-r--r--qpid/cpp/src/qmf/ConsoleEngineImpl.cpp45
-rw-r--r--qpid/cpp/src/qmf/ConsoleEngineImpl.h22
-rw-r--r--qpid/cpp/src/qmf/Object.h5
-rw-r--r--qpid/cpp/src/qmf/ObjectId.h9
-rw-r--r--qpid/cpp/src/qmf/ObjectIdImpl.cpp80
-rw-r--r--qpid/cpp/src/qmf/ObjectIdImpl.h6
-rw-r--r--qpid/cpp/src/qmf/ObjectImpl.cpp26
-rw-r--r--qpid/cpp/src/qmf/ObjectImpl.h14
-rw-r--r--qpid/cpp/src/qmf/Query.h6
-rw-r--r--qpid/cpp/src/qmf/QueryImpl.cpp9
-rw-r--r--qpid/cpp/src/qmf/QueryImpl.h24
-rw-r--r--qpid/cpp/src/qmf/ResilientConnection.cpp3
-rw-r--r--qpid/cpp/src/qmf/Schema.h60
-rw-r--r--qpid/cpp/src/qmf/SchemaImpl.cpp211
-rw-r--r--qpid/cpp/src/qmf/SchemaImpl.h64
-rw-r--r--qpid/cpp/src/qmf/Value.h9
-rw-r--r--qpid/cpp/src/qmf/ValueImpl.cpp38
-rw-r--r--qpid/cpp/src/qmf/ValueImpl.h19
25 files changed, 572 insertions, 500 deletions
diff --git a/qpid/cpp/src/qmf/AgentEngine.cpp b/qpid/cpp/src/qmf/AgentEngine.cpp
index 9ea3be5907..23d7eff84b 100644
--- a/qpid/cpp/src/qmf/AgentEngine.cpp
+++ b/qpid/cpp/src/qmf/AgentEngine.cpp
@@ -40,6 +40,7 @@
#include <iostream>
#include <fstream>
#include <boost/shared_ptr.hpp>
+#include <boost/noncopyable.hpp>
using namespace std;
using namespace qmf;
@@ -61,7 +62,7 @@ namespace qmf {
boost::shared_ptr<Value> arguments;
string exchange;
string bindingKey;
- SchemaObjectClass* objectClass;
+ const SchemaObjectClass* objectClass;
AgentEventImpl(AgentEvent::EventKind k) :
kind(k), sequence(0), object(0), objectClass(0) {}
@@ -74,11 +75,11 @@ namespace qmf {
uint32_t sequence;
string exchange;
string key;
- SchemaMethodImpl* schemaMethod;
+ const SchemaMethod* schemaMethod;
AgentQueryContext() : schemaMethod(0) {}
};
- class AgentEngineImpl {
+ class AgentEngineImpl : public boost::noncopyable {
public:
AgentEngineImpl(char* label, bool internalStore);
~AgentEngineImpl();
@@ -163,8 +164,8 @@ namespace qmf {
}
};
- typedef map<AgentClassKey, SchemaObjectClassImpl*, AgentClassKeyComp> ObjectClassMap;
- typedef map<AgentClassKey, SchemaEventClassImpl*, AgentClassKeyComp> EventClassMap;
+ typedef map<AgentClassKey, SchemaObjectClass*, AgentClassKeyComp> ObjectClassMap;
+ typedef map<AgentClassKey, SchemaEventClass*, AgentClassKeyComp> EventClassMap;
struct ClassMaps {
ObjectClassMap objectClasses;
@@ -180,7 +181,7 @@ namespace qmf {
boost::shared_ptr<ObjectId> oid);
AgentEventImpl::Ptr eventMethod(uint32_t num, const string& userId, const string& method,
boost::shared_ptr<ObjectId> oid, boost::shared_ptr<Value> argMap,
- SchemaObjectClass* objectClass);
+ const SchemaObjectClass* objectClass);
void sendBufferLH(Buffer& buf, const string& destination, const string& routingKey);
void sendPackageIndicationLH(const string& packageName);
@@ -366,15 +367,15 @@ void AgentEngineImpl::methodResponse(uint32_t sequence, uint32_t status, char* t
buffer.putLong(status);
buffer.putMediumString(text);
if (status == 0) {
- for (vector<SchemaArgumentImpl*>::const_iterator aIter = context->schemaMethod->arguments.begin();
- aIter != context->schemaMethod->arguments.end(); aIter++) {
- const SchemaArgumentImpl* schemaArg = *aIter;
- if (schemaArg->dir == DIR_OUT || schemaArg->dir == DIR_IN_OUT) {
- if (argMap.keyInMap(schemaArg->name.c_str())) {
- const Value* val = argMap.byKey(schemaArg->name.c_str());
+ for (vector<const SchemaArgument*>::const_iterator aIter = context->schemaMethod->impl->arguments.begin();
+ aIter != context->schemaMethod->impl->arguments.end(); aIter++) {
+ const SchemaArgument* schemaArg = *aIter;
+ if (schemaArg->getDirection() == DIR_OUT || schemaArg->getDirection() == DIR_IN_OUT) {
+ if (argMap.keyInMap(schemaArg->getName())) {
+ const Value* val = argMap.byKey(schemaArg->getName());
val->impl->encode(buffer);
} else {
- Value val(schemaArg->typecode);
+ Value val(schemaArg->getType());
val.impl->encode(buffer);
}
}
@@ -421,17 +422,16 @@ void AgentEngineImpl::queryComplete(uint32_t sequence)
void AgentEngineImpl::registerClass(SchemaObjectClass* cls)
{
Mutex::ScopedLock _lock(lock);
- SchemaObjectClassImpl* impl = cls->impl;
- map<string, ClassMaps>::iterator iter = packages.find(impl->package);
+ map<string, ClassMaps>::iterator iter = packages.find(cls->getClassKey()->getPackageName());
if (iter == packages.end()) {
- packages[impl->package] = ClassMaps();
- iter = packages.find(impl->getClassKey()->getPackageName());
+ packages[cls->getClassKey()->getPackageName()] = ClassMaps();
+ iter = packages.find(cls->getClassKey()->getPackageName());
// TODO: Indicate this package if connected
}
- AgentClassKey key(impl->getClassKey()->getClassName(), impl->getClassKey()->getHash());
- iter->second.objectClasses[key] = impl;
+ AgentClassKey key(cls->getClassKey()->getClassName(), cls->getClassKey()->getHash());
+ iter->second.objectClasses[key] = cls;
// TODO: Indicate this schema if connected.
}
@@ -439,17 +439,16 @@ void AgentEngineImpl::registerClass(SchemaObjectClass* cls)
void AgentEngineImpl::registerClass(SchemaEventClass* cls)
{
Mutex::ScopedLock _lock(lock);
- SchemaEventClassImpl* impl = cls->impl;
- map<string, ClassMaps>::iterator iter = packages.find(impl->package);
+ map<string, ClassMaps>::iterator iter = packages.find(cls->getClassKey()->getPackageName());
if (iter == packages.end()) {
- packages[impl->package] = ClassMaps();
- iter = packages.find(impl->getClassKey()->getPackageName());
+ packages[cls->getClassKey()->getPackageName()] = ClassMaps();
+ iter = packages.find(cls->getClassKey()->getPackageName());
// TODO: Indicate this package if connected
}
- AgentClassKey key(impl->getClassKey()->getClassName(), impl->getClassKey()->getHash());
- iter->second.eventClasses[key] = impl;
+ AgentClassKey key(cls->getClassKey()->getClassName(), cls->getClassKey()->getHash());
+ iter->second.eventClasses[key] = cls;
// TODO: Indicate this schema if connected.
}
@@ -466,8 +465,8 @@ const ObjectId* AgentEngineImpl::allocObjectId(uint64_t persistId)
uint16_t sequence = persistId ? 0 : bootSequence;
uint64_t objectNum = persistId ? persistId : nextObjectId++;
- ObjectIdImpl* oid = new ObjectIdImpl(&attachment, 0, sequence, objectNum);
- return oid->envelope;
+ ObjectId* oid = ObjectIdImpl::factory(&attachment, 0, sequence, objectNum);
+ return oid;
}
const ObjectId* AgentEngineImpl::allocObjectId(uint32_t persistIdLo, uint32_t persistIdHi)
@@ -520,7 +519,7 @@ AgentEventImpl::Ptr AgentEngineImpl::eventQuery(uint32_t num, const string& user
AgentEventImpl::Ptr AgentEngineImpl::eventMethod(uint32_t num, const string& userId, const string& method,
boost::shared_ptr<ObjectId> oid, boost::shared_ptr<Value> argMap,
- SchemaObjectClass* objectClass)
+ const SchemaObjectClass* objectClass)
{
AgentEventImpl::Ptr event(new AgentEventImpl(AgentEvent::METHOD_CALL));
event->sequence = num;
@@ -688,10 +687,10 @@ void AgentEngineImpl::handleSchemaRequest(Buffer& inBuffer, uint32_t sequence,
ClassMaps cMap = pIter->second;
ObjectClassMap::iterator ocIter = cMap.objectClasses.find(key);
if (ocIter != cMap.objectClasses.end()) {
- SchemaObjectClassImpl* oImpl = ocIter->second;
+ SchemaObjectClass* oImpl = ocIter->second;
Buffer buffer(outputBuffer, MA_BUFFER_SIZE);
Protocol::encodeHeader(buffer, Protocol::OP_SCHEMA_RESPONSE, sequence);
- oImpl->encode(buffer);
+ oImpl->impl->encode(buffer);
sendBufferLH(buffer, rExchange, rKey);
QPID_LOG(trace, "SENT SchemaResponse: (object) package=" << packageName << " class=" << key.name);
return;
@@ -699,10 +698,10 @@ void AgentEngineImpl::handleSchemaRequest(Buffer& inBuffer, uint32_t sequence,
EventClassMap::iterator ecIter = cMap.eventClasses.find(key);
if (ecIter != cMap.eventClasses.end()) {
- SchemaEventClassImpl* eImpl = ecIter->second;
+ SchemaEventClass* eImpl = ecIter->second;
Buffer buffer(outputBuffer, MA_BUFFER_SIZE);
Protocol::encodeHeader(buffer, Protocol::OP_SCHEMA_RESPONSE, sequence);
- eImpl->encode(buffer);
+ eImpl->impl->encode(buffer);
sendBufferLH(buffer, rExchange, rKey);
QPID_LOG(trace, "SENT SchemaResponse: (event) package=" << packageName << " class=" << key.name);
return;
@@ -768,8 +767,7 @@ void AgentEngineImpl::handleMethodRequest(Buffer& buffer, uint32_t sequence, con
Mutex::ScopedLock _lock(lock);
string pname;
string method;
- ObjectIdImpl* oidImpl = new ObjectIdImpl(buffer);
- boost::shared_ptr<ObjectId> oid(oidImpl->envelope);
+ boost::shared_ptr<ObjectId> oid(ObjectIdImpl::factory(buffer));
buffer.getShortString(pname);
AgentClassKey classKey(buffer);
buffer.getShortString(method);
@@ -788,29 +786,29 @@ void AgentEngineImpl::handleMethodRequest(Buffer& buffer, uint32_t sequence, con
return;
}
- const SchemaObjectClassImpl* schema = cIter->second;
- vector<SchemaMethodImpl*>::const_iterator mIter = schema->methods.begin();
- for (; mIter != schema->methods.end(); mIter++) {
- if ((*mIter)->name == method)
+ const SchemaObjectClass* schema = cIter->second;
+ vector<const SchemaMethod*>::const_iterator mIter = schema->impl->methods.begin();
+ for (; mIter != schema->impl->methods.end(); mIter++) {
+ if ((*mIter)->getName() == method)
break;
}
- if (mIter == schema->methods.end()) {
+ if (mIter == schema->impl->methods.end()) {
sendMethodErrorLH(sequence, replyTo, MERR_UNKNOWN_METHOD, method);
return;
}
- SchemaMethodImpl* schemaMethod = *mIter;
+ const SchemaMethod* schemaMethod = *mIter;
boost::shared_ptr<Value> argMap(new Value(TYPE_MAP));
- ValueImpl* value;
- for (vector<SchemaArgumentImpl*>::const_iterator aIter = schemaMethod->arguments.begin();
- aIter != schemaMethod->arguments.end(); aIter++) {
- const SchemaArgumentImpl* schemaArg = *aIter;
- if (schemaArg->dir == DIR_IN || schemaArg->dir == DIR_IN_OUT)
- value = new ValueImpl(schemaArg->typecode, buffer);
+ Value* value;
+ for (vector<const SchemaArgument*>::const_iterator aIter = schemaMethod->impl->arguments.begin();
+ aIter != schemaMethod->impl->arguments.end(); aIter++) {
+ const SchemaArgument* schemaArg = *aIter;
+ if (schemaArg->getDirection() == DIR_IN || schemaArg->getDirection() == DIR_IN_OUT)
+ value = ValueImpl::factory(schemaArg->getType(), buffer);
else
- value = new ValueImpl(schemaArg->typecode);
- argMap->insert(schemaArg->name.c_str(), value->envelope);
+ value = ValueImpl::factory(schemaArg->getType());
+ argMap->insert(schemaArg->getName(), value);
}
AgentQueryContext::Ptr context(new AgentQueryContext);
@@ -821,7 +819,7 @@ void AgentEngineImpl::handleMethodRequest(Buffer& buffer, uint32_t sequence, con
context->schemaMethod = schemaMethod;
contextMap[contextNum] = context;
- eventQueue.push_back(eventMethod(contextNum, userId, method, oid, argMap, schema->envelope));
+ eventQueue.push_back(eventMethod(contextNum, userId, method, oid, argMap, schema));
}
void AgentEngineImpl::handleConsoleAddedIndication()
diff --git a/qpid/cpp/src/qmf/AgentEngine.h b/qpid/cpp/src/qmf/AgentEngine.h
index c88ef33657..bf91cbb4c8 100644
--- a/qpid/cpp/src/qmf/AgentEngine.h
+++ b/qpid/cpp/src/qmf/AgentEngine.h
@@ -61,7 +61,7 @@ namespace qmf {
Value* arguments; // Method parameters (METHOD_CALL)
char* exchange; // Exchange for bind (BIND, UNBIND)
char* bindingKey; // Key for bind (BIND, UNBIND)
- SchemaObjectClass* objectClass; // (METHOD_CALL)
+ const SchemaObjectClass* objectClass; // (METHOD_CALL)
};
class AgentEngineImpl;
diff --git a/qpid/cpp/src/qmf/BrokerProxyImpl.cpp b/qpid/cpp/src/qmf/BrokerProxyImpl.cpp
index 47dca309d7..29e51566b3 100644
--- a/qpid/cpp/src/qmf/BrokerProxyImpl.cpp
+++ b/qpid/cpp/src/qmf/BrokerProxyImpl.cpp
@@ -43,7 +43,7 @@ namespace {
const Object* QueryResponseImpl::getObject(uint32_t idx) const
{
- vector<ObjectImpl::Ptr>::const_iterator iter = results.begin();
+ vector<ObjectPtr>::const_iterator iter = results.begin();
while (idx > 0) {
if (iter == results.end())
@@ -52,7 +52,7 @@ const Object* QueryResponseImpl::getObject(uint32_t idx) const
idx--;
}
- return (*iter)->envelope;
+ return iter->get();
}
#define STRING_REF(s) {if (!s.empty()) item.s = const_cast<char*>(s.c_str());}
@@ -68,14 +68,13 @@ BrokerEvent BrokerEventImpl::copy()
STRING_REF(exchange);
STRING_REF(bindingKey);
item.context = context;
- item.queryResponse = queryResponse.get() ? queryResponse->envelope : 0;
- item.methodResponse = methodResponse.get() ? methodResponse->envelope : 0;
+ item.queryResponse = queryResponse.get();
+ item.methodResponse = methodResponse.get();
return item;
}
-BrokerProxyImpl::BrokerProxyImpl(BrokerProxy* e, ConsoleEngine& _console) :
- envelope(e), console(_console.impl)
+BrokerProxyImpl::BrokerProxyImpl(BrokerProxy& pub, ConsoleEngine& _console) : publicObject(pub), console(_console)
{
stringstream qn;
qpid::TcpAddress addr;
@@ -114,7 +113,7 @@ void BrokerProxyImpl::startProtocol()
char rawbuffer[512];
Buffer buffer(rawbuffer, 512);
- agentList.push_back(AgentProxyImpl::Ptr(new AgentProxyImpl(console, this, 0, "Agent embedded in broker")));
+ agentList.push_back(AgentProxyPtr(AgentProxyImpl::factory(console, publicObject, 0, "Agent embedded in broker")));
requestsOutstanding = 1;
topicBound = false;
@@ -190,10 +189,10 @@ uint32_t BrokerProxyImpl::agentCount() const
const AgentProxy* BrokerProxyImpl::getAgent(uint32_t idx) const
{
Mutex::ScopedLock _lock(lock);
- for (vector<AgentProxyImpl::Ptr>::const_iterator iter = agentList.begin();
+ for (vector<AgentProxyPtr>::const_iterator iter = agentList.begin();
iter != agentList.end(); iter++)
if (idx-- == 0)
- return (*iter)->envelope;
+ return iter->get();
return 0;
}
@@ -202,17 +201,17 @@ void BrokerProxyImpl::sendQuery(const Query& query, void* context, const AgentPr
SequenceContext::Ptr queryContext(new QueryContext(*this, context));
Mutex::ScopedLock _lock(lock);
if (agent != 0) {
- sendGetRequestLH(queryContext, query, agent->impl);
+ sendGetRequestLH(queryContext, query, agent);
} else {
// TODO (optimization) only send queries to agents that have the requested class+package
- for (vector<AgentProxyImpl::Ptr>::const_iterator iter = agentList.begin();
+ for (vector<AgentProxyPtr>::const_iterator iter = agentList.begin();
iter != agentList.end(); iter++) {
sendGetRequestLH(queryContext, query, (*iter).get());
}
}
}
-void BrokerProxyImpl::sendGetRequestLH(SequenceContext::Ptr queryContext, const Query& query, const AgentProxyImpl* agent)
+void BrokerProxyImpl::sendGetRequestLH(SequenceContext::Ptr queryContext, const Query& query, const AgentProxy* agent)
{
stringstream key;
Buffer outBuffer(outputBuffer, MA_BUFFER_SIZE);
@@ -220,7 +219,7 @@ void BrokerProxyImpl::sendGetRequestLH(SequenceContext::Ptr queryContext, const
Protocol::encodeHeader(outBuffer, Protocol::OP_GET_QUERY, sequence);
query.impl->encode(outBuffer);
- key << "agent.1." << agent->agentBank;
+ key << "agent.1." << agent->impl->agentBank;
sendBufferLH(outBuffer, QMF_EXCHANGE, key.str());
QPID_LOG(trace, "SENT GetQuery seq=" << sequence << " key=" << key.str());
}
@@ -250,7 +249,7 @@ string BrokerProxyImpl::encodeMethodArguments(const SchemaMethod* schema, const
return string();
}
-void BrokerProxyImpl::sendMethodRequest(ObjectIdImpl* oid, const SchemaObjectClass* cls,
+void BrokerProxyImpl::sendMethodRequest(ObjectId* oid, const SchemaObjectClass* cls,
const string& methodName, const Value* args, void* userContext)
{
int methodCount = cls->getMethodCount();
@@ -259,30 +258,30 @@ void BrokerProxyImpl::sendMethodRequest(ObjectIdImpl* oid, const SchemaObjectCla
const SchemaMethod* method = cls->getMethod(idx);
if (string(method->getName()) == methodName) {
Mutex::ScopedLock _lock(lock);
- SequenceContext::Ptr methodContext(new MethodContext(*this, userContext, method->impl));
+ SequenceContext::Ptr methodContext(new MethodContext(*this, userContext, method));
stringstream key;
Buffer outBuffer(outputBuffer, MA_BUFFER_SIZE);
uint32_t sequence(seqMgr.reserve(methodContext));
Protocol::encodeHeader(outBuffer, Protocol::OP_METHOD_REQUEST, sequence);
- oid->encode(outBuffer);
+ oid->impl->encode(outBuffer);
cls->getClassKey()->impl->encode(outBuffer);
outBuffer.putShortString(methodName);
string argErrorString = encodeMethodArguments(method, args, outBuffer);
if (argErrorString.empty()) {
- key << "agent.1." << oid->getAgentBank();
+ key << "agent.1." << oid->impl->getAgentBank();
sendBufferLH(outBuffer, QMF_EXCHANGE, key.str());
QPID_LOG(trace, "SENT MethodRequest seq=" << sequence << " method=" << methodName << " key=" << key.str());
} else {
- MethodResponseImpl::Ptr argError(new MethodResponseImpl(1, argErrorString));
+ MethodResponsePtr argError(MethodResponseImpl::factory(1, argErrorString));
eventQueue.push_back(eventMethodResponse(userContext, argError));
}
return;
}
}
- MethodResponseImpl::Ptr error(new MethodResponseImpl(1, string("Unknown method: ") + methodName));
+ MethodResponsePtr error(MethodResponseImpl::factory(1, string("Unknown method: ") + methodName));
Mutex::ScopedLock _lock(lock);
eventQueue.push_back(eventMethodResponse(userContext, error));
}
@@ -322,7 +321,7 @@ BrokerEventImpl::Ptr BrokerProxyImpl::eventStable()
return event;
}
-BrokerEventImpl::Ptr BrokerProxyImpl::eventQueryComplete(void* context, QueryResponseImpl::Ptr response)
+BrokerEventImpl::Ptr BrokerProxyImpl::eventQueryComplete(void* context, QueryResponsePtr response)
{
BrokerEventImpl::Ptr event(new BrokerEventImpl(BrokerEvent::QUERY_COMPLETE));
event->context = context;
@@ -330,7 +329,7 @@ BrokerEventImpl::Ptr BrokerProxyImpl::eventQueryComplete(void* context, QueryRes
return event;
}
-BrokerEventImpl::Ptr BrokerProxyImpl::eventMethodResponse(void* context, MethodResponseImpl::Ptr response)
+BrokerEventImpl::Ptr BrokerProxyImpl::eventMethodResponse(void* context, MethodResponsePtr response)
{
BrokerEventImpl::Ptr event(new BrokerEventImpl(BrokerEvent::METHOD_RESPONSE));
event->context = context;
@@ -357,7 +356,7 @@ void BrokerProxyImpl::handlePackageIndication(Buffer& inBuffer, uint32_t seq)
inBuffer.getShortString(package);
QPID_LOG(trace, "RCVD PackageIndication seq=" << seq << " package=" << package);
- console->learnPackage(package);
+ console.impl->learnPackage(package);
Mutex::ScopedLock _lock(lock);
Buffer outBuffer(outputBuffer, MA_BUFFER_SIZE);
@@ -380,25 +379,25 @@ void BrokerProxyImpl::handleCommandComplete(Buffer& inBuffer, uint32_t seq)
void BrokerProxyImpl::handleClassIndication(Buffer& inBuffer, uint32_t seq)
{
uint8_t kind = inBuffer.getOctet();
- SchemaClassKeyImpl classKey(inBuffer);
+ auto_ptr<SchemaClassKey> classKey(SchemaClassKeyImpl::factory(inBuffer));
- QPID_LOG(trace, "RCVD ClassIndication seq=" << seq << " kind=" << (int) kind << " key=" << classKey.str());
+ QPID_LOG(trace, "RCVD ClassIndication seq=" << seq << " kind=" << (int) kind << " key=" << classKey->impl->str());
- if (!console->haveClass(classKey)) {
+ if (!console.impl->haveClass(classKey.get())) {
Mutex::ScopedLock _lock(lock);
incOutstandingLH();
Buffer outBuffer(outputBuffer, MA_BUFFER_SIZE);
uint32_t sequence(seqMgr.reserve());
Protocol::encodeHeader(outBuffer, Protocol::OP_SCHEMA_REQUEST, sequence);
- classKey.encode(outBuffer);
+ classKey->impl->encode(outBuffer);
sendBufferLH(outBuffer, QMF_EXCHANGE, BROKER_KEY);
- QPID_LOG(trace, "SENT SchemaRequest seq=" << sequence <<" key=" << classKey.str());
+ QPID_LOG(trace, "SENT SchemaRequest seq=" << sequence <<" key=" << classKey->impl->str());
}
}
-MethodResponseImpl::Ptr BrokerProxyImpl::handleMethodResponse(Buffer& inBuffer, uint32_t seq, SchemaMethodImpl* schema)
+MethodResponsePtr BrokerProxyImpl::handleMethodResponse(Buffer& inBuffer, uint32_t seq, const SchemaMethod* schema)
{
- MethodResponseImpl::Ptr response(new MethodResponseImpl(inBuffer, schema));
+ MethodResponsePtr response(MethodResponseImpl::factory(inBuffer, schema));
QPID_LOG(trace, "RCVD MethodResponse seq=" << seq << " status=" << response->getStatus() << " text=" <<
response->getException()->asString());
@@ -418,15 +417,15 @@ void BrokerProxyImpl::handleEventIndication(Buffer& /*inBuffer*/, uint32_t /*seq
void BrokerProxyImpl::handleSchemaResponse(Buffer& inBuffer, uint32_t seq)
{
- SchemaObjectClassImpl::Ptr oClassPtr;
- SchemaEventClassImpl::Ptr eClassPtr;
+ SchemaObjectClass* oClassPtr;
+ SchemaEventClass* eClassPtr;
uint8_t kind = inBuffer.getOctet();
- const SchemaClassKeyImpl* key;
+ const SchemaClassKey* key;
if (kind == CLASS_OBJECT) {
- oClassPtr.reset(new SchemaObjectClassImpl(inBuffer));
- console->learnClass(oClassPtr);
- key = oClassPtr->getClassKey()->impl;
- QPID_LOG(trace, "RCVD SchemaResponse seq=" << seq << " kind=object key=" << key->str());
+ oClassPtr = SchemaObjectClassImpl::factory(inBuffer);
+ console.impl->learnClass(oClassPtr);
+ key = oClassPtr->getClassKey();
+ QPID_LOG(trace, "RCVD SchemaResponse seq=" << seq << " kind=object key=" << key->impl->str());
//
// If we have just learned about the org.apache.qpid.broker:agent class, send a get
@@ -447,28 +446,28 @@ void BrokerProxyImpl::handleSchemaResponse(Buffer& inBuffer, uint32_t seq)
QPID_LOG(trace, "SENT GetQuery seq=" << sequence << " key=" << BROKER_AGENT_KEY);
}
} else if (kind == CLASS_EVENT) {
- eClassPtr.reset(new SchemaEventClassImpl(inBuffer));
- console->learnClass(eClassPtr);
- key = eClassPtr->getClassKey()->impl;
- QPID_LOG(trace, "RCVD SchemaResponse seq=" << seq << " kind=event key=" << key->str());
+ eClassPtr = SchemaEventClassImpl::factory(inBuffer);
+ console.impl->learnClass(eClassPtr);
+ key = eClassPtr->getClassKey();
+ QPID_LOG(trace, "RCVD SchemaResponse seq=" << seq << " kind=event key=" << key->impl->str());
}
else {
QPID_LOG(error, "BrokerProxyImpl::handleSchemaResponse received unknown class kind: " << (int) kind);
}
}
-ObjectImpl::Ptr BrokerProxyImpl::handleObjectIndication(Buffer& inBuffer, uint32_t seq, bool prop, bool stat)
+ObjectPtr BrokerProxyImpl::handleObjectIndication(Buffer& inBuffer, uint32_t seq, bool prop, bool stat)
{
- SchemaClassKeyImpl classKey(inBuffer);
- QPID_LOG(trace, "RCVD ObjectIndication seq=" << seq << " key=" << classKey.str());
+ auto_ptr<SchemaClassKey> classKey(SchemaClassKeyImpl::factory(inBuffer));
+ QPID_LOG(trace, "RCVD ObjectIndication seq=" << seq << " key=" << classKey->impl->str());
- SchemaObjectClassImpl::Ptr schema = console->getSchema(classKey);
- if (schema.get() == 0) {
- QPID_LOG(trace, "No Schema Found for ObjectIndication. seq=" << seq << " key=" << classKey.str());
- return ObjectImpl::Ptr();
+ SchemaObjectClass* schema = console.impl->getSchema(classKey.get());
+ if (schema == 0) {
+ QPID_LOG(trace, "No Schema Found for ObjectIndication. seq=" << seq << " key=" << classKey->impl->str());
+ return ObjectPtr();
}
- return ObjectImpl::Ptr(new ObjectImpl(schema->envelope, this, inBuffer, prop, stat, true));
+ return ObjectPtr(ObjectImpl::factory(schema, this, inBuffer, prop, stat, true));
}
void BrokerProxyImpl::incOutstandingLH()
@@ -482,8 +481,8 @@ void BrokerProxyImpl::decOutstanding()
requestsOutstanding--;
if (requestsOutstanding == 0 && !topicBound) {
topicBound = true;
- for (vector<pair<string, string> >::const_iterator iter = console->bindingList.begin();
- iter != console->bindingList.end(); iter++) {
+ for (vector<pair<string, string> >::const_iterator iter = console.impl->bindingList.begin();
+ iter != console.impl->bindingList.end(); iter++) {
string exchange(iter->first.empty() ? QMF_EXCHANGE : iter->first);
string key(iter->second);
eventQueue.push_back(eventBind(exchange, queueName, key));
@@ -493,15 +492,15 @@ void BrokerProxyImpl::decOutstanding()
}
MethodResponseImpl::MethodResponseImpl(const MethodResponseImpl& from) :
- envelope(from.envelope), // !!!! TODO !!!! this is not right
- status(from.status), schema(from.schema),
- exception(from.exception.get() ? new Value(*from.exception) : 0),
- arguments(from.arguments.get() ? new Value(*from.arguments) : 0)
+ status(from.status), schema(from.schema)
{
+ if (from.exception.get())
+ exception.reset(new Value(*(from.exception)));
+ if (from.arguments.get())
+ arguments.reset(new Value(*(from.arguments)));
}
-MethodResponseImpl::MethodResponseImpl(Buffer& buf, SchemaMethodImpl* s) :
- envelope(new MethodResponse(this)), schema(s)
+MethodResponseImpl::MethodResponseImpl(Buffer& buf, const SchemaMethod* s) : schema(s)
{
string text;
@@ -518,19 +517,31 @@ MethodResponseImpl::MethodResponseImpl(Buffer& buf, SchemaMethodImpl* s) :
for (int idx = 0; idx < argCount; idx++) {
const SchemaArgument* arg = schema->getArgument(idx);
if (arg->getDirection() == DIR_OUT || arg->getDirection() == DIR_IN_OUT) {
- ValueImpl* value(new ValueImpl(arg->getType(), buf));
- arguments->insert(arg->getName(), value->envelope);
+ Value* value(ValueImpl::factory(arg->getType(), buf));
+ arguments->insert(arg->getName(), value);
}
}
}
-MethodResponseImpl::MethodResponseImpl(uint32_t s, const string& text) : envelope(new MethodResponse(this)), schema(0)
+MethodResponseImpl::MethodResponseImpl(uint32_t s, const string& text) : schema(0)
{
status = s;
exception.reset(new Value(TYPE_LSTR));
exception->setString(text.c_str());
}
+MethodResponse* MethodResponseImpl::factory(Buffer& buf, const SchemaMethod* schema)
+{
+ MethodResponseImpl* impl(new MethodResponseImpl(buf, schema));
+ return new MethodResponse(impl);
+}
+
+MethodResponse* MethodResponseImpl::factory(uint32_t status, const std::string& text)
+{
+ MethodResponseImpl* impl(new MethodResponseImpl(status, text));
+ return new MethodResponse(impl);
+}
+
bool StaticContext::handleMessage(uint8_t opcode, uint32_t sequence, Buffer& buffer)
{
bool completeContext = false;
@@ -589,7 +600,7 @@ void QueryContext::release()
bool QueryContext::handleMessage(uint8_t opcode, uint32_t sequence, Buffer& buffer)
{
bool completeContext = false;
- ObjectImpl::Ptr object;
+ ObjectPtr object;
if (opcode == Protocol::OP_COMMAND_COMPLETE) {
broker.handleCommandComplete(buffer, sequence);
@@ -598,7 +609,7 @@ bool QueryContext::handleMessage(uint8_t opcode, uint32_t sequence, Buffer& buff
else if (opcode == Protocol::OP_OBJECT_INDICATION) {
object = broker.handleObjectIndication(buffer, sequence, true, true);
if (object.get() != 0)
- queryResponse->results.push_back(object);
+ queryResponse->impl->results.push_back(object);
}
else {
QPID_LOG(trace, "QueryContext::handleMessage invalid opcode: " << opcode);
@@ -633,7 +644,7 @@ AgentProxy::AgentProxy(AgentProxyImpl* i) : impl(i) {}
AgentProxy::~AgentProxy() { delete impl; }
const char* AgentProxy::getLabel() const { return impl->getLabel().c_str(); }
-BrokerProxy::BrokerProxy(ConsoleEngine& console) : impl(new BrokerProxyImpl(this, console)) {}
+BrokerProxy::BrokerProxy(ConsoleEngine& console) : impl(new BrokerProxyImpl(*this, console)) {}
BrokerProxy::~BrokerProxy() { delete impl; }
void BrokerProxy::sessionOpened(SessionHandle& sh) { impl->sessionOpened(sh); }
void BrokerProxy::sessionClosed() { impl->sessionClosed(); }
diff --git a/qpid/cpp/src/qmf/BrokerProxyImpl.h b/qpid/cpp/src/qmf/BrokerProxyImpl.h
index 930d8c8995..d98c28c32a 100644
--- a/qpid/cpp/src/qmf/BrokerProxyImpl.h
+++ b/qpid/cpp/src/qmf/BrokerProxyImpl.h
@@ -31,6 +31,7 @@
#include "qpid/framing/Uuid.h"
#include "qpid/sys/Mutex.h"
#include "boost/shared_ptr.hpp"
+#include "boost/noncopyable.hpp"
#include <memory>
#include <string>
#include <deque>
@@ -39,32 +40,36 @@
namespace qmf {
+ typedef boost::shared_ptr<MethodResponse> MethodResponsePtr;
struct MethodResponseImpl {
- typedef boost::shared_ptr<MethodResponseImpl> Ptr;
- MethodResponse* envelope;
uint32_t status;
- SchemaMethodImpl* schema;
- boost::shared_ptr<Value> exception;
- boost::shared_ptr<Value> arguments;
+ const SchemaMethod* schema;
+ std::auto_ptr<Value> exception;
+ std::auto_ptr<Value> arguments;
MethodResponseImpl(const MethodResponseImpl& from);
- MethodResponseImpl(qpid::framing::Buffer& buf, SchemaMethodImpl* schema);
+ MethodResponseImpl(qpid::framing::Buffer& buf, const SchemaMethod* schema);
MethodResponseImpl(uint32_t status, const std::string& text);
- ~MethodResponseImpl() { delete envelope; }
+ static MethodResponse* factory(qpid::framing::Buffer& buf, const SchemaMethod* schema);
+ static MethodResponse* factory(uint32_t status, const std::string& text);
+ ~MethodResponseImpl() {}
uint32_t getStatus() const { return status; }
const Value* getException() const { return exception.get(); }
const Value* getArgs() const { return arguments.get(); }
};
+ typedef boost::shared_ptr<QueryResponse> QueryResponsePtr;
struct QueryResponseImpl {
- typedef boost::shared_ptr<QueryResponseImpl> Ptr;
- QueryResponse *envelope;
uint32_t status;
std::auto_ptr<Value> exception;
- std::vector<ObjectImpl::Ptr> results;
-
- QueryResponseImpl() : envelope(new QueryResponse(this)), status(0) {}
- ~QueryResponseImpl() { delete envelope; }
+ std::vector<ObjectPtr> results;
+
+ QueryResponseImpl() : status(0) {}
+ static QueryResponse* factory() {
+ QueryResponseImpl* impl(new QueryResponseImpl());
+ return new QueryResponse(impl);
+ }
+ ~QueryResponseImpl() {}
uint32_t getStatus() const { return status; }
const Value* getException() const { return exception.get(); }
uint32_t getObjectCount() const { return results.size(); }
@@ -78,33 +83,33 @@ namespace qmf {
std::string exchange;
std::string bindingKey;
void* context;
- QueryResponseImpl::Ptr queryResponse;
- MethodResponseImpl::Ptr methodResponse;
+ QueryResponsePtr queryResponse;
+ MethodResponsePtr methodResponse;
BrokerEventImpl(BrokerEvent::EventKind k) : kind(k), context(0) {}
~BrokerEventImpl() {}
BrokerEvent copy();
};
+ typedef boost::shared_ptr<AgentProxy> AgentProxyPtr;
struct AgentProxyImpl {
- typedef boost::shared_ptr<AgentProxyImpl> Ptr;
- AgentProxy* envelope;
- ConsoleEngineImpl* console;
- BrokerProxyImpl* broker;
+ ConsoleEngine& console;
+ BrokerProxy& broker;
uint32_t agentBank;
std::string label;
- AgentProxyImpl(ConsoleEngineImpl* c, BrokerProxyImpl* b, uint32_t ab, const std::string& l) :
- envelope(new AgentProxy(this)), console(c), broker(b), agentBank(ab), label(l) {}
+ AgentProxyImpl(ConsoleEngine& c, BrokerProxy& b, uint32_t ab, const std::string& l) : console(c), broker(b), agentBank(ab), label(l) {}
+ static AgentProxy* factory(ConsoleEngine& c, BrokerProxy& b, uint32_t ab, const std::string& l) {
+ AgentProxyImpl* impl(new AgentProxyImpl(c, b, ab, l));
+ return new AgentProxy(impl);
+ }
~AgentProxyImpl() {}
const std::string& getLabel() const { return label; }
};
- class BrokerProxyImpl {
+ class BrokerProxyImpl : public boost::noncopyable {
public:
- typedef boost::shared_ptr<BrokerProxyImpl> Ptr;
-
- BrokerProxyImpl(BrokerProxy* e, ConsoleEngine& _console);
+ BrokerProxyImpl(BrokerProxy& pub, ConsoleEngine& _console);
~BrokerProxyImpl() {}
void sessionOpened(SessionHandle& sh);
@@ -122,9 +127,9 @@ namespace qmf {
uint32_t agentCount() const;
const AgentProxy* getAgent(uint32_t idx) const;
void sendQuery(const Query& query, void* context, const AgentProxy* agent);
- void sendGetRequestLH(SequenceContext::Ptr queryContext, const Query& query, const AgentProxyImpl* agent);
+ void sendGetRequestLH(SequenceContext::Ptr queryContext, const Query& query, const AgentProxy* agent);
std::string encodeMethodArguments(const SchemaMethod* schema, const Value* args, qpid::framing::Buffer& buffer);
- void sendMethodRequest(ObjectIdImpl* oid, const SchemaObjectClass* cls, const std::string& method, const Value* args, void* context);
+ void sendMethodRequest(ObjectId* oid, const SchemaObjectClass* cls, const std::string& method, const Value* args, void* context);
void addBinding(const std::string& exchange, const std::string& key);
void staticRelease() { decOutstanding(); }
@@ -133,15 +138,15 @@ namespace qmf {
friend class StaticContext;
friend class QueryContext;
friend class MethodContext;
+ BrokerProxy& publicObject;
mutable qpid::sys::Mutex lock;
- BrokerProxy* envelope;
- ConsoleEngineImpl* console;
+ ConsoleEngine& console;
std::string queueName;
qpid::framing::Uuid brokerId;
SequenceManager seqMgr;
uint32_t requestsOutstanding;
bool topicBound;
- std::vector<AgentProxyImpl::Ptr> agentList;
+ std::vector<AgentProxyPtr> agentList;
std::deque<MessageImpl::Ptr> xmtQueue;
std::deque<BrokerEventImpl::Ptr> eventQueue;
@@ -152,18 +157,18 @@ namespace qmf {
BrokerEventImpl::Ptr eventBind(const std::string& exchange, const std::string& queue, const std::string& key);
BrokerEventImpl::Ptr eventSetupComplete();
BrokerEventImpl::Ptr eventStable();
- BrokerEventImpl::Ptr eventQueryComplete(void* context, QueryResponseImpl::Ptr response);
- BrokerEventImpl::Ptr eventMethodResponse(void* context, MethodResponseImpl::Ptr response);
+ BrokerEventImpl::Ptr eventQueryComplete(void* context, QueryResponsePtr response);
+ BrokerEventImpl::Ptr eventMethodResponse(void* context, MethodResponsePtr response);
void handleBrokerResponse(qpid::framing::Buffer& inBuffer, uint32_t seq);
void handlePackageIndication(qpid::framing::Buffer& inBuffer, uint32_t seq);
void handleCommandComplete(qpid::framing::Buffer& inBuffer, uint32_t seq);
void handleClassIndication(qpid::framing::Buffer& inBuffer, uint32_t seq);
- MethodResponseImpl::Ptr handleMethodResponse(qpid::framing::Buffer& inBuffer, uint32_t seq, SchemaMethodImpl* schema);
+ MethodResponsePtr handleMethodResponse(qpid::framing::Buffer& inBuffer, uint32_t seq, const SchemaMethod* schema);
void handleHeartbeatIndication(qpid::framing::Buffer& inBuffer, uint32_t seq);
void handleEventIndication(qpid::framing::Buffer& inBuffer, uint32_t seq);
void handleSchemaResponse(qpid::framing::Buffer& inBuffer, uint32_t seq);
- ObjectImpl::Ptr handleObjectIndication(qpid::framing::Buffer& inBuffer, uint32_t seq, bool prop, bool stat);
+ ObjectPtr handleObjectIndication(qpid::framing::Buffer& inBuffer, uint32_t seq, bool prop, bool stat);
void incOutstandingLH();
void decOutstanding();
};
@@ -188,7 +193,7 @@ namespace qmf {
//
struct QueryContext : public SequenceContext {
QueryContext(BrokerProxyImpl& b, void* u) :
- broker(b), userContext(u), requestsOutstanding(0), queryResponse(new QueryResponseImpl()) {}
+ broker(b), userContext(u), requestsOutstanding(0), queryResponse(QueryResponseImpl::factory()) {}
virtual ~QueryContext() {}
void reserve();
void release();
@@ -198,11 +203,11 @@ namespace qmf {
BrokerProxyImpl& broker;
void* userContext;
uint32_t requestsOutstanding;
- QueryResponseImpl::Ptr queryResponse;
+ QueryResponsePtr queryResponse;
};
struct MethodContext : public SequenceContext {
- MethodContext(BrokerProxyImpl& b, void* u, SchemaMethodImpl* s) : broker(b), userContext(u), schema(s) {}
+ MethodContext(BrokerProxyImpl& b, void* u, const SchemaMethod* s) : broker(b), userContext(u), schema(s) {}
virtual ~MethodContext() {}
void reserve() {}
void release();
@@ -210,8 +215,8 @@ namespace qmf {
BrokerProxyImpl& broker;
void* userContext;
- SchemaMethodImpl* schema;
- MethodResponseImpl::Ptr methodResponse;
+ const SchemaMethod* schema;
+ MethodResponsePtr methodResponse;
};
diff --git a/qpid/cpp/src/qmf/ConnectionSettingsImpl.cpp b/qpid/cpp/src/qmf/ConnectionSettingsImpl.cpp
index 034ab18395..fa0257aeba 100644
--- a/qpid/cpp/src/qmf/ConnectionSettingsImpl.cpp
+++ b/qpid/cpp/src/qmf/ConnectionSettingsImpl.cpp
@@ -44,13 +44,13 @@ const string attrRetryDelayMin("retryDelayMin");
const string attrRetryDelayMax("retryDelayMax");
const string attrRetryDelayFactor("retryDelayFactor");
-ConnectionSettingsImpl::ConnectionSettingsImpl(ConnectionSettings* e) :
- envelope(e), retryDelayMin(1), retryDelayMax(64), retryDelayFactor(2)
+ConnectionSettingsImpl::ConnectionSettingsImpl() :
+ retryDelayMin(1), retryDelayMax(64), retryDelayFactor(2)
{
}
-ConnectionSettingsImpl::ConnectionSettingsImpl(ConnectionSettings* e, const string& /*url*/) :
- envelope(e), retryDelayMin(1), retryDelayMax(64), retryDelayFactor(2)
+ConnectionSettingsImpl::ConnectionSettingsImpl(const string& /*url*/) :
+ retryDelayMin(1), retryDelayMax(64), retryDelayFactor(2)
{
// TODO: Parse the URL
}
@@ -251,73 +251,18 @@ void ConnectionSettingsImpl::getRetrySettings(int* min, int* max, int* factor) c
// Wrappers
//==================================================================
-ConnectionSettings::ConnectionSettings(const ConnectionSettings& from)
-{
- impl = new ConnectionSettingsImpl(*from.impl);
-}
-
-ConnectionSettings::ConnectionSettings()
-{
- impl = new ConnectionSettingsImpl(this);
-}
-
-ConnectionSettings::ConnectionSettings(const char* url)
-{
- impl = new ConnectionSettingsImpl(this, url);
-}
-
-ConnectionSettings::~ConnectionSettings()
-{
- delete impl;
-}
-
-void ConnectionSettings::setAttr(const char* key, const Value& value)
-{
- impl->setAttr(key, value);
-}
-
-Value ConnectionSettings::getAttr(const char* key) const
-{
- return impl->getAttr(key);
-}
-
-const char* ConnectionSettings::getAttrString() const
-{
- return impl->getAttrString().c_str();
-}
-
-void ConnectionSettings::transportTcp(uint16_t port)
-{
- impl->transportTcp(port);
-}
-
-void ConnectionSettings::transportSsl(uint16_t port)
-{
- impl->transportSsl(port);
-}
-
-void ConnectionSettings::transportRdma(uint16_t port)
-{
- impl->transportRdma(port);
-}
-
-void ConnectionSettings::authAnonymous(const char* username)
-{
- impl->authAnonymous(username);
-}
-
-void ConnectionSettings::authPlain(const char* username, const char* password)
-{
- impl->authPlain(username, password);
-}
-
-void ConnectionSettings::authGssapi(const char* serviceName, uint32_t minSsf, uint32_t maxSsf)
-{
- impl->authGssapi(serviceName, minSsf, maxSsf);
-}
-
-void ConnectionSettings::setRetry(int delayMin, int delayMax, int delayFactor)
-{
- impl->setRetry(delayMin, delayMax, delayFactor);
-}
+ConnectionSettings::ConnectionSettings(const ConnectionSettings& from) { impl = new ConnectionSettingsImpl(*from.impl); }
+ConnectionSettings::ConnectionSettings() { impl = new ConnectionSettingsImpl(); }
+ConnectionSettings::ConnectionSettings(const char* url) { impl = new ConnectionSettingsImpl(url); }
+ConnectionSettings::~ConnectionSettings() { delete impl; }
+void ConnectionSettings::setAttr(const char* key, const Value& value) { impl->setAttr(key, value); }
+Value ConnectionSettings::getAttr(const char* key) const { return impl->getAttr(key); }
+const char* ConnectionSettings::getAttrString() const { return impl->getAttrString().c_str(); }
+void ConnectionSettings::transportTcp(uint16_t port) { impl->transportTcp(port); }
+void ConnectionSettings::transportSsl(uint16_t port) { impl->transportSsl(port); }
+void ConnectionSettings::transportRdma(uint16_t port) { impl->transportRdma(port); }
+void ConnectionSettings::authAnonymous(const char* username) { impl->authAnonymous(username); }
+void ConnectionSettings::authPlain(const char* username, const char* password) { impl->authPlain(username, password); }
+void ConnectionSettings::authGssapi(const char* serviceName, uint32_t minSsf, uint32_t maxSsf) { impl->authGssapi(serviceName, minSsf, maxSsf); }
+void ConnectionSettings::setRetry(int delayMin, int delayMax, int delayFactor) { impl->setRetry(delayMin, delayMax, delayFactor); }
diff --git a/qpid/cpp/src/qmf/ConnectionSettingsImpl.h b/qpid/cpp/src/qmf/ConnectionSettingsImpl.h
index a177233cf3..4e34cfe870 100644
--- a/qpid/cpp/src/qmf/ConnectionSettingsImpl.h
+++ b/qpid/cpp/src/qmf/ConnectionSettingsImpl.h
@@ -29,7 +29,6 @@
namespace qmf {
class ConnectionSettingsImpl {
- ConnectionSettings* envelope;
qpid::client::ConnectionSettings clientSettings;
mutable std::string attrString;
int retryDelayMin;
@@ -37,8 +36,8 @@ namespace qmf {
int retryDelayFactor;
public:
- ConnectionSettingsImpl(ConnectionSettings* e);
- ConnectionSettingsImpl(ConnectionSettings* e, const std::string& url);
+ ConnectionSettingsImpl();
+ ConnectionSettingsImpl(const std::string& url);
~ConnectionSettingsImpl() {}
void setAttr(const std::string& key, const Value& value);
Value getAttr(const std::string& key) const;
diff --git a/qpid/cpp/src/qmf/ConsoleEngine.h b/qpid/cpp/src/qmf/ConsoleEngine.h
index f04bbcea47..a5aa990a76 100644
--- a/qpid/cpp/src/qmf/ConsoleEngine.h
+++ b/qpid/cpp/src/qmf/ConsoleEngine.h
@@ -45,7 +45,6 @@ namespace qmf {
*/
class MethodResponse {
public:
- MethodResponse(MethodResponseImpl* impl);
MethodResponse(const MethodResponse& from);
~MethodResponse();
uint32_t getStatus() const;
@@ -53,7 +52,9 @@ namespace qmf {
const Value* getArgs() const;
private:
+ friend class MethodResponseImpl;
friend class ConsoleEngineImpl;
+ MethodResponse(MethodResponseImpl* impl);
MethodResponseImpl* impl;
};
@@ -62,7 +63,6 @@ namespace qmf {
*/
class QueryResponse {
public:
- QueryResponse(QueryResponseImpl* impl);
~QueryResponse();
uint32_t getStatus() const;
const Value* getException() const;
@@ -70,7 +70,9 @@ namespace qmf {
const Object* getObject(uint32_t idx) const;
private:
+ friend class QueryResponseImpl;
friend class QueryContext;
+ QueryResponse(QueryResponseImpl* impl);
QueryResponseImpl *impl;
};
@@ -129,12 +131,13 @@ namespace qmf {
*/
class AgentProxy {
public:
- AgentProxy(AgentProxyImpl* impl);
~AgentProxy();
const char* getLabel() const;
private:
+ friend class AgentProxyImpl;
friend class BrokerProxyImpl;
+ AgentProxy(AgentProxyImpl* impl);
AgentProxyImpl* impl;
};
@@ -163,6 +166,7 @@ namespace qmf {
private:
friend class ConsoleEngineImpl;
+ friend class StaticContext;
BrokerProxyImpl* impl;
};
diff --git a/qpid/cpp/src/qmf/ConsoleEngineImpl.cpp b/qpid/cpp/src/qmf/ConsoleEngineImpl.cpp
index d71bf93105..7c34af48c6 100644
--- a/qpid/cpp/src/qmf/ConsoleEngineImpl.cpp
+++ b/qpid/cpp/src/qmf/ConsoleEngineImpl.cpp
@@ -56,7 +56,7 @@ ConsoleEvent ConsoleEventImpl::copy()
::memset(&item, 0, sizeof(ConsoleEvent));
item.kind = kind;
- item.agent = agent.get() ? agent->envelope : 0;
+ item.agent = agent.get();
item.classKey = classKey.get();
item.object = object;
item.context = context;
@@ -68,8 +68,7 @@ ConsoleEvent ConsoleEventImpl::copy()
return item;
}
-ConsoleEngineImpl::ConsoleEngineImpl(ConsoleEngine* e, const ConsoleSettings& s) :
- envelope(e), settings(s)
+ConsoleEngineImpl::ConsoleEngineImpl(const ConsoleSettings& s) : settings(s)
{
bindingList.push_back(pair<string, string>(string(), "schema.#"));
if (settings.rcvObjects && settings.rcvEvents && settings.rcvHeartbeats && !settings.userBindings) {
@@ -192,7 +191,7 @@ ClassKind ConsoleEngineImpl::getClassKind(const SchemaClassKey* key) const
return CLASS_OBJECT;
const EventClassList& eList = pIter->second.second;
- if (eList.find(key->impl) != eList.end())
+ if (eList.find(key) != eList.end())
return CLASS_EVENT;
return CLASS_OBJECT;
}
@@ -205,10 +204,10 @@ const SchemaObjectClass* ConsoleEngineImpl::getObjectClass(const SchemaClassKey*
return 0;
const ObjectClassList& oList = pIter->second.first;
- ObjectClassList::const_iterator iter = oList.find(key->impl);
+ ObjectClassList::const_iterator iter = oList.find(key);
if (iter == oList.end())
return 0;
- return iter->second->envelope;
+ return iter->second;
}
const SchemaEventClass* ConsoleEngineImpl::getEventClass(const SchemaClassKey* key) const
@@ -219,10 +218,10 @@ const SchemaEventClass* ConsoleEngineImpl::getEventClass(const SchemaClassKey* k
return 0;
const EventClassList& eList = pIter->second.second;
- EventClassList::const_iterator iter = eList.find(key->impl);
+ EventClassList::const_iterator iter = eList.find(key);
if (iter == eList.end())
return 0;
- return iter->second->envelope;
+ return iter->second;
}
void ConsoleEngineImpl::bindPackage(const char* packageName)
@@ -280,7 +279,7 @@ void ConsoleEngineImpl::learnPackage(const string& packageName)
(packageName, pair<ObjectClassList, EventClassList>(ObjectClassList(), EventClassList())));
}
-void ConsoleEngineImpl::learnClass(SchemaObjectClassImpl::Ptr cls)
+void ConsoleEngineImpl::learnClass(SchemaObjectClass* cls)
{
Mutex::ScopedLock _lock(lock);
const SchemaClassKey* key = cls->getClassKey();
@@ -289,11 +288,11 @@ void ConsoleEngineImpl::learnClass(SchemaObjectClassImpl::Ptr cls)
return;
ObjectClassList& list = pIter->second.first;
- if (list.find(key->impl) == list.end())
- list[key->impl] = cls;
+ if (list.find(key) == list.end())
+ list[key] = cls;
}
-void ConsoleEngineImpl::learnClass(SchemaEventClassImpl::Ptr cls)
+void ConsoleEngineImpl::learnClass(SchemaEventClass* cls)
{
Mutex::ScopedLock _lock(lock);
const SchemaClassKey* key = cls->getClassKey();
@@ -302,34 +301,34 @@ void ConsoleEngineImpl::learnClass(SchemaEventClassImpl::Ptr cls)
return;
EventClassList& list = pIter->second.second;
- if (list.find(key->impl) == list.end())
- list[key->impl] = cls;
+ if (list.find(key) == list.end())
+ list[key] = cls;
}
-bool ConsoleEngineImpl::haveClass(const SchemaClassKeyImpl& key) const
+bool ConsoleEngineImpl::haveClass(const SchemaClassKey* key) const
{
Mutex::ScopedLock _lock(lock);
- PackageList::const_iterator pIter = packages.find(key.getPackageName());
+ PackageList::const_iterator pIter = packages.find(key->getPackageName());
if (pIter == packages.end())
return false;
const ObjectClassList& oList = pIter->second.first;
const EventClassList& eList = pIter->second.second;
- return oList.find(&key) != oList.end() || eList.find(&key) != eList.end();
+ return oList.find(key) != oList.end() || eList.find(key) != eList.end();
}
-SchemaObjectClassImpl::Ptr ConsoleEngineImpl::getSchema(const SchemaClassKeyImpl& key) const
+SchemaObjectClass* ConsoleEngineImpl::getSchema(const SchemaClassKey* key) const
{
Mutex::ScopedLock _lock(lock);
- PackageList::const_iterator pIter = packages.find(key.getPackageName());
+ PackageList::const_iterator pIter = packages.find(key->getPackageName());
if (pIter == packages.end())
- return SchemaObjectClassImpl::Ptr();
+ return 0;
const ObjectClassList& oList = pIter->second.first;
- ObjectClassList::const_iterator iter = oList.find(&key);
+ ObjectClassList::const_iterator iter = oList.find(key);
if (iter == oList.end())
- return SchemaObjectClassImpl::Ptr();
+ return 0;
return iter->second;
}
@@ -338,7 +337,7 @@ SchemaObjectClassImpl::Ptr ConsoleEngineImpl::getSchema(const SchemaClassKeyImpl
// Wrappers
//==================================================================
-ConsoleEngine::ConsoleEngine(const ConsoleSettings& settings) : impl(new ConsoleEngineImpl(this, settings)) {}
+ConsoleEngine::ConsoleEngine(const ConsoleSettings& settings) : impl(new ConsoleEngineImpl(settings)) {}
ConsoleEngine::~ConsoleEngine() { delete impl; }
bool ConsoleEngine::getEvent(ConsoleEvent& event) const { return impl->getEvent(event); }
void ConsoleEngine::popEvent() { impl->popEvent(); }
diff --git a/qpid/cpp/src/qmf/ConsoleEngineImpl.h b/qpid/cpp/src/qmf/ConsoleEngineImpl.h
index b95cb7523a..a78e8409b9 100644
--- a/qpid/cpp/src/qmf/ConsoleEngineImpl.h
+++ b/qpid/cpp/src/qmf/ConsoleEngineImpl.h
@@ -46,13 +46,14 @@
#include <iostream>
#include <fstream>
#include <boost/shared_ptr.hpp>
+#include <boost/noncopyable.hpp>
namespace qmf {
struct ConsoleEventImpl {
typedef boost::shared_ptr<ConsoleEventImpl> Ptr;
ConsoleEvent::EventKind kind;
- boost::shared_ptr<AgentProxyImpl> agent;
+ boost::shared_ptr<AgentProxy> agent;
std::string name;
boost::shared_ptr<SchemaClassKey> classKey;
Object* object;
@@ -66,9 +67,9 @@ namespace qmf {
ConsoleEvent copy();
};
- class ConsoleEngineImpl {
+ class ConsoleEngineImpl : public boost::noncopyable {
public:
- ConsoleEngineImpl(ConsoleEngine* e, const ConsoleSettings& settings = ConsoleSettings());
+ ConsoleEngineImpl(const ConsoleSettings& settings = ConsoleSettings());
~ConsoleEngineImpl();
bool getEvent(ConsoleEvent& event) const;
@@ -99,7 +100,6 @@ namespace qmf {
private:
friend class BrokerProxyImpl;
- ConsoleEngine* envelope;
const ConsoleSettings& settings;
mutable qpid::sys::Mutex lock;
std::deque<ConsoleEventImpl::Ptr> eventQueue;
@@ -110,22 +110,22 @@ namespace qmf {
// class key pointers. The default behavior would be to compare the pointer
// addresses themselves.
struct KeyCompare {
- bool operator()(const SchemaClassKeyImpl* left, const SchemaClassKeyImpl* right) const {
+ bool operator()(const SchemaClassKey* left, const SchemaClassKey* right) const {
return *left < *right;
}
};
- typedef std::map<const SchemaClassKeyImpl*, SchemaObjectClassImpl::Ptr, KeyCompare> ObjectClassList;
- typedef std::map<const SchemaClassKeyImpl*, SchemaEventClassImpl::Ptr, KeyCompare> EventClassList;
+ typedef std::map<const SchemaClassKey*, SchemaObjectClass*, KeyCompare> ObjectClassList;
+ typedef std::map<const SchemaClassKey*, SchemaEventClass*, KeyCompare> EventClassList;
typedef std::map<std::string, std::pair<ObjectClassList, EventClassList> > PackageList;
PackageList packages;
void learnPackage(const std::string& packageName);
- void learnClass(SchemaObjectClassImpl::Ptr cls);
- void learnClass(SchemaEventClassImpl::Ptr cls);
- bool haveClass(const SchemaClassKeyImpl& key) const;
- SchemaObjectClassImpl::Ptr getSchema(const SchemaClassKeyImpl& key) const;
+ void learnClass(SchemaObjectClass* cls);
+ void learnClass(SchemaEventClass* cls);
+ bool haveClass(const SchemaClassKey* key) const;
+ SchemaObjectClass* getSchema(const SchemaClassKey* key) const;
};
}
diff --git a/qpid/cpp/src/qmf/Object.h b/qpid/cpp/src/qmf/Object.h
index db89dbb700..ded6714429 100644
--- a/qpid/cpp/src/qmf/Object.h
+++ b/qpid/cpp/src/qmf/Object.h
@@ -30,7 +30,6 @@ namespace qmf {
class Object {
public:
Object(const SchemaObjectClass* type);
- Object(ObjectImpl* impl);
Object(const Object& from);
virtual ~Object();
@@ -41,6 +40,10 @@ namespace qmf {
Value* getValue(char* key) const;
void invokeMethod(const char* methodName, const Value* inArgs, void* context) const;
+ private:
+ friend class ObjectImpl;
+ friend class AgentEngineImpl;
+ Object(ObjectImpl* impl);
ObjectImpl* impl;
};
}
diff --git a/qpid/cpp/src/qmf/ObjectId.h b/qpid/cpp/src/qmf/ObjectId.h
index e894e0b39c..0e603bc898 100644
--- a/qpid/cpp/src/qmf/ObjectId.h
+++ b/qpid/cpp/src/qmf/ObjectId.h
@@ -31,7 +31,6 @@ namespace qmf {
public:
ObjectId();
ObjectId(const ObjectId& from);
- ObjectId(ObjectIdImpl* impl);
~ObjectId();
uint64_t getObjectNum() const;
@@ -45,6 +44,14 @@ namespace qmf {
bool operator<=(const ObjectId& other) const;
bool operator>=(const ObjectId& other) const;
+ private:
+ friend class ObjectIdImpl;
+ friend class ObjectImpl;
+ friend class BrokerProxyImpl;
+ friend class QueryImpl;
+ friend class ValueImpl;
+ friend class AgentEngineImpl;
+ ObjectId(ObjectIdImpl* impl);
ObjectIdImpl* impl;
};
}
diff --git a/qpid/cpp/src/qmf/ObjectIdImpl.cpp b/qpid/cpp/src/qmf/ObjectIdImpl.cpp
index c0618ccc49..b993c2dbdf 100644
--- a/qpid/cpp/src/qmf/ObjectIdImpl.cpp
+++ b/qpid/cpp/src/qmf/ObjectIdImpl.cpp
@@ -32,13 +32,12 @@ void AgentAttachment::setBanks(uint32_t broker, uint32_t agent)
((uint64_t) (agent & 0x0fffffff));
}
-ObjectIdImpl::ObjectIdImpl(Buffer& buffer) : envelope(new ObjectId(this)), agent(0)
+ObjectIdImpl::ObjectIdImpl(Buffer& buffer) : agent(0)
{
decode(buffer);
}
-ObjectIdImpl::ObjectIdImpl(AgentAttachment* a, uint8_t flags, uint16_t seq, uint64_t object) :
- envelope(new ObjectId(this)), agent(a)
+ObjectIdImpl::ObjectIdImpl(AgentAttachment* a, uint8_t flags, uint16_t seq, uint64_t object) : agent(a)
{
first =
((uint64_t) (flags & 0x0f)) << 60 |
@@ -46,6 +45,18 @@ ObjectIdImpl::ObjectIdImpl(AgentAttachment* a, uint8_t flags, uint16_t seq, uint
second = object;
}
+ObjectId* ObjectIdImpl::factory(Buffer& buffer)
+{
+ ObjectIdImpl* impl(new ObjectIdImpl(buffer));
+ return new ObjectId(impl);
+}
+
+ObjectId* ObjectIdImpl::factory(AgentAttachment* agent, uint8_t flags, uint16_t seq, uint64_t object)
+{
+ ObjectIdImpl* impl(new ObjectIdImpl(agent, flags, seq, object));
+ return new ObjectId(impl);
+}
+
void ObjectIdImpl::decode(Buffer& buffer)
{
first = buffer.getLongLong();
@@ -135,58 +146,17 @@ bool ObjectIdImpl::operator>(const ObjectIdImpl& other) const
// Wrappers
//==================================================================
-ObjectId::ObjectId() : impl(new ObjectIdImpl(this)) {}
-
+ObjectId::ObjectId() : impl(new ObjectIdImpl()) {}
ObjectId::ObjectId(const ObjectId& from) : impl(new ObjectIdImpl(*(from.impl))) {}
-
ObjectId::ObjectId(ObjectIdImpl* i) : impl(i) {}
+ObjectId::~ObjectId() { delete impl; }
+uint64_t ObjectId::getObjectNum() const { return impl->getObjectNum(); }
+uint32_t ObjectId::getObjectNumHi() const { return impl->getObjectNumHi(); }
+uint32_t ObjectId::getObjectNumLo() const { return impl->getObjectNumLo(); }
+bool ObjectId::isDurable() const { return impl->isDurable(); }
+bool ObjectId::operator==(const ObjectId& other) const { return *impl == *other.impl; }
+bool ObjectId::operator<(const ObjectId& other) const { return *impl < *other.impl; }
+bool ObjectId::operator>(const ObjectId& other) const { return *impl > *other.impl; }
+bool ObjectId::operator<=(const ObjectId& other) const { return !(*impl > *other.impl); }
+bool ObjectId::operator>=(const ObjectId& other) const { return !(*impl < *other.impl); }
-ObjectId::~ObjectId()
-{
- delete impl;
-}
-
-uint64_t ObjectId::getObjectNum() const
-{
- return impl->getObjectNum();
-}
-
-uint32_t ObjectId::getObjectNumHi() const
-{
- return impl->getObjectNumHi();
-}
-
-uint32_t ObjectId::getObjectNumLo() const
-{
- return impl->getObjectNumLo();
-}
-
-bool ObjectId::isDurable() const
-{
- return impl->isDurable();
-}
-
-bool ObjectId::operator==(const ObjectId& other) const
-{
- return *impl == *other.impl;
-}
-
-bool ObjectId::operator<(const ObjectId& other) const
-{
- return *impl < *other.impl;
-}
-
-bool ObjectId::operator>(const ObjectId& other) const
-{
- return *impl > *other.impl;
-}
-
-bool ObjectId::operator<=(const ObjectId& other) const
-{
- return !(*impl > *other.impl);
-}
-
-bool ObjectId::operator>=(const ObjectId& other) const
-{
- return !(*impl < *other.impl);
-}
diff --git a/qpid/cpp/src/qmf/ObjectIdImpl.h b/qpid/cpp/src/qmf/ObjectIdImpl.h
index 38d231237f..7a0950cd9d 100644
--- a/qpid/cpp/src/qmf/ObjectIdImpl.h
+++ b/qpid/cpp/src/qmf/ObjectIdImpl.h
@@ -34,15 +34,17 @@ namespace qmf {
};
struct ObjectIdImpl {
- ObjectId* envelope;
AgentAttachment* agent;
uint64_t first;
uint64_t second;
- ObjectIdImpl(ObjectId* e) : envelope(e), agent(0), first(0), second(0) {}
+ ObjectIdImpl() : agent(0), first(0), second(0) {}
ObjectIdImpl(qpid::framing::Buffer& buffer);
ObjectIdImpl(AgentAttachment* agent, uint8_t flags, uint16_t seq, uint64_t object);
+ static ObjectId* factory(qpid::framing::Buffer& buffer);
+ static ObjectId* factory(AgentAttachment* agent, uint8_t flags, uint16_t seq, uint64_t object);
+
void decode(qpid::framing::Buffer& buffer);
void encode(qpid::framing::Buffer& buffer) const;
void fromString(const std::string& repr);
diff --git a/qpid/cpp/src/qmf/ObjectImpl.cpp b/qpid/cpp/src/qmf/ObjectImpl.cpp
index 216a9d883e..f78808376f 100644
--- a/qpid/cpp/src/qmf/ObjectImpl.cpp
+++ b/qpid/cpp/src/qmf/ObjectImpl.cpp
@@ -27,9 +27,7 @@ using namespace qmf;
using namespace qpid::sys;
using qpid::framing::Buffer;
-ObjectImpl::ObjectImpl(Object* e, const SchemaObjectClass* type) :
- envelope(e), objectClass(type), broker(0), createTime(uint64_t(Duration(now()))),
- destroyTime(0), lastUpdatedTime(createTime)
+ObjectImpl::ObjectImpl(const SchemaObjectClass* type) : objectClass(type), broker(0), createTime(uint64_t(Duration(now()))), destroyTime(0), lastUpdatedTime(createTime)
{
int propCount = objectClass->getPropertyCount();
int statCount = objectClass->getStatisticCount();
@@ -47,7 +45,7 @@ ObjectImpl::ObjectImpl(Object* e, const SchemaObjectClass* type) :
}
ObjectImpl::ObjectImpl(const SchemaObjectClass* type, BrokerProxyImpl* b, Buffer& buffer, bool prop, bool stat, bool managed) :
- envelope(new Object(this)), objectClass(type), broker(b), createTime(0), destroyTime(0), lastUpdatedTime(0)
+ objectClass(type), broker(b), createTime(0), destroyTime(0), lastUpdatedTime(0)
{
int idx;
@@ -55,7 +53,7 @@ ObjectImpl::ObjectImpl(const SchemaObjectClass* type, BrokerProxyImpl* b, Buffer
lastUpdatedTime = buffer.getLongLong();
createTime = buffer.getLongLong();
destroyTime = buffer.getLongLong();
- objectId.reset(new ObjectIdImpl(buffer));
+ objectId.reset(ObjectIdImpl::factory(buffer));
}
if (prop) {
@@ -67,8 +65,8 @@ ObjectImpl::ObjectImpl(const SchemaObjectClass* type, BrokerProxyImpl* b, Buffer
if (excludes.count(prop->getName()) != 0) {
properties[prop->getName()] = ValuePtr(new Value(prop->getType()));
} else {
- ValueImpl* pval = new ValueImpl(prop->getType(), buffer);
- properties[prop->getName()] = ValuePtr(pval->envelope);
+ Value* pval = ValueImpl::factory(prop->getType(), buffer);
+ properties[prop->getName()] = ValuePtr(pval);
}
}
}
@@ -77,12 +75,18 @@ ObjectImpl::ObjectImpl(const SchemaObjectClass* type, BrokerProxyImpl* b, Buffer
int statCount = objectClass->getStatisticCount();
for (idx = 0; idx < statCount; idx++) {
const SchemaStatistic* stat = objectClass->getStatistic(idx);
- ValueImpl* sval = new ValueImpl(stat->getType(), buffer);
- statistics[stat->getName()] = ValuePtr(sval->envelope);
+ Value* sval = ValueImpl::factory(stat->getType(), buffer);
+ statistics[stat->getName()] = ValuePtr(sval);
}
}
}
+Object* ObjectImpl::factory(const SchemaObjectClass* type, BrokerProxyImpl* b, Buffer& buffer, bool prop, bool stat, bool managed)
+{
+ ObjectImpl* impl(new ObjectImpl(type, b, buffer, prop, stat, managed));
+ return new Object(impl);
+}
+
ObjectImpl::~ObjectImpl()
{
}
@@ -150,7 +154,7 @@ void ObjectImpl::encodeManagedObjectData(qpid::framing::Buffer& buffer) const
buffer.putLongLong(lastUpdatedTime);
buffer.putLongLong(createTime);
buffer.putLongLong(destroyTime);
- objectId->encode(buffer);
+ objectId->impl->encode(buffer);
}
void ObjectImpl::encodeProperties(qpid::framing::Buffer& buffer) const
@@ -203,7 +207,7 @@ void ObjectImpl::encodeStatistics(qpid::framing::Buffer& buffer) const
// Wrappers
//==================================================================
-Object::Object(const SchemaObjectClass* type) : impl(new ObjectImpl(this, type)) {}
+Object::Object(const SchemaObjectClass* type) : impl(new ObjectImpl(type)) {}
Object::Object(ObjectImpl* i) : impl(i) {}
Object::Object(const Object& from) : impl(new ObjectImpl(*(from.impl))) {}
Object::~Object() { delete impl; }
diff --git a/qpid/cpp/src/qmf/ObjectImpl.h b/qpid/cpp/src/qmf/ObjectImpl.h
index 4ac5a31b54..565e9a2704 100644
--- a/qpid/cpp/src/qmf/ObjectImpl.h
+++ b/qpid/cpp/src/qmf/ObjectImpl.h
@@ -33,27 +33,29 @@ namespace qmf {
class BrokerProxyImpl;
+ typedef boost::shared_ptr<Object> ObjectPtr;
+
struct ObjectImpl {
- typedef boost::shared_ptr<ObjectImpl> Ptr;
typedef boost::shared_ptr<Value> ValuePtr;
- Object* envelope;
const SchemaObjectClass* objectClass;
BrokerProxyImpl* broker;
- boost::shared_ptr<ObjectIdImpl> objectId;
+ boost::shared_ptr<ObjectId> objectId;
uint64_t createTime;
uint64_t destroyTime;
uint64_t lastUpdatedTime;
mutable std::map<std::string, ValuePtr> properties;
mutable std::map<std::string, ValuePtr> statistics;
- ObjectImpl(Object* e, const SchemaObjectClass* type);
+ ObjectImpl(const SchemaObjectClass* type);
ObjectImpl(const SchemaObjectClass* type, BrokerProxyImpl* b, qpid::framing::Buffer& buffer,
bool prop, bool stat, bool managed);
+ static Object* factory(const SchemaObjectClass* type, BrokerProxyImpl* b, qpid::framing::Buffer& buffer,
+ bool prop, bool stat, bool managed);
~ObjectImpl();
void destroy();
- const ObjectId* getObjectId() const { return objectId.get() ? objectId->envelope : 0; }
- void setObjectId(ObjectId* oid) { objectId.reset(oid->impl); }
+ const ObjectId* getObjectId() const { return objectId.get(); }
+ void setObjectId(ObjectId* oid) { objectId.reset(oid); }
const SchemaObjectClass* getClass() const { return objectClass; }
Value* getValue(const std::string& key) const;
void invokeMethod(const std::string& methodName, const Value* inArgs, void* context) const;
diff --git a/qpid/cpp/src/qmf/Query.h b/qpid/cpp/src/qmf/Query.h
index 875749862e..96ad2b0d24 100644
--- a/qpid/cpp/src/qmf/Query.h
+++ b/qpid/cpp/src/qmf/Query.h
@@ -77,7 +77,7 @@ namespace qmf {
Query(const char* className, const char* packageName);
Query(const SchemaClassKey* key);
Query(const ObjectId* oid);
- Query(QueryImpl* impl);
+ Query(const Query& from);
~Query();
void setSelect(const QueryOperand* criterion);
@@ -96,6 +96,10 @@ namespace qmf {
const char* getOrderBy() const;
bool getDecreasing() const;
+ private:
+ friend class QueryImpl;
+ friend class BrokerProxyImpl;
+ Query(QueryImpl* impl);
QueryImpl* impl;
};
}
diff --git a/qpid/cpp/src/qmf/QueryImpl.cpp b/qpid/cpp/src/qmf/QueryImpl.cpp
index f75a9aa5d5..c10bfb7018 100644
--- a/qpid/cpp/src/qmf/QueryImpl.cpp
+++ b/qpid/cpp/src/qmf/QueryImpl.cpp
@@ -45,6 +45,12 @@ QueryImpl::QueryImpl(Buffer& buffer)
// TODO
}
+Query* QueryImpl::factory(Buffer& buffer)
+{
+ QueryImpl* impl(new QueryImpl(buffer));
+ return new Query(impl);
+}
+
void QueryImpl::encode(Buffer& buffer) const
{
FieldTable ft;
@@ -69,14 +75,17 @@ QueryElement::QueryElement(const char* attrName, const Value* value, ValueOper o
QueryElement::QueryElement(QueryElementImpl* i) : impl(i) {}
QueryElement::~QueryElement() { delete impl; }
bool QueryElement::evaluate(const Object* object) const { return impl->evaluate(object); }
+
QueryExpression::QueryExpression(ExprOper oper, const QueryOperand* operand1, const QueryOperand* operand2) : impl(new QueryExpressionImpl(oper, operand1, operand2)) {}
QueryExpression::QueryExpression(QueryExpressionImpl* i) : impl(i) {}
QueryExpression::~QueryExpression() { delete impl; }
bool QueryExpression::evaluate(const Object* object) const { return impl->evaluate(object); }
+
Query::Query(const char* className, const char* packageName) : impl(new QueryImpl(className, packageName)) {}
Query::Query(const SchemaClassKey* key) : impl(new QueryImpl(key)) {}
Query::Query(const ObjectId* oid) : impl(new QueryImpl(oid)) {}
Query::Query(QueryImpl* i) : impl(i) {}
+Query::Query(const Query& from) : impl(new QueryImpl(*(from.impl))) {}
Query::~Query() { delete impl; }
void Query::setSelect(const QueryOperand* criterion) { impl->setSelect(criterion); }
void Query::setLimit(uint32_t maxResults) { impl->setLimit(maxResults); }
diff --git a/qpid/cpp/src/qmf/QueryImpl.h b/qpid/cpp/src/qmf/QueryImpl.h
index 4a56a457c0..afc2c754e6 100644
--- a/qpid/cpp/src/qmf/QueryImpl.h
+++ b/qpid/cpp/src/qmf/QueryImpl.h
@@ -34,39 +34,36 @@ namespace qpid {
namespace qmf {
struct QueryElementImpl {
- QueryElementImpl(const std::string& a, const Value* v, ValueOper o) :
- envelope(new QueryElement(this)), attrName(a), value(v), oper(o) {}
+ QueryElementImpl(const std::string& a, const Value* v, ValueOper o) : attrName(a), value(v), oper(o) {}
~QueryElementImpl() {}
bool evaluate(const Object* object) const;
- QueryElement* envelope;
std::string attrName;
const Value* value;
ValueOper oper;
};
struct QueryExpressionImpl {
- QueryExpressionImpl(ExprOper o, const QueryOperand* operand1, const QueryOperand* operand2) :
- envelope(new QueryExpression(this)), oper(o), left(operand1), right(operand2) {}
+ QueryExpressionImpl(ExprOper o, const QueryOperand* operand1, const QueryOperand* operand2) : oper(o), left(operand1), right(operand2) {}
~QueryExpressionImpl() {}
bool evaluate(const Object* object) const;
- QueryExpression* envelope;
ExprOper oper;
const QueryOperand* left;
const QueryOperand* right;
};
struct QueryImpl {
- QueryImpl(Query* e) : envelope(e), select(0) {}
- QueryImpl(const std::string& c, const std::string& p) :
- envelope(new Query(this)), packageName(p), className(c) {}
- QueryImpl(const SchemaClassKey* key) :
- envelope(new Query(this)), packageName(key->getPackageName()), className(key->getClassName()) {}
- QueryImpl(const ObjectId* oid) :
- envelope(new Query(this)), oid(new ObjectId(*oid)) {}
+ // Constructors mapped to public
+ QueryImpl(const std::string& c, const std::string& p) : packageName(p), className(c), select(0), resultLimit(0) {}
+ QueryImpl(const SchemaClassKey* key) : packageName(key->getPackageName()), className(key->getClassName()), select(0), resultLimit(0) {}
+ QueryImpl(const ObjectId* oid) : oid(new ObjectId(*oid)), select(0), resultLimit(0) {}
+
+ // Factory constructors
QueryImpl(qpid::framing::Buffer& buffer);
+
~QueryImpl() {};
+ static Query* factory(qpid::framing::Buffer& buffer);
void setSelect(const QueryOperand* criterion) { select = criterion; }
void setLimit(uint32_t maxResults) { resultLimit = maxResults; }
@@ -88,7 +85,6 @@ namespace qmf {
void encode(qpid::framing::Buffer& buffer) const;
- Query* envelope;
std::string packageName;
std::string className;
boost::shared_ptr<ObjectId> oid;
diff --git a/qpid/cpp/src/qmf/ResilientConnection.cpp b/qpid/cpp/src/qmf/ResilientConnection.cpp
index 7ec03cf4da..be7837b829 100644
--- a/qpid/cpp/src/qmf/ResilientConnection.cpp
+++ b/qpid/cpp/src/qmf/ResilientConnection.cpp
@@ -38,6 +38,7 @@
#include <vector>
#include <set>
#include <boost/intrusive_ptr.hpp>
+#include <boost/noncopyable.hpp>
using namespace std;
using namespace qmf;
@@ -77,7 +78,7 @@ namespace qmf {
void stop();
};
- class ResilientConnectionImpl : public qpid::sys::Runnable {
+ class ResilientConnectionImpl : public qpid::sys::Runnable, public boost::noncopyable {
public:
ResilientConnectionImpl(const ConnectionSettings& settings);
~ResilientConnectionImpl();
diff --git a/qpid/cpp/src/qmf/Schema.h b/qpid/cpp/src/qmf/Schema.h
index 1123acc3b8..92801c40fe 100644
--- a/qpid/cpp/src/qmf/Schema.h
+++ b/qpid/cpp/src/qmf/Schema.h
@@ -42,7 +42,7 @@ namespace qmf {
class SchemaArgument {
public:
SchemaArgument(const char* name, Typecode typecode);
- SchemaArgument(SchemaArgumentImpl* impl);
+ SchemaArgument(const SchemaArgument& from);
~SchemaArgument();
void setDirection(Direction dir);
void setUnit(const char* val);
@@ -53,6 +53,11 @@ namespace qmf {
const char* getUnit() const;
const char* getDesc() const;
+ private:
+ friend class SchemaArgumentImpl;
+ friend class SchemaMethodImpl;
+ friend class SchemaEventClassImpl;
+ SchemaArgument(SchemaArgumentImpl* impl);
SchemaArgumentImpl* impl;
};
@@ -61,15 +66,20 @@ namespace qmf {
class SchemaMethod {
public:
SchemaMethod(const char* name);
- SchemaMethod(SchemaMethodImpl* impl);
+ SchemaMethod(const SchemaMethod& from);
~SchemaMethod();
- void addArgument(const SchemaArgument& argument);
+ 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 class SchemaMethodImpl;
+ friend class SchemaObjectClassImpl;
+ friend class AgentEngineImpl;
+ SchemaMethod(SchemaMethodImpl* impl);
SchemaMethodImpl* impl;
};
@@ -78,7 +88,7 @@ namespace qmf {
class SchemaProperty {
public:
SchemaProperty(const char* name, Typecode typecode);
- SchemaProperty(SchemaPropertyImpl* impl);
+ SchemaProperty(const SchemaProperty& from);
~SchemaProperty();
void setAccess(Access access);
void setIndex(bool val);
@@ -93,6 +103,10 @@ namespace qmf {
const char* getUnit() const;
const char* getDesc() const;
+ private:
+ friend class SchemaPropertyImpl;
+ friend class SchemaObjectClassImpl;
+ SchemaProperty(SchemaPropertyImpl* impl);
SchemaPropertyImpl* impl;
};
@@ -101,7 +115,7 @@ namespace qmf {
class SchemaStatistic {
public:
SchemaStatistic(const char* name, Typecode typecode);
- SchemaStatistic(SchemaStatisticImpl* impl);
+ SchemaStatistic(const SchemaStatistic& from);
~SchemaStatistic();
void setUnit(const char* val);
void setDesc(const char* desc);
@@ -110,6 +124,10 @@ namespace qmf {
const char* getUnit() const;
const char* getDesc() const;
+ private:
+ friend class SchemaStatisticImpl;
+ friend class SchemaObjectClassImpl;
+ SchemaStatistic(SchemaStatisticImpl* impl);
SchemaStatisticImpl* impl;
};
@@ -117,13 +135,21 @@ namespace qmf {
*/
class SchemaClassKey {
public:
- SchemaClassKey(SchemaClassKeyImpl* impl);
+ 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 class SchemaClassKeyImpl;
+ friend class BrokerProxyImpl;
+ friend class ConsoleEngineImpl;
+ SchemaClassKey(SchemaClassKeyImpl* impl);
SchemaClassKeyImpl* impl;
};
@@ -132,11 +158,11 @@ namespace qmf {
class SchemaObjectClass {
public:
SchemaObjectClass(const char* package, const char* name);
- SchemaObjectClass(SchemaObjectClassImpl* impl);
+ SchemaObjectClass(const SchemaObjectClass& from);
~SchemaObjectClass();
- void addProperty(const SchemaProperty& property);
- void addStatistic(const SchemaStatistic& statistic);
- void addMethod(const SchemaMethod& method);
+ void addProperty(const SchemaProperty* property);
+ void addStatistic(const SchemaStatistic* statistic);
+ void addMethod(const SchemaMethod* method);
const SchemaClassKey* getClassKey() const;
int getPropertyCount() const;
@@ -146,6 +172,11 @@ namespace qmf {
const SchemaStatistic* getStatistic(int idx) const;
const SchemaMethod* getMethod(int idx) const;
+ private:
+ friend class SchemaObjectClassImpl;
+ friend class BrokerProxyImpl;
+ friend class AgentEngineImpl;
+ SchemaObjectClass(SchemaObjectClassImpl* impl);
SchemaObjectClassImpl* impl;
};
@@ -154,15 +185,20 @@ namespace qmf {
class SchemaEventClass {
public:
SchemaEventClass(const char* package, const char* name);
- SchemaEventClass(SchemaEventClassImpl* impl);
+ SchemaEventClass(const SchemaEventClass& from);
~SchemaEventClass();
- void addArgument(const SchemaArgument& argument);
+ 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 class SchemaEventClassImpl;
+ friend class BrokerProxyImpl;
+ friend class AgentEngineImpl;
+ SchemaEventClass(SchemaEventClassImpl* impl);
SchemaEventClassImpl* impl;
};
}
diff --git a/qpid/cpp/src/qmf/SchemaImpl.cpp b/qpid/cpp/src/qmf/SchemaImpl.cpp
index 3eb14c3952..1028281445 100644
--- a/qpid/cpp/src/qmf/SchemaImpl.cpp
+++ b/qpid/cpp/src/qmf/SchemaImpl.cpp
@@ -81,7 +81,7 @@ bool SchemaHash::operator>(const SchemaHash& other) const
return ::memcmp(&hash, &other.hash, 16) > 0;
}
-SchemaArgumentImpl::SchemaArgumentImpl(Buffer& buffer) : envelope(new SchemaArgument(this))
+SchemaArgumentImpl::SchemaArgumentImpl(Buffer& buffer)
{
FieldTable map;
map.decode(buffer);
@@ -99,6 +99,12 @@ SchemaArgumentImpl::SchemaArgumentImpl(Buffer& buffer) : envelope(new SchemaArgu
dir = DIR_IN_OUT;
}
+SchemaArgument* SchemaArgumentImpl::factory(Buffer& buffer)
+{
+ SchemaArgumentImpl* impl(new SchemaArgumentImpl(buffer));
+ return new SchemaArgument(impl);
+}
+
void SchemaArgumentImpl::encode(Buffer& buffer) const
{
FieldTable map;
@@ -128,7 +134,7 @@ void SchemaArgumentImpl::updateHash(SchemaHash& hash) const
hash.update(description);
}
-SchemaMethodImpl::SchemaMethodImpl(Buffer& buffer) : envelope(new SchemaMethod(this))
+SchemaMethodImpl::SchemaMethodImpl(Buffer& buffer)
{
FieldTable map;
int argCount;
@@ -139,11 +145,17 @@ SchemaMethodImpl::SchemaMethodImpl(Buffer& buffer) : envelope(new SchemaMethod(t
description = map.getAsString("desc");
for (int idx = 0; idx < argCount; idx++) {
- SchemaArgumentImpl* arg = new SchemaArgumentImpl(buffer);
- addArgument(*arg->envelope);
+ SchemaArgument* arg = SchemaArgumentImpl::factory(buffer);
+ addArgument(arg);
}
}
+SchemaMethod* SchemaMethodImpl::factory(Buffer& buffer)
+{
+ SchemaMethodImpl* impl(new SchemaMethodImpl(buffer));
+ return new SchemaMethod(impl);
+}
+
void SchemaMethodImpl::encode(Buffer& buffer) const
{
FieldTable map;
@@ -154,23 +166,23 @@ void SchemaMethodImpl::encode(Buffer& buffer) const
map.setString("desc", description);
map.encode(buffer);
- for (vector<SchemaArgumentImpl*>::const_iterator iter = arguments.begin();
+ for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin();
iter != arguments.end(); iter++)
- (*iter)->encode(buffer);
+ (*iter)->impl->encode(buffer);
}
-void SchemaMethodImpl::addArgument(const SchemaArgument& argument)
+void SchemaMethodImpl::addArgument(const SchemaArgument* argument)
{
- arguments.push_back(argument.impl);
+ arguments.push_back(argument);
}
const SchemaArgument* SchemaMethodImpl::getArgument(int idx) const
{
int count = 0;
- for (vector<SchemaArgumentImpl*>::const_iterator iter = arguments.begin();
+ for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin();
iter != arguments.end(); iter++, count++)
if (idx == count)
- return (*iter)->envelope;
+ return (*iter);
return 0;
}
@@ -178,12 +190,12 @@ void SchemaMethodImpl::updateHash(SchemaHash& hash) const
{
hash.update(name);
hash.update(description);
- for (vector<SchemaArgumentImpl*>::const_iterator iter = arguments.begin();
+ for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin();
iter != arguments.end(); iter++)
- (*iter)->updateHash(hash);
+ (*iter)->impl->updateHash(hash);
}
-SchemaPropertyImpl::SchemaPropertyImpl(Buffer& buffer) : envelope(new SchemaProperty(this))
+SchemaPropertyImpl::SchemaPropertyImpl(Buffer& buffer)
{
FieldTable map;
map.decode(buffer);
@@ -197,6 +209,12 @@ SchemaPropertyImpl::SchemaPropertyImpl(Buffer& buffer) : envelope(new SchemaProp
description = map.getAsString("desc");
}
+SchemaProperty* SchemaPropertyImpl::factory(Buffer& buffer)
+{
+ SchemaPropertyImpl* impl(new SchemaPropertyImpl(buffer));
+ return new SchemaProperty(impl);
+}
+
void SchemaPropertyImpl::encode(Buffer& buffer) const
{
FieldTable map;
@@ -225,7 +243,7 @@ void SchemaPropertyImpl::updateHash(SchemaHash& hash) const
hash.update(description);
}
-SchemaStatisticImpl::SchemaStatisticImpl(Buffer& buffer) : envelope(new SchemaStatistic(this))
+SchemaStatisticImpl::SchemaStatisticImpl(Buffer& buffer)
{
FieldTable map;
map.decode(buffer);
@@ -236,6 +254,12 @@ SchemaStatisticImpl::SchemaStatisticImpl(Buffer& buffer) : envelope(new SchemaSt
description = map.getAsString("desc");
}
+SchemaStatistic* SchemaStatisticImpl::factory(Buffer& buffer)
+{
+ SchemaStatisticImpl* impl(new SchemaStatisticImpl(buffer));
+ return new SchemaStatistic(impl);
+}
+
void SchemaStatisticImpl::encode(Buffer& buffer) const
{
FieldTable map;
@@ -258,16 +282,26 @@ void SchemaStatisticImpl::updateHash(SchemaHash& hash) const
hash.update(description);
}
-SchemaClassKeyImpl::SchemaClassKeyImpl(const string& p, const string& n, const SchemaHash& h) :
- envelope(new SchemaClassKey(this)), package(p), name(n), hash(h) {}
+SchemaClassKeyImpl::SchemaClassKeyImpl(const string& p, const string& n, const SchemaHash& h) : package(p), name(n), hash(h) {}
-SchemaClassKeyImpl::SchemaClassKeyImpl(Buffer& buffer) :
- envelope(new SchemaClassKey(this)), package(packageContainer), name(nameContainer), hash(hashContainer)
+SchemaClassKeyImpl::SchemaClassKeyImpl(Buffer& buffer) : package(packageContainer), name(nameContainer), hash(hashContainer)
{
buffer.getShortString(packageContainer);
buffer.getShortString(nameContainer);
hashContainer.decode(buffer);
-}
+}
+
+SchemaClassKey* SchemaClassKeyImpl::factory(const string& package, const string& name, const SchemaHash& hash)
+{
+ SchemaClassKeyImpl* impl(new SchemaClassKeyImpl(package, name, hash));
+ return new SchemaClassKey(impl);
+}
+
+SchemaClassKey* SchemaClassKeyImpl::factory(Buffer& buffer)
+{
+ SchemaClassKeyImpl* impl(new SchemaClassKeyImpl(buffer));
+ return new SchemaClassKey(impl);
+}
void SchemaClassKeyImpl::encode(Buffer& buffer) const
{
@@ -300,8 +334,7 @@ string SchemaClassKeyImpl::str() const
return str.str();
}
-SchemaObjectClassImpl::SchemaObjectClassImpl(Buffer& buffer) :
- envelope(new SchemaObjectClass(this)), hasHash(true), classKey(package, name, hash)
+SchemaObjectClassImpl::SchemaObjectClassImpl(Buffer& buffer) : hasHash(true), classKey(SchemaClassKeyImpl::factory(package, name, hash))
{
buffer.getShortString(package);
buffer.getShortString(name);
@@ -313,21 +346,27 @@ SchemaObjectClassImpl::SchemaObjectClassImpl(Buffer& buffer) :
uint16_t methodCount = buffer.getShort();
for (uint16_t idx = 0; idx < propCount; idx++) {
- SchemaPropertyImpl* property = new SchemaPropertyImpl(buffer);
- addProperty(*property->envelope);
+ const SchemaProperty* property = SchemaPropertyImpl::factory(buffer);
+ addProperty(property);
}
for (uint16_t idx = 0; idx < statCount; idx++) {
- SchemaStatisticImpl* statistic = new SchemaStatisticImpl(buffer);
- addStatistic(*statistic->envelope);
+ const SchemaStatistic* statistic = SchemaStatisticImpl::factory(buffer);
+ addStatistic(statistic);
}
for (uint16_t idx = 0; idx < methodCount; idx++) {
- SchemaMethodImpl* method = new SchemaMethodImpl(buffer);
- addMethod(*method->envelope);
+ SchemaMethod* method = SchemaMethodImpl::factory(buffer);
+ addMethod(method);
}
}
+SchemaObjectClass* SchemaObjectClassImpl::factory(Buffer& buffer)
+{
+ SchemaObjectClassImpl* impl(new SchemaObjectClassImpl(buffer));
+ return new SchemaObjectClass(impl);
+}
+
void SchemaObjectClassImpl::encode(Buffer& buffer) const
{
buffer.putOctet((uint8_t) CLASS_OBJECT);
@@ -339,15 +378,15 @@ void SchemaObjectClassImpl::encode(Buffer& buffer) const
buffer.putShort((uint16_t) statistics.size());
buffer.putShort((uint16_t) methods.size());
- for (vector<SchemaPropertyImpl*>::const_iterator iter = properties.begin();
+ for (vector<const SchemaProperty*>::const_iterator iter = properties.begin();
iter != properties.end(); iter++)
- (*iter)->encode(buffer);
- for (vector<SchemaStatisticImpl*>::const_iterator iter = statistics.begin();
+ (*iter)->impl->encode(buffer);
+ for (vector<const SchemaStatistic*>::const_iterator iter = statistics.begin();
iter != statistics.end(); iter++)
- (*iter)->encode(buffer);
- for (vector<SchemaMethodImpl*>::const_iterator iter = methods.begin();
+ (*iter)->impl->encode(buffer);
+ for (vector<const SchemaMethod*>::const_iterator iter = methods.begin();
iter != methods.end(); iter++)
- (*iter)->encode(buffer);
+ (*iter)->impl->encode(buffer);
}
const SchemaClassKey* SchemaObjectClassImpl::getClassKey() const
@@ -356,67 +395,66 @@ const SchemaClassKey* SchemaObjectClassImpl::getClassKey() const
hasHash = true;
hash.update(package);
hash.update(name);
- for (vector<SchemaPropertyImpl*>::const_iterator iter = properties.begin();
+ for (vector<const SchemaProperty*>::const_iterator iter = properties.begin();
iter != properties.end(); iter++)
- (*iter)->updateHash(hash);
- for (vector<SchemaStatisticImpl*>::const_iterator iter = statistics.begin();
+ (*iter)->impl->updateHash(hash);
+ for (vector<const SchemaStatistic*>::const_iterator iter = statistics.begin();
iter != statistics.end(); iter++)
- (*iter)->updateHash(hash);
- for (vector<SchemaMethodImpl*>::const_iterator iter = methods.begin();
+ (*iter)->impl->updateHash(hash);
+ for (vector<const SchemaMethod*>::const_iterator iter = methods.begin();
iter != methods.end(); iter++)
- (*iter)->updateHash(hash);
+ (*iter)->impl->updateHash(hash);
}
- return classKey.envelope;
+ return classKey.get();
}
-void SchemaObjectClassImpl::addProperty(const SchemaProperty& property)
+void SchemaObjectClassImpl::addProperty(const SchemaProperty* property)
{
- properties.push_back(property.impl);
+ properties.push_back(property);
}
-void SchemaObjectClassImpl::addStatistic(const SchemaStatistic& statistic)
+void SchemaObjectClassImpl::addStatistic(const SchemaStatistic* statistic)
{
- statistics.push_back(statistic.impl);
+ statistics.push_back(statistic);
}
-void SchemaObjectClassImpl::addMethod(const SchemaMethod& method)
+void SchemaObjectClassImpl::addMethod(const SchemaMethod* method)
{
- methods.push_back(method.impl);
+ methods.push_back(method);
}
const SchemaProperty* SchemaObjectClassImpl::getProperty(int idx) const
{
int count = 0;
- for (vector<SchemaPropertyImpl*>::const_iterator iter = properties.begin();
+ for (vector<const SchemaProperty*>::const_iterator iter = properties.begin();
iter != properties.end(); iter++, count++)
if (idx == count)
- return (*iter)->envelope;
+ return *iter;
return 0;
}
const SchemaStatistic* SchemaObjectClassImpl::getStatistic(int idx) const
{
int count = 0;
- for (vector<SchemaStatisticImpl*>::const_iterator iter = statistics.begin();
+ for (vector<const SchemaStatistic*>::const_iterator iter = statistics.begin();
iter != statistics.end(); iter++, count++)
if (idx == count)
- return (*iter)->envelope;
+ return *iter;
return 0;
}
const SchemaMethod* SchemaObjectClassImpl::getMethod(int idx) const
{
int count = 0;
- for (vector<SchemaMethodImpl*>::const_iterator iter = methods.begin();
+ for (vector<const SchemaMethod*>::const_iterator iter = methods.begin();
iter != methods.end(); iter++, count++)
if (idx == count)
- return (*iter)->envelope;
+ return *iter;
return 0;
}
-SchemaEventClassImpl::SchemaEventClassImpl(Buffer& buffer) :
- envelope(new SchemaEventClass(this)), hasHash(true), classKey(package, name, hash)
+SchemaEventClassImpl::SchemaEventClassImpl(Buffer& buffer) : hasHash(true), classKey(SchemaClassKeyImpl::factory(package, name, hash))
{
buffer.getShortString(package);
buffer.getShortString(name);
@@ -426,11 +464,17 @@ SchemaEventClassImpl::SchemaEventClassImpl(Buffer& buffer) :
uint16_t argCount = buffer.getShort();
for (uint16_t idx = 0; idx < argCount; idx++) {
- SchemaArgumentImpl* argument = new SchemaArgumentImpl(buffer);
- addArgument(*argument->envelope);
+ SchemaArgument* argument = SchemaArgumentImpl::factory(buffer);
+ addArgument(argument);
}
}
+SchemaEventClass* SchemaEventClassImpl::factory(Buffer& buffer)
+{
+ SchemaEventClassImpl* impl(new SchemaEventClassImpl(buffer));
+ return new SchemaEventClass(impl);
+}
+
void SchemaEventClassImpl::encode(Buffer& buffer) const
{
buffer.putOctet((uint8_t) CLASS_EVENT);
@@ -439,9 +483,9 @@ void SchemaEventClassImpl::encode(Buffer& buffer) const
hash.encode(buffer);
buffer.putShort((uint16_t) arguments.size());
- for (vector<SchemaArgumentImpl*>::const_iterator iter = arguments.begin();
+ for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin();
iter != arguments.end(); iter++)
- (*iter)->encode(buffer);
+ (*iter)->impl->encode(buffer);
}
const SchemaClassKey* SchemaEventClassImpl::getClassKey() const
@@ -450,25 +494,25 @@ const SchemaClassKey* SchemaEventClassImpl::getClassKey() const
hasHash = true;
hash.update(package);
hash.update(name);
- for (vector<SchemaArgumentImpl*>::const_iterator iter = arguments.begin();
+ for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin();
iter != arguments.end(); iter++)
- (*iter)->updateHash(hash);
+ (*iter)->impl->updateHash(hash);
}
- return classKey.envelope;
+ return classKey.get();
}
-void SchemaEventClassImpl::addArgument(const SchemaArgument& argument)
+void SchemaEventClassImpl::addArgument(const SchemaArgument* argument)
{
- arguments.push_back(argument.impl);
+ arguments.push_back(argument);
}
const SchemaArgument* SchemaEventClassImpl::getArgument(int idx) const
{
int count = 0;
- for (vector<SchemaArgumentImpl*>::const_iterator iter = arguments.begin();
+ for (vector<const SchemaArgument*>::const_iterator iter = arguments.begin();
iter != arguments.end(); iter++, count++)
if (idx == count)
- return (*iter)->envelope;
+ return (*iter);
return 0;
}
@@ -477,8 +521,9 @@ const SchemaArgument* SchemaEventClassImpl::getArgument(int idx) const
// Wrappers
//==================================================================
-SchemaArgument::SchemaArgument(const char* name, Typecode typecode) { impl = new SchemaArgumentImpl(this, name, typecode); }
+SchemaArgument::SchemaArgument(const char* name, Typecode typecode) { impl = new SchemaArgumentImpl(name, typecode); }
SchemaArgument::SchemaArgument(SchemaArgumentImpl* i) : impl(i) {}
+SchemaArgument::SchemaArgument(const SchemaArgument& from) : impl(new SchemaArgumentImpl(*(from.impl))) {}
SchemaArgument::~SchemaArgument() { delete impl; }
void SchemaArgument::setDirection(Direction dir) { impl->setDirection(dir); }
void SchemaArgument::setUnit(const char* val) { impl->setUnit(val); }
@@ -488,17 +533,21 @@ Typecode SchemaArgument::getType() const { return impl->getType(); }
Direction SchemaArgument::getDirection() const { return impl->getDirection(); }
const char* SchemaArgument::getUnit() const { return impl->getUnit().c_str(); }
const char* SchemaArgument::getDesc() const { return impl->getDesc().c_str(); }
-SchemaMethod::SchemaMethod(const char* name) { impl = new SchemaMethodImpl(this, name); }
+
+SchemaMethod::SchemaMethod(const char* name) : impl(new SchemaMethodImpl(name)) {}
SchemaMethod::SchemaMethod(SchemaMethodImpl* i) : impl(i) {}
+SchemaMethod::SchemaMethod(const SchemaMethod& from) : impl(new SchemaMethodImpl(*(from.impl))) {}
SchemaMethod::~SchemaMethod() { delete impl; }
-void SchemaMethod::addArgument(const SchemaArgument& argument) { impl->addArgument(argument); }
+void SchemaMethod::addArgument(const SchemaArgument* argument) { impl->addArgument(argument); }
void SchemaMethod::setDesc(const char* desc) { impl->setDesc(desc); }
const char* SchemaMethod::getName() const { return impl->getName().c_str(); }
const char* SchemaMethod::getDesc() const { return impl->getDesc().c_str(); }
int SchemaMethod::getArgumentCount() const { return impl->getArgumentCount(); }
const SchemaArgument* SchemaMethod::getArgument(int idx) const { return impl->getArgument(idx); }
-SchemaProperty::SchemaProperty(const char* name, Typecode typecode) { impl = new SchemaPropertyImpl(this, name, typecode); }
+
+SchemaProperty::SchemaProperty(const char* name, Typecode typecode) : impl(new SchemaPropertyImpl(name, typecode)) {}
SchemaProperty::SchemaProperty(SchemaPropertyImpl* i) : impl(i) {}
+SchemaProperty::SchemaProperty(const SchemaProperty& from) : impl(new SchemaPropertyImpl(*(from.impl))) {}
SchemaProperty::~SchemaProperty() { delete impl; }
void SchemaProperty::setAccess(Access access) { impl->setAccess(access); }
void SchemaProperty::setIndex(bool val) { impl->setIndex(val); }
@@ -512,8 +561,10 @@ bool SchemaProperty::isIndex() const { return impl->isIndex(); }
bool SchemaProperty::isOptional() const { return impl->isOptional(); }
const char* SchemaProperty::getUnit() const { return impl->getUnit().c_str(); }
const char* SchemaProperty::getDesc() const { return impl->getDesc().c_str(); }
-SchemaStatistic::SchemaStatistic(const char* name, Typecode typecode) { impl = new SchemaStatisticImpl(this, name, typecode); }
+
+SchemaStatistic::SchemaStatistic(const char* name, Typecode typecode) : impl(new SchemaStatisticImpl(name, typecode)) {}
SchemaStatistic::SchemaStatistic(SchemaStatisticImpl* i) : impl(i) {}
+SchemaStatistic::SchemaStatistic(const SchemaStatistic& from) : impl(new SchemaStatisticImpl(*(from.impl))) {}
SchemaStatistic::~SchemaStatistic() { delete impl; }
void SchemaStatistic::setUnit(const char* val) { impl->setUnit(val); }
void SchemaStatistic::setDesc(const char* desc) { impl->setDesc(desc); }
@@ -521,17 +572,23 @@ const char* SchemaStatistic::getName() const { return impl->getName().c_str(); }
Typecode SchemaStatistic::getType() const { return impl->getType(); }
const char* SchemaStatistic::getUnit() const { return impl->getUnit().c_str(); }
const char* SchemaStatistic::getDesc() const { return impl->getDesc().c_str(); }
+
SchemaClassKey::SchemaClassKey(SchemaClassKeyImpl* i) : impl(i) {}
+SchemaClassKey::SchemaClassKey(const SchemaClassKey& from) : impl(new SchemaClassKeyImpl(*(from.impl))) {}
SchemaClassKey::~SchemaClassKey() { delete impl; }
const char* SchemaClassKey::getPackageName() const { return impl->getPackageName().c_str(); }
const char* SchemaClassKey::getClassName() const { return impl->getClassName().c_str(); }
const uint8_t* SchemaClassKey::getHash() const { return impl->getHash(); }
-SchemaObjectClass::SchemaObjectClass(const char* package, const char* name) { impl = new SchemaObjectClassImpl(this, package, name); }
+bool SchemaClassKey::operator==(const SchemaClassKey& other) const { return *impl == *(other.impl); }
+bool SchemaClassKey::operator<(const SchemaClassKey& other) const { return *impl < *(other.impl); }
+
+SchemaObjectClass::SchemaObjectClass(const char* package, const char* name) : impl(new SchemaObjectClassImpl(package, name)) {}
SchemaObjectClass::SchemaObjectClass(SchemaObjectClassImpl* i) : impl(i) {}
+SchemaObjectClass::SchemaObjectClass(const SchemaObjectClass& from) : impl(new SchemaObjectClassImpl(*(from.impl))) {}
SchemaObjectClass::~SchemaObjectClass() { delete impl; }
-void SchemaObjectClass::addProperty(const SchemaProperty& property) { impl->addProperty(property); }
-void SchemaObjectClass::addStatistic(const SchemaStatistic& statistic) { impl->addStatistic(statistic); }
-void SchemaObjectClass::addMethod(const SchemaMethod& method) { impl->addMethod(method); }
+void SchemaObjectClass::addProperty(const SchemaProperty* property) { impl->addProperty(property); }
+void SchemaObjectClass::addStatistic(const SchemaStatistic* statistic) { impl->addStatistic(statistic); }
+void SchemaObjectClass::addMethod(const SchemaMethod* method) { impl->addMethod(method); }
const SchemaClassKey* SchemaObjectClass::getClassKey() const { return impl->getClassKey(); }
int SchemaObjectClass::getPropertyCount() const { return impl->getPropertyCount(); }
int SchemaObjectClass::getStatisticCount() const { return impl->getStatisticCount(); }
@@ -539,10 +596,12 @@ int SchemaObjectClass::getMethodCount() const { return impl->getMethodCount(); }
const SchemaProperty* SchemaObjectClass::getProperty(int idx) const { return impl->getProperty(idx); }
const SchemaStatistic* SchemaObjectClass::getStatistic(int idx) const { return impl->getStatistic(idx); }
const SchemaMethod* SchemaObjectClass::getMethod(int idx) const { return impl->getMethod(idx); }
-SchemaEventClass::SchemaEventClass(const char* package, const char* name) { impl = new SchemaEventClassImpl(this, package, name); }
+
+SchemaEventClass::SchemaEventClass(const char* package, const char* name) : impl(new SchemaEventClassImpl(package, name)) {}
SchemaEventClass::SchemaEventClass(SchemaEventClassImpl* i) : impl(i) {}
+SchemaEventClass::SchemaEventClass(const SchemaEventClass& from) : impl(new SchemaEventClassImpl(*(from.impl))) {}
SchemaEventClass::~SchemaEventClass() { delete impl; }
-void SchemaEventClass::addArgument(const SchemaArgument& argument) { impl->addArgument(argument); }
+void SchemaEventClass::addArgument(const SchemaArgument* argument) { impl->addArgument(argument); }
void SchemaEventClass::setDesc(const char* desc) { impl->setDesc(desc); }
const SchemaClassKey* SchemaEventClass::getClassKey() const { return impl->getClassKey(); }
int SchemaEventClass::getArgumentCount() const { return impl->getArgumentCount(); }
diff --git a/qpid/cpp/src/qmf/SchemaImpl.h b/qpid/cpp/src/qmf/SchemaImpl.h
index 035d99aecd..190a0c7f26 100644
--- a/qpid/cpp/src/qmf/SchemaImpl.h
+++ b/qpid/cpp/src/qmf/SchemaImpl.h
@@ -21,7 +21,6 @@
*/
#include "qmf/Schema.h"
-#include <boost/shared_ptr.hpp>
#include <string>
#include <vector>
#include <qpid/framing/Buffer.h>
@@ -52,16 +51,15 @@ namespace qmf {
};
struct SchemaArgumentImpl {
- SchemaArgument* envelope;
std::string name;
Typecode typecode;
Direction dir;
std::string unit;
std::string description;
- SchemaArgumentImpl(SchemaArgument* e, const char* n, Typecode t) :
- envelope(e), name(n), typecode(t), dir(DIR_IN) {}
+ SchemaArgumentImpl(const char* n, Typecode t) : name(n), typecode(t), dir(DIR_IN) {}
SchemaArgumentImpl(qpid::framing::Buffer& buffer);
+ static SchemaArgument* factory(qpid::framing::Buffer& buffer);
void encode(qpid::framing::Buffer& buffer) const;
void setDirection(Direction d) { dir = d; }
void setUnit(const char* val) { unit = val; }
@@ -75,15 +73,15 @@ namespace qmf {
};
struct SchemaMethodImpl {
- SchemaMethod* envelope;
std::string name;
std::string description;
- std::vector<SchemaArgumentImpl*> arguments;
+ std::vector<const SchemaArgument*> arguments;
- SchemaMethodImpl(SchemaMethod* e, const char* n) : envelope(e), name(n) {}
+ SchemaMethodImpl(const char* n) : name(n) {}
SchemaMethodImpl(qpid::framing::Buffer& buffer);
+ static SchemaMethod* factory(qpid::framing::Buffer& buffer);
void encode(qpid::framing::Buffer& buffer) const;
- void addArgument(const SchemaArgument& argument);
+ void addArgument(const SchemaArgument* argument);
void setDesc(const char* desc) { description = desc; }
const std::string& getName() const { return name; }
const std::string& getDesc() const { return description; }
@@ -93,7 +91,6 @@ namespace qmf {
};
struct SchemaPropertyImpl {
- SchemaProperty* envelope;
std::string name;
Typecode typecode;
Access access;
@@ -102,10 +99,9 @@ namespace qmf {
std::string unit;
std::string description;
- SchemaPropertyImpl(SchemaProperty* e, const char* n, Typecode t) :
- envelope(e), name(n), typecode(t), access(ACCESS_READ_ONLY),
- index(false), optional(false) {}
+ SchemaPropertyImpl(const char* n, Typecode t) : name(n), typecode(t), access(ACCESS_READ_ONLY), index(false), optional(false) {}
SchemaPropertyImpl(qpid::framing::Buffer& buffer);
+ static SchemaProperty* factory(qpid::framing::Buffer& buffer);
void encode(qpid::framing::Buffer& buffer) const;
void setAccess(Access a) { access = a; }
void setIndex(bool val) { index = val; }
@@ -123,15 +119,14 @@ namespace qmf {
};
struct SchemaStatisticImpl {
- SchemaStatistic* envelope;
std::string name;
Typecode typecode;
std::string unit;
std::string description;
- SchemaStatisticImpl(SchemaStatistic* e, const char* n, Typecode t) :
- envelope(e), name(n), typecode(t) {}
+ SchemaStatisticImpl(const char* n, Typecode t) : name(n), typecode(t) {}
SchemaStatisticImpl(qpid::framing::Buffer& buffer);
+ static SchemaStatistic* factory(qpid::framing::Buffer& buffer);
void encode(qpid::framing::Buffer& buffer) const;
void setUnit(const char* val) { unit = val; }
void setDesc(const char* desc) { description = desc; }
@@ -143,7 +138,6 @@ namespace qmf {
};
struct SchemaClassKeyImpl {
- const SchemaClassKey* envelope;
const std::string& package;
const std::string& name;
const SchemaHash& hash;
@@ -156,6 +150,8 @@ namespace qmf {
SchemaClassKeyImpl(const std::string& package, const std::string& name, const SchemaHash& hash);
SchemaClassKeyImpl(qpid::framing::Buffer& buffer);
+ static SchemaClassKey* factory(const std::string& package, const std::string& name, const SchemaHash& hash);
+ static SchemaClassKey* factory(qpid::framing::Buffer& buffer);
const std::string& getPackageName() const { return package; }
const std::string& getClassName() const { return name; }
@@ -168,24 +164,24 @@ namespace qmf {
};
struct SchemaObjectClassImpl {
- typedef boost::shared_ptr<SchemaObjectClassImpl> Ptr;
- SchemaObjectClass* envelope;
std::string package;
std::string name;
mutable SchemaHash hash;
mutable bool hasHash;
- SchemaClassKeyImpl classKey;
- std::vector<SchemaPropertyImpl*> properties;
- std::vector<SchemaStatisticImpl*> statistics;
- std::vector<SchemaMethodImpl*> methods;
+ std::auto_ptr<SchemaClassKey> classKey;
+ std::vector<const SchemaProperty*> properties;
+ std::vector<const SchemaStatistic*> statistics;
+ std::vector<const SchemaMethod*> methods;
- SchemaObjectClassImpl(SchemaObjectClass* e, const char* p, const char* n) :
- envelope(e), package(p), name(n), hasHash(false), classKey(package, name, hash) {}
+ SchemaObjectClassImpl(const char* p, const char* n) :
+ package(p), name(n), hasHash(false), classKey(SchemaClassKeyImpl::factory(package, name, hash)) {}
SchemaObjectClassImpl(qpid::framing::Buffer& buffer);
+ static SchemaObjectClass* factory(qpid::framing::Buffer& buffer);
+
void encode(qpid::framing::Buffer& buffer) const;
- void addProperty(const SchemaProperty& property);
- void addStatistic(const SchemaStatistic& statistic);
- void addMethod(const SchemaMethod& method);
+ void addProperty(const SchemaProperty* property);
+ void addStatistic(const SchemaStatistic* statistic);
+ void addMethod(const SchemaMethod* method);
const SchemaClassKey* getClassKey() const;
int getPropertyCount() const { return properties.size(); }
@@ -197,21 +193,21 @@ namespace qmf {
};
struct SchemaEventClassImpl {
- typedef boost::shared_ptr<SchemaEventClassImpl> Ptr;
- SchemaEventClass* envelope;
std::string package;
std::string name;
mutable SchemaHash hash;
mutable bool hasHash;
- SchemaClassKeyImpl classKey;
+ std::auto_ptr<SchemaClassKey> classKey;
std::string description;
- std::vector<SchemaArgumentImpl*> arguments;
+ std::vector<const SchemaArgument*> arguments;
- SchemaEventClassImpl(SchemaEventClass* e, const char* p, const char* n) :
- envelope(e), package(p), name(n), hasHash(false), classKey(package, name, hash) {}
+ SchemaEventClassImpl(const char* p, const char* n) :
+ package(p), name(n), hasHash(false), classKey(SchemaClassKeyImpl::factory(package, name, hash)) {}
SchemaEventClassImpl(qpid::framing::Buffer& buffer);
+ static SchemaEventClass* factory(qpid::framing::Buffer& buffer);
+
void encode(qpid::framing::Buffer& buffer) const;
- void addArgument(const SchemaArgument& argument);
+ void addArgument(const SchemaArgument* argument);
void setDesc(const char* desc) { description = desc; }
const SchemaClassKey* getClassKey() const;
diff --git a/qpid/cpp/src/qmf/Value.h b/qpid/cpp/src/qmf/Value.h
index 2ec2149110..449872764b 100644
--- a/qpid/cpp/src/qmf/Value.h
+++ b/qpid/cpp/src/qmf/Value.h
@@ -33,7 +33,6 @@ namespace qmf {
// Value();
Value(const Value& from);
Value(Typecode t, Typecode arrayType = TYPE_UINT8);
- Value(ValueImpl* impl);
~Value();
Typecode getType() const;
@@ -81,7 +80,7 @@ namespace qmf {
void setUuid(const uint8_t* val);
bool isObject() const;
- Object* asObject() const;
+ const Object* asObject() const;
void setObject(Object* val);
bool isMap() const;
@@ -106,6 +105,12 @@ namespace qmf {
void appendToArray(Value* val);
void deleteArrayItem(uint32_t idx);
+ private:
+ friend class ValueImpl;
+ friend class BrokerProxyImpl;
+ friend class ObjectImpl;
+ friend class AgentEngineImpl;
+ Value(ValueImpl* impl);
ValueImpl* impl;
};
}
diff --git a/qpid/cpp/src/qmf/ValueImpl.cpp b/qpid/cpp/src/qmf/ValueImpl.cpp
index b03d222835..652b99cae9 100644
--- a/qpid/cpp/src/qmf/ValueImpl.cpp
+++ b/qpid/cpp/src/qmf/ValueImpl.cpp
@@ -24,7 +24,7 @@ using namespace std;
using namespace qmf;
using qpid::framing::Buffer;
-ValueImpl::ValueImpl(Typecode t, Buffer& buf) : envelope(new Value(this)), typecode(t)
+ValueImpl::ValueImpl(Typecode t, Buffer& buf) : typecode(t)
{
uint64_t first;
uint64_t second;
@@ -67,16 +67,27 @@ ValueImpl::ValueImpl(Typecode t, Buffer& buf) : envelope(new Value(this)), typec
}
}
-ValueImpl::ValueImpl(Value* e, Typecode t, Typecode at) :
- envelope(e), typecode(t), valid(false), arrayTypecode(at)
+ValueImpl::ValueImpl(Typecode t, Typecode at) : typecode(t), valid(false), arrayTypecode(at)
{
}
-ValueImpl::ValueImpl(Typecode t) : envelope(new Value(this)), typecode(t)
+ValueImpl::ValueImpl(Typecode t) : typecode(t)
{
::memset(&value, 0, sizeof(value));
}
+Value* ValueImpl::factory(Typecode t, Buffer& b)
+{
+ ValueImpl* impl(new ValueImpl(t, b));
+ return new Value(impl);
+}
+
+Value* ValueImpl::factory(Typecode t)
+{
+ ValueImpl* impl(new ValueImpl(t));
+ return new Value(impl);
+}
+
ValueImpl::~ValueImpl()
{
}
@@ -118,9 +129,9 @@ bool ValueImpl::keyInMap(const char* key) const
Value* ValueImpl::byKey(const char* key)
{
if (keyInMap(key)) {
- map<std::string, VPtr>::iterator iter = mapVal.find(key);
+ map<std::string, Value>::iterator iter = mapVal.find(key);
if (iter != mapVal.end())
- return iter->second.get();
+ return &iter->second;
}
return 0;
}
@@ -128,9 +139,9 @@ Value* ValueImpl::byKey(const char* key)
const Value* ValueImpl::byKey(const char* key) const
{
if (keyInMap(key)) {
- map<std::string, VPtr>::const_iterator iter = mapVal.find(key);
+ map<std::string, Value>::const_iterator iter = mapVal.find(key);
if (iter != mapVal.end())
- return iter->second.get();
+ return &iter->second;
}
return 0;
}
@@ -142,12 +153,13 @@ void ValueImpl::deleteKey(const char* key)
void ValueImpl::insert(const char* key, Value* val)
{
- mapVal[key] = VPtr(val);
+ pair<string, Value> entry(key, *val);
+ mapVal.insert(entry);
}
const char* ValueImpl::key(uint32_t idx) const
{
- map<std::string, VPtr>::const_iterator iter = mapVal.begin();
+ map<std::string, Value>::const_iterator iter = mapVal.begin();
for (uint32_t i = 0; i < idx; i++) {
if (iter == mapVal.end())
break;
@@ -192,9 +204,9 @@ void ValueImpl::deleteArrayItem(uint32_t)
//==================================================================
Value::Value(const Value& from) : impl(new ValueImpl(*(from.impl))) {}
-Value::Value(Typecode t, Typecode at) : impl(new ValueImpl(this, t, at)) {}
+Value::Value(Typecode t, Typecode at) : impl(new ValueImpl(t, at)) {}
Value::Value(ValueImpl* i) : impl(i) {}
-Value::~Value() { delete impl; }
+Value::~Value() { delete impl;}
Typecode Value::getType() const { return impl->getType(); }
bool Value::isNull() const { return impl->isNull(); }
@@ -230,7 +242,7 @@ bool Value::isUuid() const { return impl->isUuid(); }
const uint8_t* Value::asUuid() const { return impl->asUuid(); }
void Value::setUuid(const uint8_t* val) { impl->setUuid(val); }
bool Value::isObject() const { return impl->isObject(); }
-Object* Value::asObject() const { return impl->asObject(); }
+const Object* Value::asObject() const { return impl->asObject(); }
void Value::setObject(Object* val) { impl->setObject(val); }
bool Value::isMap() const { return impl->isMap(); }
bool Value::keyInMap(const char* key) const { return impl->keyInMap(key); }
diff --git a/qpid/cpp/src/qmf/ValueImpl.h b/qpid/cpp/src/qmf/ValueImpl.h
index 5be4cbc205..03692a7fad 100644
--- a/qpid/cpp/src/qmf/ValueImpl.h
+++ b/qpid/cpp/src/qmf/ValueImpl.h
@@ -36,17 +36,14 @@ namespace qmf {
// TODO: add a modified flag and accessors
struct ValueImpl {
- typedef boost::shared_ptr<Value> VPtr;
- typedef boost::shared_ptr<Object> OPtr;
- Value* envelope;
const Typecode typecode;
bool valid;
ObjectId refVal;
std::string stringVal;
- OPtr objectVal;
- std::map<std::string, VPtr> mapVal;
- std::vector<VPtr> vectorVal;
+ std::auto_ptr<Object> objectVal;
+ std::map<std::string, Value> mapVal;
+ std::vector<Value> vectorVal;
Typecode arrayTypecode;
union {
@@ -60,9 +57,17 @@ namespace qmf {
uint8_t uuidVal[16];
} value;
- ValueImpl(Value* e, Typecode t, Typecode at);
+ ValueImpl(const ValueImpl& from) :
+ typecode(from.typecode), valid(from.valid), refVal(from.refVal), stringVal(from.stringVal),
+ objectVal(from.objectVal.get() ? new Object(*(from.objectVal)) : 0),
+ mapVal(from.mapVal), vectorVal(from.vectorVal), arrayTypecode(from.arrayTypecode),
+ value(from.value) {}
+
+ ValueImpl(Typecode t, Typecode at);
ValueImpl(Typecode t, qpid::framing::Buffer& b);
ValueImpl(Typecode t);
+ static Value* factory(Typecode t, qpid::framing::Buffer& b);
+ static Value* factory(Typecode t);
~ValueImpl();
void encode(qpid::framing::Buffer& b) const;