The ProbeListener base class automatically registers itself with a
probe manager. Currently, the class does not unregister a itself when
it is destroyed, which makes removing probes listeners somewhat
cumbersome. This patch adds an automatic call to
manager->removeListener in the ProbeListener destructor, which solves
the problem.
listeners.clear();
}
-ProbeListener::ProbeListener(ProbeManager *manager, const std::string &name)
+ProbeListener::ProbeListener(ProbeManager *_manager, const std::string &_name)
+ : manager(_manager), name(_name)
{
manager->addListener(name, *this);
}
+ProbeListener::~ProbeListener()
+{
+ manager->removeListener(name, *this);
+}
+
ProbeListenerObject*
ProbeListenerObjectParams::create()
{
{
public:
ProbeListener(ProbeManager *manager, const std::string &name);
- virtual ~ProbeListener() {}
+ virtual ~ProbeListener();
+
+ protected:
+ ProbeManager *const manager;
+ const std::string name;
};
/**