Files | |
file | handle.cc [code] |
file | handle.h [code] |
file | log.cc [code] |
file | log.h [code] |
file | objdb.cc [code] |
file | objdb.h [code] |
file | object.cc [code] |
file | object.h [code] |
file | objfactory.cc [code] |
file | objfactory.h [code] |
file | objmgr.cc [code] |
file | objmgr.h [code] |
file | README.dxy [code] |
file | ref.cc [code] |
file | ref.h [code] |
file | refcounted.cc [code] |
file | refcounted.h [code] |
file | scheduler.cc [code] |
file | scheduler.h [code] |
file | signal.cc [code] |
file | signal.h [code] |
file | timer.cc [code] |
file | timer.h [code] |
file | types.h [code] |
file | uid.h [code] |
file | volatileobject.cc [code] |
file | volatileobject.h [code] |
file | weak_handle.cc [code] |
file | weak_handle.h [code] |
src/nub provides a base class, nub::object, with intrusive reference-counting. Objects deriving from nub::object can be stored in the nub::objectdb, which allows objects to be retrieved given their unique integer id (nub::uid). This, in turn, provides a basis for using these integer ids as object handles in a script-language wrapper of c++ classes and objects.
There are two basic smart pointer classes that can be used with nub::object; these are nub::ref and nub::soft_ref. The first, nub::ref, provides a strong guarantee that its pointee will never be null (this is verified upon construction of the nub::ref, after which the guarantee can never be lost). The second, nub::soft_ref, is more flexible in two ways: (1) it can have a null pointee, allowing for the representation of "no object here" (though it still verifies that its pointee is non-null upon dereferencing, and throws an exception if the pointee is null), and (2) it can act as a weak pointer, that is, one that doesn't prevent its pointee from being destroyed -- in this case if its pointee is destroyed, the the nub::soft_ref silently becomes null (but does not "dangle" like an ordinary pointer would).