aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-01-28 07:35:37 +0100
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:12 +0200
commitbd2bd91ac947a7b1f6d097d7efa4b0ab2041d4db (patch)
treed934d57f39c8ce321688308317476baacd4efd83 /include
parent2ca8686eabc3b624c9981509c161b9be6af439cb (diff)
Add some files...
Diffstat (limited to 'include')
-rw-r--r--include/DataView.hpp16
-rw-r--r--include/Database.hpp31
-rw-r--r--include/Group.hpp20
-rw-r--r--include/Key.hpp14
-rw-r--r--include/Permission.hpp14
-rw-r--r--include/User.hpp15
-rw-r--r--include/types.hpp22
7 files changed, 132 insertions, 0 deletions
diff --git a/include/DataView.hpp b/include/DataView.hpp
new file mode 100644
index 0000000..982cb8a
--- /dev/null
+++ b/include/DataView.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "types.hpp"
+
+namespace odhtdb
+{
+ class DataView
+ {
+ public:
+ DataView() : data(nullptr), size(0) {}
+ DataView(void *_data, usize _size) : data(_data), size(_size) {}
+
+ const void *data;
+ const usize size;
+ };
+} \ No newline at end of file
diff --git a/include/Database.hpp b/include/Database.hpp
new file mode 100644
index 0000000..0b324e8
--- /dev/null
+++ b/include/Database.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "types.hpp"
+#include "Key.hpp"
+#include "DataView.hpp"
+#include <opendht/dhtrunner.h>
+#include <vector>
+
+namespace odhtdb
+{
+ struct StagedObject
+ {
+ Key key;
+ DataView data;
+ };
+
+ class Database
+ {
+ public:
+ Database(const char *bootstrapNodeAddr, u16 port);
+ ~Database();
+
+ void add(const Key &key, DataView data);
+ void commit();
+ private:
+ void commitStagedObject(const StagedObject &stagedObject);
+ private:
+ dht::DhtRunner node;
+ std::vector<StagedObject> stagedObjects;
+ };
+} \ No newline at end of file
diff --git a/include/Group.hpp b/include/Group.hpp
new file mode 100644
index 0000000..dafc05a
--- /dev/null
+++ b/include/Group.hpp
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <opendht/crypto.h>
+#include <string>
+#include <vector>
+
+namespace odhtdb
+{
+ class User;
+
+ class Group
+ {
+ public:
+ ~Group();
+ private:
+ dht::crypto::PublicKey publicKey;
+ std::string name;
+ std::vector<User*> users;
+ };
+} \ No newline at end of file
diff --git a/include/Key.hpp b/include/Key.hpp
new file mode 100644
index 0000000..e9f0591
--- /dev/null
+++ b/include/Key.hpp
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <opendht/infohash.h>
+
+namespace odhtdb
+{
+ class Key
+ {
+ public:
+ Key(const char *key) : hashedKey(dht::InfoHash::get(key)) {}
+
+ dht::InfoHash hashedKey;
+ };
+} \ No newline at end of file
diff --git a/include/Permission.hpp b/include/Permission.hpp
new file mode 100644
index 0000000..a6a16c3
--- /dev/null
+++ b/include/Permission.hpp
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "types.hpp"
+
+namespace odhtdb
+{
+ enum class Permission : u8
+ {
+ NONE,
+ READ,
+ WRITE,
+ READ_WRITE
+ };
+} \ No newline at end of file
diff --git a/include/User.hpp b/include/User.hpp
new file mode 100644
index 0000000..727bbcf
--- /dev/null
+++ b/include/User.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <opendht/crypto.h>
+#include <string>
+
+namespace odhtdb
+{
+ class User
+ {
+ public:
+ private:
+ dht::crypto::PublicKey publicKey;
+ std::string name;
+ };
+} \ No newline at end of file
diff --git a/include/types.hpp b/include/types.hpp
new file mode 100644
index 0000000..3cf7f02
--- /dev/null
+++ b/include/types.hpp
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <cstdint>
+
+namespace odhtdb
+{
+ typedef int8_t i8;
+ typedef int16_t i16;
+ typedef int32_t i32;
+ typedef int64_t i64;
+
+ typedef uint8_t u8;
+ typedef uint16_t u16;
+ typedef uint32_t u32;
+ typedef uint64_t u64;
+
+ typedef float f32;
+ typedef double f64;
+
+ typedef intptr_t isize;
+ typedef uintptr_t usize;
+}