(1) Node is basically a hierarchical representation of transformation, and Entity is object in the game scene. Every Entity must have a node, each node can have several child nodes.
What I want to do is
(2) deleting either of entity or node will delete both of them, and also
(3) deleting a node will somehow notify its parent.
Circular ownership references are troublesome. It's best to avoid them alltogether.
(1) Sounds like Node as such has no right to exist, but several Entity objects may own the same node ---> use a shared_ptr<Node> in Entity. This gives a many-to-one relationship, and when the last Entity having a hold on a Node is destroyed, the now useless Node goes away, too. No need to do anything special.
(2) This is hard, if possible at all, and not easy to do in an easy, clean, unambiguous way. It is however also someting you likely don't need to (or don't want to) do either. Do you really need to delete entities by deleting nodes? Really? If that is so, find all the entities in the node by the back-pointer, remove them from whatever container owns all entities (so they're not double-deleted) and delete them. Don't touch the Node, the shared_ptr will take care of that, once it is not needed any more.
(3) This becomes somewhat obsolete, since there are no entities owning a node left when it's deleted (and otherwise, it is not valid to do so! It would leave orphaned entities around). But if you still want to achieve that, invoke a callback on each entity pointer from Node's destructor.
Edited by samoth, 18 January 2014 - 08:16 AM.