commit b0ac85e4f104eed91fa4b9abaca7b4269a1146b1 Author: Green Sky Date: Fri Jul 21 17:13:59 2023 +0200 initial commit (version 3) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..45836b2 --- /dev/null +++ b/CMakeLists.txt @@ -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 +) + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2780797 --- /dev/null +++ b/LICENSE @@ -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. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..6b1bac8 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +`plant !` + +provides `contact` functionallity for solanaceae code. + +relies on [EnTT](https://github.com/skypjack/entt) + diff --git a/solanaceae/contact/components.hpp b/solanaceae/contact/components.hpp new file mode 100644 index 0000000..a1c1d59 --- /dev/null +++ b/solanaceae/contact/components.hpp @@ -0,0 +1,60 @@ +#pragma once + +#include "./contact_model3.hpp" + +#include + +// 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 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" + diff --git a/solanaceae/contact/components_id.inl b/solanaceae/contact/components_id.inl new file mode 100644 index 0000000..95f15fa --- /dev/null +++ b/solanaceae/contact/components_id.inl @@ -0,0 +1,27 @@ +#include "./components.hpp" + +#include + +// TODO: move more central +#define DEFINE_COMP_ID(x) \ +template<> \ +constexpr entt::id_type entt::type_hash::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 + diff --git a/solanaceae/contact/contact_model3.hpp b/solanaceae/contact/contact_model3.hpp new file mode 100644 index 0000000..0ec2615 --- /dev/null +++ b/solanaceae/contact/contact_model3.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include +#include + +// strong typing for contacts +enum class Contact3 : uint32_t {}; + +using Contact3Registry = entt::basic_registry; +using Contact3Handle = entt::basic_handle; + +struct ContactModel3I { + virtual ~ContactModel3I(void) {} + + // eg friends, confs, groups + //virtual std::vector getBigContacts(void) = 0; + // eg, all clients in a group + //virtual std::vector 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; +}; +