Savarese Software Research Corporation
MembershipInfo.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2006 Savarese Software Research Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.savarese.com/software/ApacheLicense-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
23 #ifndef __SSRC_SPREAD_MEMBERSHIP_INFO_H
24 #define __SSRC_SPREAD_MEMBERSHIP_INFO_H
25 
27 
29 
30 #ifdef LIBSSRCSPREAD_ENABLE_MEMBERSHIP_INFO
31 
41 class MembershipInfo {
42  friend void BaseMessage::get_membership_info(MembershipInfo & info) const;
43 
44  BaseMessage::service_type _service_type;
45  Spread::membership_info _info;
46  GroupList _local_members, _non_local_members;
47 
48  void set_service(const BaseMessage::service_type service) {
49  _service_type = service;
50  }
51 
52 public:
53 
58  BaseMessage::service_type service() const {
59  return _service_type;
60  }
61 
74  void get_local_members(GroupList & members) const {
75  members = _local_members;
76  }
86  void get_non_local_members(GroupList & members) const {
87  members = _non_local_members;
88  }
89 
102  void get_all_members(GroupList & members) const {
103  members.clear();
104  members.add(_local_members);
105  members.add(_non_local_members);
106  }
107 
114  bool equal_group_ids(const MembershipInfo & info) const {
115  return (Spread::SP_equal_group_ids(_info.gid, info._info.gid) != 0);
116  }
117 
125  string changed_member() const {
126  return _info.changed_member;
127  }
128 
133  bool is_regular_membership() const {
134  return Is_reg_memb_mess(service());
135  }
136 
143  bool is_transition() const {
144  return Is_transition_mess(service());
145  }
146 
153  bool is_self_leave() const {
154  return Is_self_leave(service());
155  }
156 
163  bool caused_by_join() const {
164  return Is_caused_join_mess(service());
165  }
166 
173  bool caused_by_leave() const {
174  return Is_caused_leave_mess(service());
175  }
176 
183  bool caused_by_disconnect() const {
184  return Is_caused_disconnect_mess(service());
185  }
186 
193  bool caused_by_network() const {
194  return Is_caused_network_mess(service());
195  }
196 };
197 
198 #endif
199 
201 
202 #endif

Savarese Software Research Corporation
Copyright © 2006-2015 Savarese Software Research Corporation. All rights reserved.