61 #ifndef LIB_ELEMENT_TRACKER_H 62 #define LIB_ELEMENT_TRACKER_H 91 template<
typename ELM>
95 using _Vec = std::vector<P<ELM>>;
96 using Iter =
typename _Vec::iterator;
97 using CIter =
typename _Vec::const_iterator;
110 toKill.reserve(_Vec::size());
112 ASSERT (0 == _Vec::size());
113 util::for_each (toKill, unlink_it);
119 REQUIRE (asset,
"Attempt to track a NIL element");
121 this->push_back (asset);
125 remove (ELM
const& asset)
127 for (Iter i = _Vec::begin();
128 i != _Vec::end() ; ++i )
137 isRegistered (ELM
const& asset)
const 139 for (CIter i = _Vec::begin();
140 i != _Vec::end() ; ++i )
152 try { elm->detach(); }
155 WARN (common,
"problems while clearing ElementTracker, ignored.");
173 template<
typename TAR>
187 if (!getRegistry)
return;
188 TAR& element =
static_cast<TAR&
> (*this);
190 getRegistry().remove(element);
191 ENSURE (!getRegistry().isRegistered(element));
204 REQUIRE (getRegistry);
206 PTarget newElement (
new TAR());
207 getRegistry().append (newElement);
210 ENSURE (getRegistry().isRegistered(*newElement));
216 setRegistryInstance (Registry& registry_to_use)
218 getRegistry.link_to (registry_to_use);
222 deactivateRegistryLink()
228 is_attached_to (Registry
const& someRegistry)
230 return getRegistry.points_to (someRegistry);
239 template<
typename TAR>
Optional or switchable link to an existing object.
a checked, switchable reference.
Customised refcounting smart pointer.
Registry for tracking object instances.
Implementation namespace for support and library code.
Helper mixin template for implementing a type intended to participate in automatic element tracking...
static PTarget create()
factory for creating smart-ptr managed TAR instances, automatically registered with the element-track...
void detach()
detach this element from the element-tracking registry.
Some (library-) implementations of the RefArray interface.
The asset subsystem of the Steam-Layer.
Perform operations "for each element" of a collection.
static RegistryLink getRegistry
storage for the functor to link an AutoRegistered entity to the corresponding registration service ...
This variation of the wrapper actually is a vector, but can act as a RefArray.
bool isSameObject(A const &a, B const &b)
compare plain object identity, bypassing any custom comparison operators.