initial commit (version 3)

This commit is contained in:
2023-07-21 17:13:59 +02:00
commit b0ac85e4f1
6 changed files with 160 additions and 0 deletions

View File

@ -0,0 +1,60 @@
#pragma once
#include "./contact_model3.hpp"
#include <string>
// fwd
struct ContactModel3I;
namespace Contact::Components {
struct TagSelfWeak {};
struct TagSelfStrong {};
struct TagBig {};
// self counterpart
struct Self {
Contact3 self;
};
// TODO: rename to SubOf?
struct BigParent {
Contact3 parent;
};
struct ParentOf {
std::vector<Contact3> subs;
};
// TODO: this is very hacky
// maybe refwrapper?
using ContactModel = ContactModel3I*;
struct Name {
std::string name;
};
// (display)alias
// avatar
// 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?)
};
#include "./components_id.inl"

View File

@ -0,0 +1,27 @@
#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::Self)
DEFINE_COMP_ID(Contact::Components::BigParent)
DEFINE_COMP_ID(Contact::Components::ParentOf)
DEFINE_COMP_ID(Contact::Components::ContactModel)
DEFINE_COMP_ID(Contact::Components::Name)
DEFINE_COMP_ID(Contact::Components::ConnectionState)
DEFINE_COMP_ID(Contact::Components::StatusMessage)
#undef DEFINE_COMP_ID

View File

@ -0,0 +1,27 @@
#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;
};