From bd2bd91ac947a7b1f6d097d7efa4b0ab2041d4db Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 28 Jan 2018 07:35:37 +0100 Subject: Add some files... --- include/DataView.hpp | 16 ++++++++++++++++ include/Database.hpp | 31 +++++++++++++++++++++++++++++++ include/Group.hpp | 20 ++++++++++++++++++++ include/Key.hpp | 14 ++++++++++++++ include/Permission.hpp | 14 ++++++++++++++ include/User.hpp | 15 +++++++++++++++ include/types.hpp | 22 ++++++++++++++++++++++ 7 files changed, 132 insertions(+) create mode 100644 include/DataView.hpp create mode 100644 include/Database.hpp create mode 100644 include/Group.hpp create mode 100644 include/Key.hpp create mode 100644 include/Permission.hpp create mode 100644 include/User.hpp create mode 100644 include/types.hpp (limited to 'include') 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 +#include + +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 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 +#include +#include + +namespace odhtdb +{ + class User; + + class Group + { + public: + ~Group(); + private: + dht::crypto::PublicKey publicKey; + std::string name; + std::vector 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 + +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 +#include + +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 + +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; +} -- cgit v1.2.3