diff options
| author | Ted Ross <tross@apache.org> | 2010-09-21 21:48:41 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2010-09-21 21:48:41 +0000 |
| commit | d47927b3e150057f6d615a0d00c8eff6c83320ac (patch) | |
| tree | 6cf1da8bd7a46fd3cef8251af94f88bbad0e627d /qpid/cpp/src/qmf/Schema.cpp | |
| parent | 81414cc0fb52efbd77e3e3bc83ed0c5dcb7fe83a (diff) | |
| download | qpid-python-d47927b3e150057f6d615a0d00c8eff6c83320ac.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@999662 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qmf/Schema.cpp')
| -rw-r--r-- | qpid/cpp/src/qmf/Schema.cpp | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/qpid/cpp/src/qmf/Schema.cpp b/qpid/cpp/src/qmf/Schema.cpp index 5676125c22..e003f9d06f 100644 --- a/qpid/cpp/src/qmf/Schema.cpp +++ b/qpid/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; } |
