mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 08:15:38 +07:00
add dummy network module
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "deferrer.hpp"
|
||||
#include "engine.hpp"
|
||||
#include "input.hpp"
|
||||
#include "network.hpp"
|
||||
#include "platform.hpp"
|
||||
#include "render.hpp"
|
||||
#include "render.inl"
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace e2d
|
||||
class mouse;
|
||||
class keyboard;
|
||||
class input;
|
||||
class network;
|
||||
class platform;
|
||||
class render;
|
||||
class shader;
|
||||
|
||||
@@ -124,6 +124,7 @@ namespace e2d
|
||||
parameters& game_name(str_view value);
|
||||
parameters& company_name(str_view value);
|
||||
parameters& without_audio(bool value);
|
||||
parameters& without_network(bool value);
|
||||
parameters& without_graphics(bool value);
|
||||
parameters& debug_params(const debug_parameters& value);
|
||||
parameters& window_params(const window_parameters& value);
|
||||
@@ -132,6 +133,7 @@ namespace e2d
|
||||
str& game_name() noexcept;
|
||||
str& company_name() noexcept;
|
||||
bool& without_audio() noexcept;
|
||||
bool& without_network() noexcept;
|
||||
bool& without_graphics() noexcept;
|
||||
debug_parameters& debug_params() noexcept;
|
||||
window_parameters& window_params() noexcept;
|
||||
@@ -140,6 +142,7 @@ namespace e2d
|
||||
const str& game_name() const noexcept;
|
||||
const str& company_name() const noexcept;
|
||||
const bool& without_audio() const noexcept;
|
||||
const bool& without_network() const noexcept;
|
||||
const bool& without_graphics() const noexcept;
|
||||
const debug_parameters& debug_params() const noexcept;
|
||||
const window_parameters& window_params() const noexcept;
|
||||
@@ -148,6 +151,7 @@ namespace e2d
|
||||
str game_name_{"noname"};
|
||||
str company_name_{"noname"};
|
||||
bool without_audio_{false};
|
||||
bool without_network_{false};
|
||||
bool without_graphics_{false};
|
||||
debug_parameters debug_params_;
|
||||
window_parameters window_params_;
|
||||
|
||||
36
headers/enduro2d/core/network.hpp
Normal file
36
headers/enduro2d/core/network.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "_core.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
//
|
||||
// bad_network_operation
|
||||
//
|
||||
|
||||
class bad_network_operation final : public exception {
|
||||
public:
|
||||
const char* what() const noexcept final {
|
||||
return "bad network operation";
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// network
|
||||
//
|
||||
|
||||
class network final : public module<network> {
|
||||
public:
|
||||
network();
|
||||
~network() noexcept;
|
||||
private:
|
||||
class internal_state;
|
||||
std::unique_ptr<internal_state> state_;
|
||||
};
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <enduro2d/core/debug.hpp>
|
||||
#include <enduro2d/core/deferrer.hpp>
|
||||
#include <enduro2d/core/input.hpp>
|
||||
#include <enduro2d/core/network.hpp>
|
||||
#include <enduro2d/core/platform.hpp>
|
||||
#include <enduro2d/core/render.hpp>
|
||||
#include <enduro2d/core/vfs.hpp>
|
||||
@@ -175,11 +176,16 @@ namespace e2d
|
||||
return *this;
|
||||
}
|
||||
|
||||
engine::parameters& engine::parameters::without_network(bool value) {
|
||||
without_network_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
engine::parameters& engine::parameters::without_graphics(bool value) {
|
||||
without_graphics_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
engine::parameters& engine::parameters::debug_params(const debug_parameters& value) {
|
||||
debug_params_ = value;
|
||||
return *this;
|
||||
@@ -207,6 +213,10 @@ namespace e2d
|
||||
return without_audio_;
|
||||
}
|
||||
|
||||
bool& engine::parameters::without_network() noexcept {
|
||||
return without_network_;
|
||||
}
|
||||
|
||||
bool& engine::parameters::without_graphics() noexcept {
|
||||
return without_graphics_;
|
||||
}
|
||||
@@ -235,6 +245,10 @@ namespace e2d
|
||||
return without_audio_;
|
||||
}
|
||||
|
||||
const bool& engine::parameters::without_network() const noexcept {
|
||||
return without_network_;
|
||||
}
|
||||
|
||||
const bool& engine::parameters::without_graphics() const noexcept {
|
||||
return without_graphics_;
|
||||
}
|
||||
@@ -397,6 +411,12 @@ namespace e2d
|
||||
the<debug>());
|
||||
}
|
||||
|
||||
// setup network
|
||||
|
||||
if ( !params.without_network() ) {
|
||||
safe_module_initialize<network>();
|
||||
}
|
||||
|
||||
// setup graphics
|
||||
|
||||
if ( !params.without_graphics() )
|
||||
@@ -431,6 +451,7 @@ namespace e2d
|
||||
modules::shutdown<dbgui>();
|
||||
modules::shutdown<render>();
|
||||
modules::shutdown<window>();
|
||||
modules::shutdown<network>();
|
||||
modules::shutdown<audio>();
|
||||
modules::shutdown<input>();
|
||||
modules::shutdown<vfs>();
|
||||
|
||||
23
sources/enduro2d/core/network.cpp
Normal file
23
sources/enduro2d/core/network.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/core/network.hpp>
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
class network::internal_state final : private e2d::noncopyable {
|
||||
public:
|
||||
internal_state() = default;
|
||||
~internal_state() noexcept = default;
|
||||
};
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
network::network()
|
||||
: state_(new internal_state()) {}
|
||||
network::~network() noexcept = default;
|
||||
}
|
||||
11
untests/sources/untests_core/network.cpp
Normal file
11
untests/sources/untests_core/network.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include "_core.hpp"
|
||||
using namespace e2d;
|
||||
|
||||
TEST_CASE("network"){
|
||||
}
|
||||
Reference in New Issue
Block a user