-
Notifications
You must be signed in to change notification settings - Fork 1
/
rocksentity.h
58 lines (44 loc) · 1.33 KB
/
rocksentity.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef ROCKSENTITY_H
#define ROCKSENTITY_H
#include <boost/exception/exception.hpp>
#include <boost/optional.hpp>
#include <boost/type_index.hpp>
#include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <folly/dynamic.h>
#include <sstream>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/assume_abstract.hpp>
namespace cxxdoor {
class RocksEntity {
friend boost::serialization::access;
friend std::ostream &operator<<(std::ostream &os, const RocksEntity &c);
public:
RocksEntity();
RocksEntity(RocksEntity&& other): _id(nullptr) {
_id = other._id;
other._id = nullptr;
}
template<class Archive>
void serialize(Archive &a, const unsigned int version) {
a & _id;
}
virtual ~RocksEntity() = default;
static std::string generateId();
std::string getId() const;
void setId(const std::string &id);
boost::optional<std::string> rocksdb_key() const;
std::string new_rocksdb_key();
virtual folly::dynamic get_json() const = 0;
bool operator==(const RocksEntity &rhs) const;
bool operator!=(const RocksEntity &rhs) const;
private:
std::string _id;
std::string entity_class() const;
protected:
bool is_rocksdb_key_valid() const;
};
BOOST_SERIALIZATION_ASSUME_ABSTRACT(RocksEntity);
}
#endif // ROCKSENTITY_H