Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(938)

Unified Diff: src/core/model/config.cc

Issue 4644042: Implementation of ObjectMap, to add a map to the attribute system instead of a vector
Patch Set: Created 12 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/config-store/model/model-node-creator.cc ('k') | src/core/model/object-map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/model/config.cc
===================================================================
--- a/src/core/model/config.cc
+++ b/src/core/model/config.cc
@@ -22,6 +22,7 @@
#include "object.h"
#include "global-value.h"
#include "object-vector.h"
+#include "object-map.h"
#include "names.h"
#include "pointer.h"
#include "log.h"
@@ -227,6 +228,7 @@
void Canonicalize (void);
void DoResolve (std::string path, Ptr<Object> root);
void DoArrayResolve (std::string path, const ObjectVectorValue &vector);
+ void DoMapResolve (std::string path, const ObjectMapValue &vector);
void DoResolveOne (Ptr<Object> object);
std::string GetResolvedPath (void) const;
virtual void DoOne (Ptr<Object> object, std::string path) = 0;
@@ -413,6 +415,17 @@
DoArrayResolve (pathLeft, vector);
m_workStack.pop_back ();
}
+ // attempt to cast to an object map.
+ const ObjectMapChecker *mapChecker = dynamic_cast<const ObjectMapChecker *> (PeekPointer (info.checker));
+ if (mapChecker != 0)
+ {
+ NS_LOG_DEBUG ("GetAttribute(map)=" << item << " on path=" << GetResolvedPath ());
+ ObjectMapValue map;
+ root->GetAttribute (item, map);
+ m_workStack.push_back (item);
+ DoMapResolve (pathLeft, map);
+ m_workStack.pop_back ();
+ }
// this could be anything else and we don't know what to do with it.
// So, we just ignore it.
}
@@ -445,8 +458,37 @@
}
}
+void
+Resolver::DoMapResolve (std::string path, const ObjectMapValue &map)
+{
+ NS_ASSERT (path != "");
+ std::string::size_type tmp;
+ tmp = path.find ("/");
+ NS_ASSERT (tmp == 0);
+ std::string::size_type next = path.find ("/", 1);
+ if (next == std::string::npos)
+ {
+ NS_FATAL_ERROR ("map path includes no index data on path=\"" << path << "\"");
+ }
+ std::string item = path.substr (1, next - 1);
+ std::string pathLeft = path.substr (next, path.size () - next);
-class ConfigImpl
+ ArrayMatcher matcher = ArrayMatcher (item);
+ for (ObjectMapValue::Iterator it = map.Begin (); it != map.End (); it++ )
+ {
+ if (matcher.Matches ((*it).first))
+ {
+ std::ostringstream oss;
+ oss << (*it).first;
+ m_workStack.push_back (oss.str ());
+ DoResolve (pathLeft, (*it).second);
+ m_workStack.pop_back ();
+ }
+ }
+}
+
+
+class ConfigImpl
{
public:
void Set (std::string path, const AttributeValue &value);
« no previous file with comments | « src/config-store/model/model-node-creator.cc ('k') | src/core/model/object-map.h » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b