reorg + selfmanage externals
This commit is contained in:
12
src/CMakeLists.txt
Normal file
12
src/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
add_library(solanaceae_contact INTERFACE
|
||||
#./solanaceae/contact/components.hpp
|
||||
#./solanaceae/contact/components_id.inl
|
||||
#./solanaceae/contact/contact_model3.hpp
|
||||
)
|
||||
|
||||
target_include_directories(solanaceae_contact INTERFACE .)
|
||||
target_compile_features(solanaceae_contact INTERFACE cxx_std_17)
|
||||
target_link_libraries(solanaceae_contact INTERFACE
|
||||
EnTT::EnTT
|
||||
)
|
||||
|
90
src/solanaceae/contact/components.hpp
Normal file
90
src/solanaceae/contact/components.hpp
Normal file
@ -0,0 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include "./contact_model3.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// fwd
|
||||
struct ContactModel3I;
|
||||
|
||||
namespace Contact::Components {
|
||||
|
||||
struct TagSelfWeak {};
|
||||
struct TagSelfStrong {};
|
||||
struct TagBig {};
|
||||
|
||||
struct RequestIncoming {
|
||||
bool name = false;
|
||||
bool password = false;
|
||||
};
|
||||
struct TagRequestOutgoing {};
|
||||
|
||||
// self counterpart
|
||||
struct Self {
|
||||
Contact3 self;
|
||||
};
|
||||
|
||||
// tier 1
|
||||
struct Parent {
|
||||
Contact3 parent;
|
||||
};
|
||||
|
||||
// TODO: maybe rename to children
|
||||
struct ParentOf {
|
||||
std::vector<Contact3> subs;
|
||||
};
|
||||
|
||||
// TODO: this is very hacky
|
||||
// maybe refwrapper?
|
||||
using ContactModel = ContactModel3I*;
|
||||
|
||||
struct Name {
|
||||
std::string name;
|
||||
};
|
||||
|
||||
// stable, probably unique, ID
|
||||
// eg for tox this would be the public key of the contact
|
||||
// if the protocol does not have its own ids, you can use a hash or a random byte array
|
||||
// TODO: make more length specific variants?
|
||||
struct ID {
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
|
||||
// (display)alias
|
||||
|
||||
// tag to signal an avatar change, and the texture needs to be reloaded
|
||||
struct TagAvatarInvalidate {};
|
||||
|
||||
struct AvatarMemory {
|
||||
// RGBA single-frame
|
||||
std::vector<uint8_t> data;
|
||||
uint64_t width;
|
||||
uint64_t height;
|
||||
};
|
||||
|
||||
struct AvatarFile {
|
||||
std::string file_path;
|
||||
};
|
||||
|
||||
// status
|
||||
|
||||
struct ConnectionState {
|
||||
enum State {
|
||||
disconnected,
|
||||
direct, // tox udp-direct?
|
||||
cloud, // tox tcp-relayed / most messengers ?
|
||||
} state = disconnected;
|
||||
};
|
||||
|
||||
// status message
|
||||
struct StatusMessage {
|
||||
std::string msg;
|
||||
};
|
||||
|
||||
// last seen (not disconnected?)
|
||||
|
||||
} // Contact::Components
|
||||
|
||||
#include "./components_id.inl"
|
||||
|
33
src/solanaceae/contact/components_id.inl
Normal file
33
src/solanaceae/contact/components_id.inl
Normal file
@ -0,0 +1,33 @@
|
||||
#include "./components.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; \
|
||||
}
|
||||
|
||||
// cross compiler stable ids
|
||||
|
||||
DEFINE_COMP_ID(Contact::Components::TagSelfWeak)
|
||||
DEFINE_COMP_ID(Contact::Components::TagSelfStrong)
|
||||
DEFINE_COMP_ID(Contact::Components::TagBig)
|
||||
DEFINE_COMP_ID(Contact::Components::RequestIncoming)
|
||||
DEFINE_COMP_ID(Contact::Components::TagRequestOutgoing)
|
||||
DEFINE_COMP_ID(Contact::Components::Self)
|
||||
DEFINE_COMP_ID(Contact::Components::Parent)
|
||||
DEFINE_COMP_ID(Contact::Components::ParentOf)
|
||||
DEFINE_COMP_ID(Contact::Components::ContactModel)
|
||||
DEFINE_COMP_ID(Contact::Components::Name)
|
||||
DEFINE_COMP_ID(Contact::Components::ID)
|
||||
DEFINE_COMP_ID(Contact::Components::TagAvatarInvalidate)
|
||||
DEFINE_COMP_ID(Contact::Components::AvatarMemory)
|
||||
DEFINE_COMP_ID(Contact::Components::AvatarFile)
|
||||
DEFINE_COMP_ID(Contact::Components::ConnectionState)
|
||||
DEFINE_COMP_ID(Contact::Components::StatusMessage)
|
||||
|
||||
#undef DEFINE_COMP_ID
|
||||
|
30
src/solanaceae/contact/contact_model3.hpp
Normal file
30
src/solanaceae/contact/contact_model3.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <entt/entity/registry.hpp>
|
||||
#include <entt/entity/handle.hpp>
|
||||
|
||||
// strong typing for contacts
|
||||
enum class Contact3 : uint32_t {};
|
||||
|
||||
using Contact3Registry = entt::basic_registry<Contact3>;
|
||||
using Contact3Handle = entt::basic_handle<Contact3Registry>;
|
||||
|
||||
struct ContactModel3I {
|
||||
virtual ~ContactModel3I(void) {}
|
||||
|
||||
// eg friends, confs, groups
|
||||
//virtual std::vector<Contact3> getBigContacts(void) = 0;
|
||||
// eg, all clients in a group
|
||||
//virtual std::vector<Contact3> getSubContacts(const Contact3& c) = 0;
|
||||
|
||||
//virtual Contact3Handle toSelfStrong(void) = 0;
|
||||
|
||||
//virtual Contact3Handle toBig(void) = 0;
|
||||
|
||||
//virtual Contact3Handle toPersistent(void) = 0;
|
||||
//virtual Contact3Handle toEphemeral(void) = 0;
|
||||
|
||||
// accept incoming request
|
||||
virtual void acceptRequest(Contact3 c, std::string_view self_name, std::string_view password) { (void)c,(void)self_name,(void)password; }
|
||||
};
|
||||
|
Reference in New Issue
Block a user