ScaleOut Native C++ API Library  5.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
named_cache_primitive.h
1 #pragma once
2 
3 #include <string>
4 #include <stdint.h>
5 
6 #include "soss_client/typed_named_cache.h"
7 
8 namespace sosscli {
9 
12 template <typename T>
14 {
15 public:
16 
18  NamedCachePrimitive(const std::string &name) { this->init(name); }
19 
21  NamedCachePrimitive(const uint32_t app_id) { this->init(app_id); }
22 
23 
24 
25 protected:
26 
28  virtual void serialize(const T& object, std::vector<uint8_t> &bytes_out, std::vector<uint8_t> &prop_spec_out)
29  {
30  bytes_out.resize(sizeof(T));
31  memcpy(&((bytes_out)[0]), &object, sizeof(T));
32  }
33 
35  virtual boost::shared_ptr<T> deserialize(const std::vector<uint8_t> &bytes)
36  {
37  boost::shared_ptr<T> obj_ptr(new T());
38  memcpy(obj_ptr.get(), &(bytes[0]), bytes.size());
39  return obj_ptr;
40  }
41 
42 
43 private:
44 
45 };
46 
47 }