An instance of this class provides a unique handle to an observer which can be used to detach it explicitly. It also holds a strong reference to the observed subject, so while it exists the subject and therefore the observer will not be destroyed.
If the handle is destroyed without calling Detach()
, the lifetime of the observer is tied to the subject.
template <typename D>
class Observer
{
public:
// Constructor
Observer();
Observer(Observer&& other); // Move
// Assignemnt
Observer& operator=(Observer&& other); // Move
// Tests if this instance is linked to a node
bool IsValid() const;
// Sets weight override for linked node
void SetWeightHint(WeightHint hint);
// Manually detaches the linked observer node from its subject
void Detach();
};