-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathstorage_module_base.hpp
More file actions
105 lines (83 loc) · 2.4 KB
/
storage_module_base.hpp
File metadata and controls
105 lines (83 loc) · 2.4 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef STORAGE_MODULE_BASE_HPP_
#define STORAGE_MODULE_BASE_HPP_
#include "countly/countly_configuration.hpp"
#include "countly/logger_module.hpp"
#include <string>
#include <vector>
namespace cly {
class DataEntry {
private:
long long _id;
std::string _data;
public:
DataEntry(const long long id, const std::string &data) {
this->_id = id;
this->_data = data;
}
~DataEntry() {}
/**
* @return id of data entry
*/
long long getId() const { return _id; }
/**
* @return content of data entry
*/
const std::string &getData() const { return _data; }
};
class StorageModuleBase {
protected:
bool _is_initialized = false;
std::shared_ptr<CountlyConfiguration> _configuration;
std::shared_ptr<LoggerModule> _logger;
public:
StorageModuleBase(std::shared_ptr<CountlyConfiguration> config, std::shared_ptr<LoggerModule> logger) {
this->_configuration = config;
this->_logger = logger;
}
bool isInitialized() { return _is_initialized; }
virtual ~StorageModuleBase() {
_logger.reset();
_configuration.reset();
}
/**
* Initialize the storage module.
*/
virtual void init() = 0;
/**
* Returns the count of stored requests.
* @return count of stored requests
*/
virtual long long RQCount() = 0;
/**
* Delete all stored requests.
*/
virtual void RQClearAll() = 0;
/**
* Remove front request from the request queue.
*/
virtual void RQRemoveFront() = 0;
/**
* Retrieve the element at the front of the queue. It does not deletes the element in the queue.
* @return front request of the queue.
*/
const virtual std::shared_ptr<DataEntry> RQPeekFront() = 0;
/**
* Retrieve all requests in the request queue without removing them.
* @return a vector of requests.
*/
virtual std::vector<std::shared_ptr<DataEntry>> RQPeekAll() = 0;
/**
* Remove the front request from the request queue if provided request's id and front request's id do match.
* @param request: a shared pointer to front request
*/
virtual void RQRemoveFront(std::shared_ptr<DataEntry> request) = 0;
/**
* Insert element into the request queue at the end.
* @param request: content of the request
*/
virtual void RQInsertAtEnd(const std::string &request) = 0;
virtual void storeSDKBehaviorSettings(const std::string &sdk_behavior_settings) = 0;
virtual std::string getSDKBehaviorSettings() = 0;
};
} // namespace cly
#endif