diff options
| author | Ted Ross <tross@apache.org> | 2009-09-18 20:15:15 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2009-09-18 20:15:15 +0000 |
| commit | c8fa5fa308f6ad9be22612568ace703777fbb6d9 (patch) | |
| tree | 148275652ac2572ef4bb0863736a337a5d1617e2 /qpid/cpp/src/qmf/ObjectImpl.cpp | |
| parent | d3c07faea48e2dbd57cf27fac2d9940ca6456a69 (diff) | |
| download | qpid-python-c8fa5fa308f6ad9be22612568ace703777fbb6d9.tar.gz | |
Refactored the QMF engine to adhere to the following rules regarding
the pimpl (Pointer to Implementation) pattern:
1) Impl classes have constructors matching the public constructors
2) Additional Impl constructors are accessed through a static factory function
3) All linkages to objects are to the public object
4) If a back-link (from Impl to public) is needed, the Impl class must be
derived from boost::noncopyable
5) All public classes have non-default copy constructors that make a copy of the
Impl class
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@816770 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qmf/ObjectImpl.cpp')
| -rw-r--r-- | qpid/cpp/src/qmf/ObjectImpl.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
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; } |
