fw: FaceTable onAdd,onRemove events
refs #1244
Change-Id: I8710dedaba94c1fcd852bd3aa2f21d39ad0bd7ee
diff --git a/daemon/fw/face-table.cpp b/daemon/fw/face-table.cpp
index 1ed79ad..35bf377 100644
--- a/daemon/fw/face-table.cpp
+++ b/daemon/fw/face-table.cpp
@@ -36,11 +36,15 @@
&m_forwarder, boost::ref(*face), _1);
face->onFail += bind(&FaceTable::remove,
this, face);
+
+ this->onAdd(face);
}
void
FaceTable::remove(shared_ptr<Face> face)
{
+ this->onRemove(face);
+
FaceId faceId = face->getId();
m_faces.erase(faceId);
face->setId(INVALID_FACEID);
diff --git a/daemon/fw/face-table.hpp b/daemon/fw/face-table.hpp
index 2af2b6b..868cf9e 100644
--- a/daemon/fw/face-table.hpp
+++ b/daemon/fw/face-table.hpp
@@ -48,6 +48,17 @@
const_iterator
end() const;
+public: // events
+ /** \brief fires after a Face is added
+ */
+ EventEmitter<shared_ptr<Face> > onAdd;
+
+ /** \brief fires before a Face is removed
+ *
+ * FaceId is valid when this event is fired
+ */
+ EventEmitter<shared_ptr<Face> > onRemove;
+
private:
// remove is private because it's a subscriber of face.onFail event.
// face->close() closes a face and would trigger .remove(face)