Changeset 6073 in orxonox.OLD for trunk/src/lib/coord
- Timestamp:
- Dec 12, 2005, 7:42:48 PM (19 years ago)
- Location:
- trunk/src/lib/coord
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/null_parent.cc
r6070 r6073 33 33 this->setName("NullParent"); 34 34 35 while (!this->getNodesChildren().empty())36 delete this->getNodesChildren().front();37 38 35 this->setParentMode(PNODE_ALL); 39 36 NullParent::singletonRef = this; -
trunk/src/lib/coord/p_node.cc
r6071 r6073 36 36 PNode::PNode () 37 37 { 38 init( NULL);38 init(); 39 39 40 40 NullParent::getInstance()->addChild(this); 41 41 } 42 42 43 /**44 * @param root the load-Element for the PNode45 */46 PNode::PNode(const TiXmlElement* root)47 {48 this->init(NULL);49 this->loadParams(root);50 51 if (this->parent == NULL)52 NullParent::getInstance()->addChild(this);53 }54 43 55 44 /** … … 60 49 PNode::PNode (const Vector& absCoor, PNode* parent ) 61 50 { 62 this->init( parent);51 this->init(); 63 52 64 53 if (likely(parent != NULL)) … … 67 56 this->setAbsCoor(absCoor); 68 57 } 58 69 59 70 60 /** … … 77 67 * (danger if you still need the children's instance somewhere else!!) 78 68 * 79 * 2. instance->remove 2D(); delete instance;69 * 2. instance->removeNode(); delete instance; 80 70 * -> result: 81 71 * moves its children to the NullParent … … 84 74 PNode::~PNode () 85 75 { 76 // remove the Node, delete it's children (if required). 77 std::list<PNode*>::iterator tmp = this->children.begin(); 78 std::list<PNode*>::iterator deleteNode; 79 while(!this->children.empty()) 80 while (tmp != this->children.end()) 81 { 82 deleteNode = tmp; 83 ++tmp; 84 printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName()); 85 if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) || 86 ((*deleteNode)->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT)) 87 { 88 if (this == NullParent::getInstance() && (*deleteNode)->parentMode & PNODE_REPARENT_TO_NULLPARENT) 89 delete (*deleteNode); 90 else 91 (*deleteNode)->reparent(); 92 } 93 else 94 delete (*deleteNode); 95 } 96 86 97 if (this->parent != NULL) 87 98 { … … 90 101 } 91 102 92 // remove the Node, delete it's children (if required).93 std::list<PNode*>::iterator tmp = this->children.begin();94 std::list<PNode*>::iterator deleteNode;95 while (tmp != this->children.end())96 {97 deleteNode = tmp++;98 if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) || ((*deleteNode)->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT) )99 (*deleteNode)->reparent();100 else101 delete (*deleteNode);102 }103 104 103 // remove all other allocated memory. 105 104 if (this->toCoordinate != NULL) … … 114 113 * @param parent the parent for this PNode 115 114 */ 116 void PNode::init( PNode* parent)115 void PNode::init() 117 116 { 118 117 this->setClassID(CL_PARENT_NODE, "PNode"); … … 120 119 this->bRelCoorChanged = true; 121 120 this->bRelDirChanged = true; 122 this->parent = parent;121 this->parent = NULL; 123 122 this->parentMode = PNODE_PARENT_MODE_DEFAULT; 124 123 this->bActive = true; -
trunk/src/lib/coord/p_node.h
r6071 r6073 73 73 public: 74 74 PNode (); 75 PNode(const TiXmlElement* root);76 75 PNode (const Vector& absCoor, PNode* pNode); 77 76 virtual ~PNode (); … … 170 169 171 170 private: 172 void init( PNode* parent);171 void init(); 173 172 /** tells the child that the parent's Coordinate has changed */ 174 173 inline void parentCoorChanged () { this->bRelCoorChanged = true; }
Note: See TracChangeset
for help on using the changeset viewer.