Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Implementation of network handler #13

Draft
wants to merge 25 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f984296
Add handler submodule
kachsheev Oct 13, 2023
9ce1b74
Add Expected class to Common. Fix 'Utils' -> 'UtilsTest'
kachsheev Dec 24, 2023
475470c
Add implementation of network hadler
kachsheev Dec 24, 2023
57636fd
Merge branch 'dev' into Handler/Network
kachsheev Sep 12, 2024
b6b2b99
Move files and fix headers
kachsheev Sep 16, 2024
d7b382c
Add 'Common/TypeMapper' with tests
kachsheev Sep 17, 2024
b392d0b
Redesign UDP part of Hanler
kachsheev Sep 23, 2024
81169f6
Add pull() member function to Optional
kachsheev Sep 23, 2024
2cd47f2
Fix compilation errors and warnings
kachsheev Sep 23, 2024
b9022ce
Rename Handler tests
kachsheev Sep 24, 2024
7a17097
Fix build on MSVC 2017
kachsheev Sep 24, 2024
dc93f32
Change returning type in 'Handler::ServerHandle::getSessionHandle()'
kachsheev Sep 24, 2024
745f99a
Multiple changes
kachsheev Sep 24, 2024
282640a
Common/Expected: add 'ifResultGet()' and 'ifErrorGet()' for change da…
kachsheev Dec 14, 2024
6f514e1
Common/ReferenceWrapper: update, add default copy/move ctorss add ass…
kachsheev Dec 14, 2024
429815c
Handler/Network/Tests: fix tests location
kachsheev Dec 14, 2024
c765f10
Dump changes
kachsheev Dec 14, 2024
d7a833f
Templates/Array: fix compilation error
kachsheev Dec 14, 2024
6cb32a1
Os/Async/Network/Registrar: remove useless header
kachsheev Dec 14, 2024
00c0ebe
Os/Threads/ConditionVariable: remove tryWait and unwait
kachsheev Dec 14, 2024
52c6fae
Os/Threads/Counter: update
kachsheev Dec 14, 2024
ff0eb23
Templates/Object: fix compilation error
kachsheev Dec 14, 2024
59e777a
Templates/SimpleAlgorithms: fix
kachsheev Dec 14, 2024
f24ae30
Common/Tests: small fixes in FunctionTrait and VoidType tests
kachsheev Dec 14, 2024
7860296
Handler/Tests/Network/Udp: add test templates; add tests for UDP storage
kachsheev Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/FlameIDE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(HEADER_MODULES
${FLAME_INCLUDE_SUBMODLUES_PATH}/Common
${FLAME_INCLUDE_SUBMODLUES_PATH}/Constants
${FLAME_INCLUDE_SUBMODLUES_PATH}/Crypto
${FLAME_INCLUDE_SUBMODLUES_PATH}/Handler
${FLAME_INCLUDE_SUBMODLUES_PATH}/Os
${FLAME_INCLUDE_SUBMODLUES_PATH}/Others
# ${FLAME_INCLUDE_SUBMODLUES_PATH}/Streams
Expand Down
36 changes: 34 additions & 2 deletions include/FlameIDE/Common/Expected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ class Expected
template<typename Functor>
const Me &ifResult(Functor &&functor) const noexcept;

template<typename Functor>
Me &ifResultGet(Functor &&functor) noexcept;

template<typename Functor>
Me &ifError(Functor &&functor) noexcept;
template<typename Functor>
const Me &ifError(Functor &&functor) const noexcept;

template<typename Functor>
Me &ifErrorGet(Functor &&functor) noexcept;

void done() noexcept;
void done() const noexcept;

Expand Down Expand Up @@ -146,10 +152,10 @@ Expected<ResultType, ErrorType>::operator=(Me &&expected) noexcept
{
expected.ifResult([this](ResultType &&result)
{
operator=(move(result));
this->operator=(move(result));
}).ifError([this](ErrorType &&error)
{
operator=(move(error));
this->operator=(move(error));
}).done();
return *this;
}
Expand Down Expand Up @@ -221,6 +227,19 @@ Expected<ResultType, ErrorType>::ifResult(Functor &&functor) const noexcept
return *this;
}

template<typename ResultType, typename ErrorType>
template<typename Functor>
Expected<ResultType, ErrorType> &
Expected<ResultType, ErrorType>::ifResultGet(Functor &&functor) noexcept
{
if (State::RESULT != data.state)
return *this;

functor(data.result.value);

return *this;
}

template<typename ResultType, typename ErrorType>
template<typename Functor>
Expected<ResultType, ErrorType> &
Expand Down Expand Up @@ -248,6 +267,19 @@ Expected<ResultType, ErrorType>::ifError(Functor &&functor) const noexcept
return *this;
}

template<typename ResultType, typename ErrorType>
template<typename Functor>
Expected<ResultType, ErrorType> &
Expected<ResultType, ErrorType>::ifErrorGet(Functor &&functor) noexcept
{
if (State::ERROR != data.state)
return *this;

functor(data.error.value);

return *this;
}

template<typename ResultType, typename ErrorType>
inline void Expected<ResultType, ErrorType>::done() noexcept
{}
Expand Down
1 change: 0 additions & 1 deletion include/FlameIDE/Common/PrimitiveTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ using long_t = ::int64_t;
using float_t = float;
using double_t = double;
using ldouble_t = long double;

using ptrint_t = ::intptr_t;
using ptruint_t = ::uintptr_t;

Expand Down
7 changes: 7 additions & 0 deletions include/FlameIDE/Common/ReferenceWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ template<typename T, typename Traits = ContainerTraits<T>>
class ReferenceWrapper
{
public:
using Me = ReferenceWrapper<T, Traits>;
using Pointer = typename Traits::Pointer;
using Reference = typename Traits::Reference;

ReferenceWrapper(const Me &) noexcept = default;
ReferenceWrapper(Me &&) noexcept = default;

///
/// @brief ReferenceWrapper
/// @param initValue
Expand All @@ -28,6 +32,9 @@ class ReferenceWrapper
///
ReferenceWrapper(Reference initValue) noexcept;

Me &operator=(const Me &) noexcept = default;
Me &operator=(Me &&) noexcept = default;

///
/// @brief get
/// @return
Expand Down
38 changes: 38 additions & 0 deletions include/FlameIDE/Common/Traits/Functional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,44 @@ struct DoSomeByIndex<T, SIZE, SIZE>
{}
};

///
/// @brief The TypeMappingTrait class
/// @tparam T1
/// @tparam T2
///
template<typename T1, typename T2>
struct TypeMappingTrait
{
using Type1 = T1;
using Type2 = T2;
};

///
/// @brief The TypeMapper class
/// @tparam T
/// @tparam TypeMappingTrait
/// @tparam ENABLE_STATIC_ASSERT
///
template<typename T, typename TypeMappingTrait, bool ENABLE_STATIC_ASSERT = true>
struct TypeMapper
{
using Type = typename ChooseType<
ComparingTypes<T, typename TypeMappingTrait::Type1>::VALUE
, typename TypeMappingTrait::Type2
, typename ChooseType<
ComparingTypes<T, typename TypeMappingTrait::Type2>::VALUE
, typename TypeMappingTrait::Type1
, Empty
>::Type
>::Type;

static_assert(
!ENABLE_STATIC_ASSERT
|| ComparingTypes<Type, Empty>::VALUE == FalseType::VALUE
, "Type does not include in chosen TypeMatchingTrait"
);
};

}

#endif // FLAMEIDE_COMMON_TRAITS_FUCTIONAL_HPP
8 changes: 8 additions & 0 deletions include/FlameIDE/Handler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.14)

set(SOURCE_MODULES
${CMAKE_CURRENT_LIST_DIR}/Network
)
foreach(module ${SOURCE_MODULES})
add_subdirectory(${module})
endforeach()
20 changes: 20 additions & 0 deletions include/FlameIDE/Handler/Network/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.14)

set(NAME "Handler.Network")
set(NAME_ALIAS "Handler::Network")
set(LIBRARY_ALIAS_NAME ${FLAME_NAMESPACE}::${NAME_ALIAS}::Headers)
set(DEPENDENCY_LIST
${FLAME_NAMESPACE}::Common::Headers
${FLAME_NAMESPACE}::Os::Headers
${FLAME_NAMESPACE}::Templates::Headers
)

get_sources(FILE_LIST)
flame_header_library(
NAME "${NAME}"
LIBRARY_ALIAS_NAME "${LIBRARY_ALIAS_NAME}"
HEADER_LIST "${FILE_LIST}"
DEPENDENCY_TARGET_LIST "${DEPENDENCY_LIST}"
INCLUDE_PATHS "${FLAME_INCLUDE_PATH}"
INSTALL_SUBDIR "${FLAME_NAMESPACE}/${NAME}"
)
Loading
Loading