summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/qmf/Data.cpp
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2011-01-10 14:06:16 +0000
committerTed Ross <tross@apache.org>2011-01-10 14:06:16 +0000
commitb1cd22ae277d9a987d37e2538aded2f3521bc362 (patch)
tree963a769044353a57597b1b348d8b7f5f8727b07f /qpid/cpp/src/qmf/Data.cpp
parentde0bef9f28c6e6b2238405086e3e0177ed36901a (diff)
downloadqpid-python-b1cd22ae277d9a987d37e2538aded2f3521bc362.tar.gz
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
Diffstat (limited to 'qpid/cpp/src/qmf/Data.cpp')
-rw-r--r--qpid/cpp/src/qmf/Data.cpp19
1 files changed, 17 insertions, 2 deletions
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<DataImpl>() { 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;