From: Oliver O. <fr...@us...> - 2007-05-08 01:36:26
|
Update of /cvsroot/simspark/simspark/spark/zeitgeist In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv11623 Modified Files: Tag: projectx leaf.h leaf.cpp node.h node.cpp core.cpp Log Message: Added some changes from the rsgedit_fileref branch (Markus Rollmann) - added member GetNumberOfChildren() to node that returns the total number of children - modified SetParent() to care for a uniqe name among sibling nodes. If another sibling with the same name exists the current number of children is appended to the node name. If mporter classes create nodes in a stable order this also assures consistent node names through simulation restarts Index: core.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/zeitgeist/core.cpp,v retrieving revision 1.2.2.5.2.1 retrieving revision 1.2.2.5.2.2 diff -C2 -d -r1.2.2.5.2.1 -r1.2.2.5.2.2 *** core.cpp 30 Mar 2007 03:38:09 -0000 1.2.2.5.2.1 --- core.cpp 8 May 2007 01:36:22 -0000 1.2.2.5.2.2 *************** *** 163,167 **** void Core::CatchSignal(int sig_num) { - #ifdef __linux__ if (sig_num != SIGSEGV) { --- 163,166 ---- *************** *** 171,174 **** --- 170,174 ---- cerr << "(Core) caught signal " << sig_num << endl; + #ifdef __linux__ // retrieve the name of our executable without access to argc and // argv (this works only with linux) *************** *** 206,213 **** free (strings); cerr << "(Core) exit" << endl; exit(1); - #endif } --- 206,213 ---- free (strings); + #endif cerr << "(Core) exit" << endl; exit(1); } Index: node.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/zeitgeist/node.h,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -C2 -d -r1.1 -r1.1.4.1 *** node.h 5 Dec 2005 20:59:18 -0000 1.1 --- node.h 8 May 2007 01:36:22 -0000 1.1.4.1 *************** *** 83,86 **** --- 83,89 ---- virtual bool IsLeaf() const; + /** returns the total number of children */ + virtual int GetNumberOfChildren() const; + /** update variables from a script */ virtual void UpdateCached(); *************** *** 131,150 **** boost::shared_ptr<Node> node = boost::shared_static_cast<Node>(make_shared(GetParent())); ! while (node.get() != 0) { boost::shared_ptr<CLASS> test = boost::shared_dynamic_cast<CLASS>(node); ! if (test.get() != 0) { return test; } ! //node = boost::shared_static_cast<Node>(make_shared(node->GetParent())); node = boost::shared_static_cast<Node>(node->GetParent().lock()); ! } ! return boost::shared_ptr<CLASS>(); } --- 134,153 ---- boost::shared_ptr<Node> node = boost::shared_static_cast<Node>(make_shared(GetParent())); ! while (node.get() != 0) { boost::shared_ptr<CLASS> test = boost::shared_dynamic_cast<CLASS>(node); ! if (test.get() != 0) { return test; } ! //node = boost::shared_static_cast<Node>(make_shared(node->GetParent())); node = boost::shared_static_cast<Node>(node->GetParent().lock()); ! } ! return boost::shared_ptr<CLASS>(); } Index: leaf.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/zeitgeist/leaf.h,v retrieving revision 1.1.2.1.2.1 retrieving revision 1.1.2.1.2.2 diff -C2 -d -r1.1.2.1.2.1 -r1.1.2.1.2.2 *** leaf.h 4 May 2007 05:24:39 -0000 1.1.2.1.2.1 --- leaf.h 8 May 2007 01:36:22 -0000 1.1.2.1.2.2 *************** *** 159,163 **** */ template<class CLASS> ! void ListChildrenSupportingClass(TLeafList& list, bool recursive = false) { TLeafList::iterator lstEnd = end(); // avoid repeated virtual calls --- 159,163 ---- */ template<class CLASS> ! void ListChildrenSupportingClass(TLeafList& list, bool recursive = false) { TLeafList::iterator lstEnd = end(); // avoid repeated virtual calls *************** *** 220,223 **** --- 220,226 ---- virtual bool IsLeaf() const; + /** returns the total number of children */ + virtual int GetNumberOfChildren() const; + /** removes base from the set of children. */ virtual void RemoveChildReference(const boost::shared_ptr<Leaf> &base); Index: node.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/zeitgeist/node.cpp,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.2.2.1 diff -C2 -d -r1.1.2.2 -r1.1.2.2.2.1 *** node.cpp 16 Feb 2007 15:39:23 -0000 1.1.2.2 --- node.cpp 8 May 2007 01:36:22 -0000 1.1.2.2.2.1 *************** *** 184,187 **** --- 184,193 ---- } + int + Node::GetNumberOfChildren() const + { + return static_cast<int>(mChildren.size()); + } + bool Node::IsLeaf() const Index: leaf.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/zeitgeist/leaf.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.1.2.1 diff -C2 -d -r1.1.2.1 -r1.1.2.1.2.1 *** leaf.cpp 16 Feb 2007 15:38:42 -0000 1.1.2.1 --- leaf.cpp 8 May 2007 01:36:22 -0000 1.1.2.1.2.1 *************** *** 23,26 **** --- 23,27 ---- #include "node.h" #include <iostream> + #include <sstream> using namespace boost; *************** *** 112,115 **** --- 113,122 ---- } + int + Leaf::GetNumberOfChildren() const + { + return 0; + } + bool Leaf::IsLeaf() const { *************** *** 199,209 **** void Leaf::SetParent(const boost::shared_ptr<Node> &newParent) { ! shared_ptr<Node> oldParent = make_shared(GetParent()); if (oldParent.get() != 0) { // we have a parent, so update our state - shared_ptr<Leaf> self - = shared_static_cast<Leaf>(make_shared(GetSelf())); - // here reference count should be > 1 (at least one in the // parent, and one in this routine) --- 206,215 ---- void Leaf::SetParent(const boost::shared_ptr<Node> &newParent) { ! shared_ptr<Node> oldParent = GetParent().lock(); ! shared_ptr<Leaf> self = shared_static_cast<Leaf>(GetSelf().lock()); ! if (oldParent.get() != 0) { // we have a parent, so update our state // here reference count should be > 1 (at least one in the // parent, and one in this routine) *************** *** 229,237 **** mParent = newParent; ! if (! mParent.expired()) { ! // we have been linked, so now we can do something :) ! OnLink(); } } --- 235,255 ---- mParent = newParent; ! if (newParent.get() == 0) { ! return; ! } ! ! // assure a unique name among our siblings ! shared_ptr<Leaf> sibling = newParent->GetChild(mName); ! ! if (sibling != self) ! { ! stringstream ss; ! ss << mName << "_" << newParent->GetNumberOfChildren() << ">"; ! mName = ss.str().c_str(); } + + // we have been linked, so now we can do something :) + OnLink(); } |