new comps

also ids, some where forgotten
This commit is contained in:
Green Sky 2024-07-22 09:17:44 +02:00
parent 4605d64df2
commit 43eee367a7
No known key found for this signature in database
5 changed files with 195 additions and 2 deletions

View File

@ -6,6 +6,8 @@ add_library(solanaceae_object_store
./solanaceae/object_store/types.hpp
./solanaceae/object_store/meta_components.hpp
./solanaceae/object_store/meta_components_id.inl
./solanaceae/object_store/meta_components_file.hpp
./solanaceae/object_store/meta_components_file_id.inl
./solanaceae/object_store/serializer_json.hpp
./solanaceae/object_store/object_store.hpp
./solanaceae/object_store/object_store.cpp

View File

@ -1,7 +1,7 @@
#pragma once
#include "./types.hpp"
#include "./object_store.hpp"
#include "./fwd.hpp"
#include <vector>
#include <string>

View File

@ -0,0 +1,148 @@
#pragma once
#include "./meta_components.hpp"
#include <solanaceae/util/bitset.hpp>
#include <vector>
#include <string>
namespace ObjectStore::Components {
// until i find a better name
namespace File {
// have bitsets
// there will be hash trees in the future too
// bitsets are not very flexible
// TODO: use tag instead of bool?
// the have all tag sure was useful
struct TagLocalHaveAll {};
struct LocalHaveBitset {
BitSet have;
// TODO: store actual size, since bitset is mult of 8
// size_t bits {0};
};
#if 0
// ephemeral?, not sure saving this to disk makes sense
// tag remove have all?
struct RemoteHaveBitset {
struct Entry {
bool have_all {false};
BitSet have;
};
entt::dense_map<Contact3, Entry> others;
};
#endif
// for single files or member of a collection
// split up into comps? more info?
// other stuff like filesystems have?
struct SingleInfo {
std::string file_name; // full path relative to base
uint64_t file_size {0};
};
// exists for stuff on disk
// there is no garantie this exists if its, eg. encrypted
struct SingleInfoLocal {
std::string file_path;
};
struct Collection {
std::vector<ObjectHandle> objs;
};
// entries in a collection can have SingleInfo,
// but CollectionInfo is still required, so data might be duplicated
struct CollectionInfo {
// order is same as in `Collection`
std::vector<SingleInfo> file_list;
uint64_t total_size {0};
};
struct CollectionInfoLocal {
// order is same as in `Collection`
// might contain empty entries
std::vector<SingleInfoLocal> file_list;
};
// img stuff
// save in the message instead? no?
// struct FrameDims {
// struct ThumbHash {
// struct TagNotImage {};
// receiving/sending/paused/canceled/stopped whatever
// think about this more
#if 0
// TODO: make an event instead/keeps on messages?
// TODO: rename to start? or set or ...
struct ActionAccept {
std::string save_to_path;
bool path_is_file = false; // if the path is not the folder to place the file into, overwrites the name
};
#endif
} // File
namespace Ephemeral {
namespace File {
struct DownloadPriority {
// download/retreival priority in comparison to other objects
// not all backends implement this
// priority can be weak, meaning low priority DLs will still get transfer activity, just less often
enum class Priority {
HIGHEST,
HIGH,
NORMAL,
LOW,
LOWEST,
} p = Priority::NORMAL;
};
struct ReadHeadHint {
// points to the first byte we want
// this is just a hint, that can be set from outside
// to guide the sequential "piece picker" strategy
// ? the strategy *should* set this to the first byte we dont yet have
// ???
uint64_t offset_into_file {0u};
};
// this is per object/content
// more aplicable than "separated", so should be supported by most backends
struct TransferStats {
// in bytes per second
float rate_up {0.f};
float rate_down {0.f};
// bytes
uint64_t total_up {0u};
uint64_t total_down {0u};
};
#if 0
struct TransferStatsSeparated {
entt::dense_map<Contact3, TransferStats> stats;
};
#endif
} // File
} // Ephemeral
namespace F = File;
} // ObjectStore::Components
#include "./meta_components_file_id.inl"

View File

@ -0,0 +1,36 @@
#pragma once
#include "./meta_components_file.hpp"
#include <entt/core/type_info.hpp>
// TODO: move more central
#define DEFINE_COMP_ID(x) \
template<> \
constexpr entt::id_type entt::type_hash<x>::value() noexcept { \
using namespace entt::literals; \
return #x##_hs; \
} \
template<> \
constexpr std::string_view entt::type_name<x>::value() noexcept { \
return #x; \
}
// cross compile(r) stable ids
DEFINE_COMP_ID(ObjComp::F::TagLocalHaveAll)
DEFINE_COMP_ID(ObjComp::F::LocalHaveBitset)
//DEFINE_COMP_ID(ObjComp::F::RemoteHaveBitset)
DEFINE_COMP_ID(ObjComp::F::SingleInfo)
DEFINE_COMP_ID(ObjComp::F::SingleInfoLocal)
DEFINE_COMP_ID(ObjComp::F::Collection)
DEFINE_COMP_ID(ObjComp::F::CollectionInfo)
DEFINE_COMP_ID(ObjComp::F::CollectionInfoLocal)
DEFINE_COMP_ID(ObjComp::Ephemeral::File::DownloadPriority)
DEFINE_COMP_ID(ObjComp::Ephemeral::File::ReadHeadHint)
DEFINE_COMP_ID(ObjComp::Ephemeral::File::TransferStats)
//DEFINE_COMP_ID(ObjComp::Ephemeral::File::TransferStatsSeparated)
#undef DEFINE_COMP_ID

View File

@ -18,13 +18,20 @@ constexpr std::string_view entt::type_name<x>::value() noexcept { \
// cross compiler stable ids
DEFINE_COMP_ID(ObjComp::ID)
DEFINE_COMP_ID(ObjComp::DataEncryptionType)
DEFINE_COMP_ID(ObjComp::DataCompressionType)
DEFINE_COMP_ID(ObjComp::Ephemeral::MetaFileType)
DEFINE_COMP_ID(ObjComp::Ephemeral::MetaEncryptionType)
DEFINE_COMP_ID(ObjComp::Ephemeral::MetaCompressionType)
DEFINE_COMP_ID(ObjComp::Ephemeral::Backend)
DEFINE_COMP_ID(ObjComp::Ephemeral::FilePath)
DEFINE_COMP_ID(ObjComp::Ephemeral::DirtyTag) // ??
// old stuff
DEFINE_COMP_ID(FragComp::DataEncryptionType)
DEFINE_COMP_ID(FragComp::DataCompressionType)
#undef DEFINE_COMP_ID