initial commit (version 3)

This commit is contained in:
Green Sky 2023-07-21 17:13:59 +02:00
commit b0ac85e4f1
No known key found for this signature in database
6 changed files with 160 additions and 0 deletions

16
CMakeLists.txt Normal file
View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
project(solanaceae)
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
)

24
LICENSE Normal file
View File

@ -0,0 +1,24 @@
The Code is under the following License, if not stated otherwise:
MIT License
Copyright (c) 2023 Erik Scholz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

6
README.md Normal file
View File

@ -0,0 +1,6 @@
`plant !`
provides `contact` functionallity for solanaceae code.
relies on [EnTT](https://github.com/skypjack/entt)

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;
};