Lumiera  0.pre.03
element-tracker.hpp File Reference

Go to the source code of this file.


Tracking instances automatically on creation and disposal.

These helper templates can be used to provide a registry of all objects of some kind or type. The class to be used with instance tracking needs to cooperate, typically by inheriting from lib::AutoRegistered. Moreover, the instance lifecycle handling is assumed to utilise lumiera::P or a similar smart-ptr, which allows the registry to hold a safe reference. Thus, references won't be cleaned up automatically (as there is always at least one reference left) – rather we rely on invoking a dispose or unlink function explicitly.

The standard use case for this feature is the management of the structural facade assets Timeline and Sequence within the session. They're created automatically to reflect some internal structures within the model; with the help of lib::ElementTracker we can expose a list of all instances as part of the public Session interface.

AutoRegistered does not check accessibility of the configured registry, when detaching an element. Especially, when detaching in turn gets automatically invoked from some kind of cleanup, care has to be taken to ensure the registry is still available. The Functions AutoRegistered::is_attached_to and AutoRegistered::deactivateRegistryLink can be used for detaching an Registry explicitly before destruction. Ignoring this might lead to segfault on application shutdown. /////////////////TICKET #574
be sure to understand the implications of object identity, especially when it comes to closing and opening the Session. Especially note that Assets use a systematic identity, not an instance identity, which might lead to removing an old instance from the new session.
See also

Definition in file element-tracker.hpp.

#include "lib/p.hpp"
#include "lib/optional-ref.hpp"
#include "lib/util-foreach.hpp"
#include "lib/ref-array-impl.hpp"


class  AutoRegistered< TAR >
 Helper mixin template for implementing a type intended to participate in automatic element tracking. More...
class  ElementTracker< ELM >
 Registry for tracking object instances. More...


 Implementation namespace for support and library code.