]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: added journal::EventEntry::get_event_type() helper
authorJason Dillaman <dillaman@redhat.com>
Mon, 13 Jul 2015 23:06:47 +0000 (19:06 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 13 Nov 2015 01:17:53 +0000 (20:17 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/JournalTypes.cc
src/librbd/JournalTypes.h

index 01b850183354610c4646c29c11d8ecea79f8df6b..4dcd2f5aff56378c99976a511785ae5792cd5897 100644 (file)
@@ -11,6 +11,14 @@ namespace journal {
 
 namespace {
 
+class GetEventTypeVistor : public boost::static_visitor<EventType> {
+public:
+  template <typename Event>
+  inline EventType operator()(const Event &event) const {
+    return Event::EVENT_TYPE;
+  }
+};
+
 class EncodeEventVisitor : public boost::static_visitor<void> {
 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;
 }
-
index c631964e45eb634babff9bdd5853bace4ef25c07..59bd13fa275a9f877aaba258e0070112c14ced86 100644 (file)
@@ -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;