1 // 2 // Copyright (C) 2015 Codership Oy <info@codership.com> 3 // 4 5 /*! @file galera_view.hpp 6 * 7 * Helper class and methods for manipulating views in galera code. 8 */ 9 10 11 #ifndef GALERA_VIEW_HPP 12 #define GALERA_VIEW_HPP 13 14 #include "wsrep_api.h" // for wsrep_view_info_t 15 #include "gu_uuid.hpp" 16 #include <set> 17 operator <(const wsrep_uuid_t & lhs,const wsrep_uuid_t & rhs)18static inline bool operator<(const wsrep_uuid_t& lhs, const wsrep_uuid_t& rhs) 19 { 20 return (memcmp(lhs.data, rhs.data, sizeof(lhs.data)) < 0); 21 } 22 23 24 namespace galera 25 { 26 class View 27 { 28 public: 29 class UUIDCmp 30 { 31 public: operator ()(const wsrep_uuid_t & lhs,const wsrep_uuid_t & rhs) const32 bool operator()(const wsrep_uuid_t& lhs, 33 const wsrep_uuid_t& rhs) const 34 { 35 return (lhs < rhs); 36 } 37 }; 38 // Convenience typedef for member set 39 typedef std::set<wsrep_uuid_t, UUIDCmp> MembSet; 40 // Default constructor 41 View(); 42 // Construct View from wsrep_view_info_t 43 View(const wsrep_view_info_t&); 44 // Destructor 45 ~View(); 46 // Return true if the members of the view are subset of 47 // other MembSet. 48 bool subset_of(const MembSet& other) const; 49 private: 50 MembSet members_; // members set 51 }; 52 } 53 54 #endif // GALERA_VIEW_HPP 55