SDK  2.1.4 [async]
CloudBackend Software Development Kit - SDK API for C++
Member.h
1 /*
2  Copyright © CloudBackend AB 2023.
3 */
4 
5 #ifndef CBE_MEMBER_H
6 #define CBE_MEMBER_H
7 
8 #include "cbe/Types.h"
9 
10 #include "cbe/delegate/KickDelegate.h"
11 #include "cbe/delegate/BanDelegate.h"
12 #include "cbe/delegate/UnBanDelegate.h"
13 
14 #include "cbe/delegate/Error.h"
15 #include "cbe/util/ErrorInfo.h"
16 #include "cbe/util/Exception.h"
17 #include "cbe/util/Optional.h"
18 namespace CBI {
19 class Member;
20 using MemberPtr = std::shared_ptr<CBI::Member>;
21 class GroupEventProtocol;
22 using GroupDelegatePtr = std::shared_ptr<GroupEventProtocol>;
23 } // namespace CBI
24 
25 namespace cbe {
26 
30 struct Request {
31  cbe::UserId userId{};
32  std::string alias{};
33  std::string applicationComment{};
34  cbe::Date date{};
35 
36  Request(cbe::UserId userId, std::string alias, std::string applicationComment,
37  cbe::Date date)
38  : userId{userId}, alias{std::move(alias)},
39  applicationComment{std::move(applicationComment)}, date{date} {}
40 };
41 
45 class Member {
46 public:
61  void kick(std::string kickComment, KickDelegatePtr delegate);
68 #ifndef CBE_NO_SYNC
72  using KickException = delegate::KickDelegate::Exception;
87  std::string kickComment);
88 
95  using KickError = delegate::KickDelegate::ErrorInfo;
117  std::string kickComment,
118  KickError& error);
119 #endif // #ifndef CBE_NO_SYNC
120  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
121 
137  void ban(std::string banComment, BanDelegatePtr delegate);
144 #ifndef CBE_NO_SYNC
148  using BanException = delegate::BanDelegate::Exception;
162  delegate::BanSuccess ban(std::string banComment);
163 
170  using BanError = delegate::BanDelegate::ErrorInfo;
191  cbe::util::Optional<delegate::BanSuccess> ban(std::string banComment,
192  BanError& error);
193 #endif // #ifndef CBE_NO_SYNC
194  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
195 
209  void unBan(UnBanDelegatePtr delegate);
216 #ifndef CBE_NO_SYNC
220  using UnBanException = delegate::UnBanDelegate::Exception;
235 
242  using UnBanError = delegate::UnBanDelegate::ErrorInfo;
264 #endif // #ifndef CBE_NO_SYNC
265  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
266 
269 
271  std::string name() const;
272 
275 
278 
284 
294  ~Member();
295 
308  explicit operator bool() const;
309 private:
310  struct Impl;
311 
312  std::shared_ptr<Impl> pImpl{};
313 
314  friend class Group;
315  friend class Role;
316  Member(CBI::MemberPtr cbiPeerPtr);
317  CBI::Member& getCbiPeer() const;
318 }; // class Member
319 
320 } // namespace cbe
321 
322 #endif //CBE_MEMBER_H
A group of members.
Definition: Group.h:42
A of member of a Group.
Definition: Member.h:45
Member(cbe::DefaultCtor)
Default constructor.
cbe::Visibility visibility() const
cbe::MemberId memberId() const
delegate::BanDelegatePtr BanDelegatePtr
Definition: Member.h:128
void unBan(UnBanDelegatePtr delegate)
cbe::GroupId groupId() const
delegate::KickDelegatePtr KickDelegatePtr
Definition: Member.h:53
cbe::MemberBanInfo getMemberBanInfo()
Gets the member ban info map.
delegate::UnBanDelegatePtr UnBanDelegatePtr
Definition: Member.h:202
void kick(std::string kickComment, KickDelegatePtr delegate)
void ban(std::string banComment, BanDelegatePtr delegate)
std::string name() const
User role information.
Definition: Role.h:34
Convenience type that bundles all parameters passed to method cbe::delegate::BanDelegate::onBanSucces...
Definition: BanDelegate.h:76
Convenience type that bundles all parameters passed to method cbe::delegate::KickDelegate::onKickSucc...
Definition: KickDelegate.h:76
Convenience type that bundles all parameters passed to method cbe::delegate::UnBanDelegate::onUnBanSu...
Definition: UnBanDelegate.h:75
Class template Optional manages an optional contained value - i.e., a value that is either present or...
Definition: Optional.h:20
std::shared_ptr< KickDelegate > KickDelegatePtr
Definition: KickDelegate.h:69
std::shared_ptr< UnBanDelegate > UnBanDelegatePtr
Definition: UnBanDelegate.h:68
std::shared_ptr< BanDelegate > BanDelegatePtr
Definition: BanDelegate.h:69
Root namespace for the CloudBackend SDK API.
Definition: Account.h:22
std::map< std::pair< cbe::MemberId, cbe::MemberId >, std::pair< cbe::Date, std::string > > MemberBanInfo
Map of a pair of members, associated with ban information.
Definition: Types.h:441
std::uint64_t UserId
Uniquely identifies the CBE user number.
Definition: Types.h:126
Visibility
Definition: Types.h:375
DefaultCtor
Default constructor marker.
Definition: Types.h:204
std::uint64_t GroupId
Uniquely identifies the Group.
Definition: Types.h:84
std::uint64_t MemberId
Represents the cbe::Group membership id.
Definition: Types.h:92
std::uint64_t Date
A time-stamp in the unix epoch format.
Definition: Types.h:80
Definition: Member.h:30
Definition: BanDelegate.h:45
Definition: KickDelegate.h:45
Definition: UnBanDelegate.h:45