summaryrefslogtreecommitdiff
path: root/cpp/src/qmf/Schema.cpp
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2010-09-21 21:48:41 +0000
committerTed Ross <tross@apache.org>2010-09-21 21:48:41 +0000
commit3cfbdf0e60c94733c0a79e94bdf8627afc6bb2a4 (patch)
treee33d57bca9a2c2275e76f882484ac3ea913e83fd /cpp/src/qmf/Schema.cpp
parent449ab0f1062c0eac0234f84556de60436ba2ee9d (diff)
downloadqpid-python-3cfbdf0e60c94733c0a79e94bdf8627afc6bb2a4.tar.gz
QMFv2 Additions:
- QMFv2 schema encoding completed - Schema queries handled by the agent and initiated by the console by user request - Full query support with predicates evaluated on the agent (regex not yet implemented) - Agent filtering in the console - Agent aging in the console - Unit tests git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@999662 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qmf/Schema.cpp')
-rw-r--r--cpp/src/qmf/Schema.cpp59
1 files changed, 58 insertions, 1 deletions
diff --git a/cpp/src/qmf/Schema.cpp b/cpp/src/qmf/Schema.cpp
index 5676125c22..e003f9d06f 100644
--- a/cpp/src/qmf/Schema.cpp
+++ b/cpp/src/qmf/Schema.cpp
@@ -61,8 +61,65 @@ SchemaMethod Schema::getMethod(uint32_t i) const { return impl->getMethod(i); }
// Impl Method Bodies
//========================================================================================
-SchemaImpl::SchemaImpl(const qpid::types::Variant::Map&) : finalized(true)
+SchemaImpl::SchemaImpl(const Variant::Map& map) : finalized(false)
{
+ Variant::Map::const_iterator iter;
+ Variant::List::const_iterator lIter;
+
+ iter = map.find("_schema_id");
+ if (iter == map.end())
+ throw QmfException("Schema map missing _schema_id element");
+ schemaId = SchemaId(new SchemaIdImpl(iter->second.asMap()));
+
+ iter = map.find("_desc");
+ if (iter != map.end())
+ description = iter->second.asString();
+
+ iter = map.find("_default_severity");
+ if (iter != map.end())
+ defaultSeverity = int(iter->second.asUint32());
+
+ iter = map.find("_properties");
+ if (iter != map.end()) {
+ const Variant::List& props(iter->second.asList());
+ for (lIter = props.begin(); lIter != props.end(); lIter++)
+ addProperty(SchemaProperty(new SchemaPropertyImpl(lIter->asMap())));
+ }
+
+ iter = map.find("_methods");
+ if (iter != map.end()) {
+ const Variant::List& meths(iter->second.asList());
+ for (lIter = meths.begin(); lIter != meths.end(); lIter++)
+ addMethod(SchemaMethod(new SchemaMethodImpl(lIter->asMap())));
+ }
+
+ finalized = true;
+}
+
+
+Variant::Map SchemaImpl::asMap() const
+{
+ Variant::Map map;
+ Variant::List propList;
+ Variant::List methList;
+
+ checkNotFinal();
+
+ map["_schema_id"] = SchemaIdImplAccess::get(schemaId).asMap();
+ if (!description.empty())
+ map["_desc"] = description;
+ if (schemaId.getType() == SCHEMA_TYPE_EVENT)
+ map["_default_severity"] = uint32_t(defaultSeverity);
+
+ for (list<SchemaProperty>::const_iterator pIter = properties.begin(); pIter != properties.end(); pIter++)
+ propList.push_back(SchemaPropertyImplAccess::get(*pIter).asMap());
+
+ for (list<SchemaMethod>::const_iterator mIter = methods.begin(); mIter != methods.end(); mIter++)
+ methList.push_back(SchemaMethodImplAccess::get(*mIter).asMap());
+
+ map["_properties"] = propList;
+ map["_methods"] = methList;
+ return map;
}