# Class CompNodeDepedentObject¶

## Class Documentation¶

class mgb::CompNodeDepedentObject : private mgb::comp_node_detail::DepedentObjList

base class for objects that depend on CompNode

There is a CompNode::finalize() method that destorys all global comp nodes. Therefore objects that depend on CompNode should all be marked as invalid at that time.

CompNode::finalize() is called in atexit() because some external libraries that CompNode depends on seems to be registering exit handlers. It is also impractical to require a correct destruction order because, for example, in python atexit() handlers are invoked before global python objects get reclaimed.

As a result we give up enforcing a correct destruction order, but rather require all CompNode-dependent objects to derive from this class so they can get notified possibly do most of the cleanup when CompNode is finalized.

Subclassed by mgb::cg::ComputingGraph

Protected Functions

CompNodeDepedentObject()
~CompNodeDepedentObject()
std::shared_ptr<void> on_comp_node_finalize() = 0

overwritten by subclasses to perform clean up jobs

Note: in case the object has nested objects which hold a reference to the object itself, a reference to this object must be kept so it would not be released during the call of on_comp_node_finalize().

void check_not_finalized() const

exception would thrown if on_comp_node_finalize() has been called (do not raise if invoked from on_comp_node_finalize())

bool is_finalized() const

whether on_comp_node_finalize() has been called (true when invoked from on_comp_node_finalize())