From: Markus R. <rol...@us...> - 2007-02-16 15:38:51
|
Update of /cvsroot/simspark/simspark/spark/zeitgeist In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv22972 Modified Files: Tag: WIN32 leaf.cpp leaf.h Log Message: - implement a registry of path references that each node caches. The references are updated from UpdateCached() Index: leaf.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/zeitgeist/leaf.cpp,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** leaf.cpp 5 Dec 2005 20:59:18 -0000 1.1 --- leaf.cpp 16 Feb 2007 15:38:42 -0000 1.1.2.1 *************** *** 168,175 **** } ! void Leaf::ClearCachedData() const { delete mCachedFullPath; mCachedFullPath = NULL; } --- 168,176 ---- } ! void Leaf::ClearCachedData() { delete mCachedFullPath; mCachedFullPath = NULL; + mCachedPaths.clear(); } *************** *** 242,243 **** --- 243,269 ---- { } + + void Leaf::UpdateCached() + { + shared_ptr<Core> core(GetCore()); + + for ( + TCachedPathSet::iterator iter = mCachedPaths.begin(); + iter != mCachedPaths.end(); + ++iter + ) + { + (*iter)->Update(core); + } + } + + void Leaf::RegisterCachedPath(Core::CachedLeafPath& path, const std::string& pathStr) + { + path.Cache(GetCore(), pathStr); + mCachedPaths.insert(&path); + } + + void Leaf::RegisterCachedPath(Core::CachedLeafPath& path) + { + mCachedPaths.insert(&path); + } Index: leaf.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/zeitgeist/leaf.h,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** leaf.h 5 Dec 2005 20:59:18 -0000 1.1 --- leaf.h 16 Feb 2007 15:38:43 -0000 1.1.2.1 *************** *** 38,42 **** #define ZEITGEIST_LEAF_H ! #include <list> #include <string> #include "object.h" --- 38,42 ---- #define ZEITGEIST_LEAF_H ! #include <set> #include <string> #include "object.h" *************** *** 55,59 **** --- 55,65 ---- // public: + template <typename _CLASS> + struct CachedPath : public Core::CachedPath<_CLASS> + { + }; + typedef std::list< boost::shared_ptr<Leaf> > TLeafList; + typedef std::set<Core::CachedLeafPath*> TCachedPathSet; // *************** *** 229,234 **** virtual void Dump() const; /** update variables from a script */ ! virtual void UpdateCached() {} /** constructs the full path of this node by walking up the --- 235,246 ---- virtual void Dump() const; + /** update and register a path reference */ + void RegisterCachedPath(Core::CachedLeafPath& path, const std::string& pathStr); + + /** register a path reference */ + void Leaf::RegisterCachedPath(Core::CachedLeafPath& path); + /** update variables from a script */ ! virtual void UpdateCached(); /** constructs the full path of this node by walking up the *************** *** 239,243 **** /** clears any cached data (e.g. the cached full path and forces the node to recalculate all values */ ! void ClearCachedData() const; /** sets the name of this node */ --- 251,255 ---- /** clears any cached data (e.g. the cached full path and forces the node to recalculate all values */ ! void ClearCachedData(); /** sets the name of this node */ *************** *** 290,294 **** which can hold children. We use a weak pointer to break the cyclic dependency. */ ! boost::weak_ptr<Node> mParent; private: --- 302,306 ---- which can hold children. We use a weak pointer to break the cyclic dependency. */ ! boost::weak_ptr<Node> mParent; private: *************** *** 298,301 **** --- 310,316 ---- /** temporary cached full path of this node in the hierarchy */ mutable std::string *mCachedFullPath; + + /** list of cached path references to other nodes */ + TCachedPathSet mCachedPaths; }; |