SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RgrUpdate.h
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 #ifndef swcdb_manager_Protocol_mngr_params_RgrUpdate_h
7 #define swcdb_manager_Protocol_mngr_params_RgrUpdate_h
8 
10 
11 namespace SWC { namespace Comm { namespace Protocol {
12 namespace Mngr { namespace Params {
13 
14 
15 class RgrUpdate final : public Serializable {
16  public:
17 
19  RgrUpdate() noexcept : hosts(), sync_all() { }
20 
22  RgrUpdate(const Manager::RangerList& a_hosts, bool a_sync_all)
23  : hosts(a_hosts), sync_all(a_sync_all) {
24  }
25 
27  RgrUpdate(RgrUpdate&& other) noexcept
28  : hosts(std::move(other.hosts)), sync_all(other.sync_all) {
29  }
30 
31  RgrUpdate(const RgrUpdate&) = delete;
33  RgrUpdate& operator=(const RgrUpdate&) = delete;
34 
35  ~RgrUpdate() noexcept { }
36 
37  void print(std::ostream& out) const {
38  out << "Rangers-params:";
39  for(auto& h : hosts)
40  h->print(out << "\n ");
41  }
42 
44  bool sync_all;
45 
46  private:
47 
48  size_t internal_encoded_length() const override {
49  size_t len = 1 + Serialization::encoded_length_vi32(hosts.size());
50  for(auto& h : hosts)
51  len += h->encoded_length();
52  return len;
53  }
54 
55  void internal_encode(uint8_t** bufp) const override {
58  for(auto& h : hosts)
59  h->encode(bufp);
60  }
61 
62  void internal_decode(const uint8_t** bufp, size_t* remainp) override {
63  sync_all = Serialization::decode_bool(bufp, remainp);
64  hosts.clear();
65  if(size_t sz = Serialization::decode_vi32(bufp, remainp)) {
66  hosts.reserve(sz);
67  for(size_t i=0; i<sz; ++i)
68  hosts.emplace_back(new Manager::Ranger(bufp, remainp));
69  }
70  }
71 
72 };
73 
74 
75 }}}}}
76 
77 #endif // swcdb_manager_Protocol_mngr_params_RgrUpdate_h
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::RgrUpdate
SWC_CAN_INLINE RgrUpdate() noexcept
Definition: RgrUpdate.h:19
SWC::Core::Vector::clear
SWC_CAN_INLINE void clear() noexcept(_NoExceptDestructor)
Definition: Vector.h:120
SWC::Serialization::encoded_length_vi32
constexpr SWC_CAN_INLINE uint8_t encoded_length_vi32(uint32_t val) noexcept
Definition: Serialization.h:234
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::~RgrUpdate
~RgrUpdate() noexcept
Definition: RgrUpdate.h:35
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::RgrUpdate
SWC_CAN_INLINE RgrUpdate(const Manager::RangerList &a_hosts, bool a_sync_all)
Definition: RgrUpdate.h:22
SWC::Serialization::encode_bool
constexpr SWC_CAN_INLINE void encode_bool(uint8_t **bufp, bool bval) noexcept
Definition: Serialization.h:102
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::operator=
RgrUpdate & operator=(const RgrUpdate &)=delete
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::internal_encode
void internal_encode(uint8_t **bufp) const override
Definition: RgrUpdate.h:55
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::RgrUpdate
RgrUpdate(const RgrUpdate &)=delete
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::internal_encoded_length
size_t internal_encoded_length() const override
Definition: RgrUpdate.h:48
SWC::Serialization::decode_bool
constexpr SWC_CAN_INLINE bool decode_bool(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:107
SWC::Comm::Serializable
Definition: Serializable.h:18
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::sync_all
bool sync_all
Definition: RgrUpdate.h:44
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::operator=
RgrUpdate & operator=(RgrUpdate &&)=delete
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::RgrUpdate
SWC_CAN_INLINE RgrUpdate(RgrUpdate &&other) noexcept
Definition: RgrUpdate.h:27
Serializable.h
SWC::Core::Vector< Ranger::Ptr >
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::print
void print(std::ostream &out) const
Definition: RgrUpdate.h:37
SWC::Serialization::encode_vi32
constexpr SWC_CAN_INLINE void encode_vi32(uint8_t **bufp, uint32_t val)
Definition: Serialization.h:243
SWC::Manager::Ranger
Definition: Ranger.h:17
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::internal_decode
void internal_decode(const uint8_t **bufp, size_t *remainp) override
Definition: RgrUpdate.h:62
SWC::Core::Vector::size
constexpr SWC_CAN_INLINE size_type size() const noexcept
Definition: Vector.h:189
SWC::Core::Vector::emplace_back
SWC_CAN_INLINE reference emplace_back(ArgsT &&... args)
Definition: Vector.h:349
SWC::Comm::Protocol::Mngr::Params::RgrUpdate
Definition: RgrUpdate.h:15
SWC::Core::Vector::reserve
SWC_CAN_INLINE void reserve(size_type cap)
Definition: Vector.h:288
SWC::Comm::Protocol::Mngr::Params::RgrUpdate::hosts
Manager::RangerList hosts
Definition: RgrUpdate.h:43
SWC::Serialization::decode_vi32
constexpr SWC_CAN_INLINE uint32_t decode_vi32(const uint8_t **bufp, size_t *remainp)
Definition: Serialization.h:254