From: Jason Dillaman Date: Mon, 13 Jul 2015 23:06:47 +0000 (-0400) Subject: librbd: added journal::EventEntry::get_event_type() helper X-Git-Tag: v10.0.1~52^2~23 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dcd3a6520c3505643c5c1cd577092b3e528c7dd0;p=ceph.git librbd: added journal::EventEntry::get_event_type() helper Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/JournalTypes.cc b/src/librbd/JournalTypes.cc index 01b850183354..4dcd2f5aff56 100644 --- a/src/librbd/JournalTypes.cc +++ b/src/librbd/JournalTypes.cc @@ -11,6 +11,14 @@ namespace journal { namespace { +class GetEventTypeVistor : public boost::static_visitor { +public: + template + inline EventType operator()(const Event &event) const { + return Event::EVENT_TYPE; + } +}; + class EncodeEventVisitor : public boost::static_visitor { public: EncodeEventVisitor(bufferlist &bl) : m_bl(bl) { @@ -107,6 +115,10 @@ void UnknownEvent::decode(__u8 version, bufferlist::iterator& it) { void UnknownEvent::dump(Formatter *f) const { } +EventType EventEntry::get_event_type() const { + return boost::apply_visitor(GetEventTypeVistor(), event); +} + void EventEntry::encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); boost::apply_visitor(EncodeEventVisitor(bl), event); @@ -178,4 +190,3 @@ std::ostream &operator<<(std::ostream &out, } return out; } - diff --git a/src/librbd/JournalTypes.h b/src/librbd/JournalTypes.h index c631964e45eb..59bd13fa275a 100644 --- a/src/librbd/JournalTypes.h +++ b/src/librbd/JournalTypes.h @@ -87,6 +87,8 @@ struct EventEntry { Event event; + EventType get_event_type() const; + void encode(bufferlist& bl) const; void decode(bufferlist::iterator& it); void dump(Formatter *f) const;