From b1cd22ae277d9a987d37e2538aded2f3521bc362 Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Mon, 10 Jan 2011 14:06:16 +0000 Subject: Updates to the C++ implementation of QMFv2: 1) Consolidated string constants for the protocol into a definition file. 2) Added hooks for subscription handling. 3) Added checks to validate properties and arguments against the schema (if there is a schema). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1057199 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qmf/Data.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src/qmf/Data.cpp') diff --git a/qpid/cpp/src/qmf/Data.cpp b/qpid/cpp/src/qmf/Data.cpp index 0ceca6e1e9..c503bab445 100644 --- a/qpid/cpp/src/qmf/Data.cpp +++ b/qpid/cpp/src/qmf/Data.cpp @@ -21,8 +21,10 @@ #include "qmf/DataImpl.h" #include "qmf/DataAddrImpl.h" +#include "qmf/SchemaImpl.h" #include "qmf/SchemaIdImpl.h" #include "qmf/PrivateImplRef.h" +#include "qmf/SchemaProperty.h" using namespace std; using namespace qmf; @@ -35,8 +37,7 @@ Data::Data(const Data& s) : qmf::Handle() { PI::copy(*this, s); } Data::~Data() { PI::dtor(*this); } Data& Data::operator=(const Data& s) { return PI::assign(*this, s); } -Data::Data(const SchemaId& s) { PI::ctor(*this, new DataImpl(s)); } -void Data::setSchema(const SchemaId& s) { impl->setSchema(s); } +Data::Data(const Schema& s) { PI::ctor(*this, new DataImpl(s)); } void Data::setAddr(const DataAddr& a) { impl->setAddr(a); } void Data::setProperty(const string& k, const qpid::types::Variant& v) { impl->setProperty(k, v); } void Data::overwriteProperties(const qpid::types::Variant::Map& m) { impl->overwriteProperties(m); } @@ -103,6 +104,20 @@ Variant::Map DataImpl::asMap() const } +void DataImpl::setProperty(const std::string& k, const qpid::types::Variant& v) +{ + if (schema.isValid()) { + // + // If we have a valid schema, make sure that the property is included in the + // schema and that the variant type is compatible with the schema type. + // + if (!SchemaImplAccess::get(schema).isValidProperty(k, v)) + throw QmfException("Property '" + k + "' either not in the schema or value is of incompatible type"); + } + properties[k] = v; +} + + DataImpl& DataImplAccess::get(Data& item) { return *item.impl; -- cgit v1.2.1