add dummy network module

This commit is contained in:
2019-07-08 08:33:56 +07:00
parent 76be08d543
commit 049d8a7276
7 changed files with 98 additions and 1 deletions

View File

@@ -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"

View File

@@ -35,6 +35,7 @@ namespace e2d
class mouse;
class keyboard;
class input;
class network;
class platform;
class render;
class shader;

View File

@@ -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_;

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

View File

@@ -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>();

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

View 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"){
}