mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-16 22:16:53 +07:00
rename component_factory to factory
This commit is contained in:
@@ -40,8 +40,8 @@
|
||||
#include "asset.hpp"
|
||||
#include "asset.inl"
|
||||
#include "atlas.hpp"
|
||||
#include "component.hpp"
|
||||
#include "component.inl"
|
||||
#include "factory.hpp"
|
||||
#include "factory.inl"
|
||||
#include "flipbook.hpp"
|
||||
#include "gobject.hpp"
|
||||
#include "library.hpp"
|
||||
|
||||
@@ -52,13 +52,12 @@ namespace e2d
|
||||
class content_asset;
|
||||
class asset;
|
||||
|
||||
class factory;
|
||||
class library;
|
||||
class asset_cache;
|
||||
class asset_group;
|
||||
class asset_dependencies;
|
||||
|
||||
class component_factory;
|
||||
|
||||
class atlas;
|
||||
class flipbook;
|
||||
class gobject;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../component.hpp"
|
||||
#include "../factory.hpp"
|
||||
#include "../node.hpp"
|
||||
|
||||
namespace e2d
|
||||
@@ -27,17 +27,17 @@ namespace e2d
|
||||
};
|
||||
|
||||
template <>
|
||||
class component_loader<actor> {
|
||||
class factory_loader<actor> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
actor& component,
|
||||
const component_loader<>::fill_context& ctx) const;
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const;
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../component.hpp"
|
||||
#include "../factory.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
@@ -36,17 +36,17 @@ namespace e2d
|
||||
};
|
||||
|
||||
template <>
|
||||
class component_loader<camera> {
|
||||
class factory_loader<camera> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
camera& component,
|
||||
const component_loader<>::fill_context& ctx) const;
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const;
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../component.hpp"
|
||||
#include "../factory.hpp"
|
||||
#include "../assets/flipbook_asset.hpp"
|
||||
|
||||
namespace e2d
|
||||
@@ -53,17 +53,17 @@ namespace e2d
|
||||
};
|
||||
|
||||
template <>
|
||||
class component_loader<flipbook_player> {
|
||||
class factory_loader<flipbook_player> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
flipbook_player& component,
|
||||
const component_loader<>::fill_context& ctx) const;
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const;
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../component.hpp"
|
||||
#include "../factory.hpp"
|
||||
#include "../assets/flipbook_asset.hpp"
|
||||
|
||||
namespace e2d
|
||||
@@ -25,17 +25,17 @@ namespace e2d
|
||||
};
|
||||
|
||||
template <>
|
||||
class component_loader<flipbook_source> {
|
||||
class factory_loader<flipbook_source> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
flipbook_source& component,
|
||||
const component_loader<>::fill_context& ctx) const;
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const;
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../component.hpp"
|
||||
#include "../factory.hpp"
|
||||
#include "../assets/model_asset.hpp"
|
||||
|
||||
namespace e2d
|
||||
@@ -25,17 +25,17 @@ namespace e2d
|
||||
};
|
||||
|
||||
template <>
|
||||
class component_loader<model_renderer> {
|
||||
class factory_loader<model_renderer> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
model_renderer& component,
|
||||
const component_loader<>::fill_context& ctx) const;
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const;
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../component.hpp"
|
||||
#include "../factory.hpp"
|
||||
#include "../assets/material_asset.hpp"
|
||||
|
||||
namespace e2d
|
||||
@@ -38,17 +38,17 @@ namespace e2d
|
||||
};
|
||||
|
||||
template <>
|
||||
class component_loader<renderer> {
|
||||
class factory_loader<renderer> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
renderer& component,
|
||||
const component_loader<>::fill_context& ctx) const;
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const;
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../component.hpp"
|
||||
#include "../factory.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
@@ -23,17 +23,17 @@ namespace e2d
|
||||
};
|
||||
|
||||
template <>
|
||||
class component_loader<scene> {
|
||||
class factory_loader<scene> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
scene& component,
|
||||
const component_loader<>::fill_context& ctx) const;
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const;
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "../_high.hpp"
|
||||
|
||||
#include "../component.hpp"
|
||||
#include "../factory.hpp"
|
||||
#include "../assets/sprite_asset.hpp"
|
||||
|
||||
namespace e2d
|
||||
@@ -33,17 +33,17 @@ namespace e2d
|
||||
};
|
||||
|
||||
template <>
|
||||
class component_loader<sprite_renderer> {
|
||||
class factory_loader<sprite_renderer> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
sprite_renderer& component,
|
||||
const component_loader<>::fill_context& ctx) const;
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const;
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef E2D_INCLUDE_GUARD_DEE612552A524342A523868F34FF88BA
|
||||
#define E2D_INCLUDE_GUARD_DEE612552A524342A523868F34FF88BA
|
||||
#ifndef E2D_INCLUDE_GUARD_9C9B1BA27AAC42CBAA07890458076B81
|
||||
#define E2D_INCLUDE_GUARD_9C9B1BA27AAC42CBAA07890458076B81
|
||||
#pragma once
|
||||
|
||||
#include "_high.hpp"
|
||||
@@ -13,25 +13,25 @@
|
||||
namespace e2d
|
||||
{
|
||||
//
|
||||
// bad_component_factory_operation
|
||||
// bad_factory_operation
|
||||
//
|
||||
|
||||
class bad_component_factory_operation final : public exception {
|
||||
class bad_factory_operation final : public exception {
|
||||
public:
|
||||
const char* what() const noexcept final {
|
||||
return "bad component factory operation";
|
||||
return "bad factory operation";
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// component_loader
|
||||
// factory_loader
|
||||
//
|
||||
|
||||
template < typename Component = void >
|
||||
class component_loader;
|
||||
class factory_loader;
|
||||
|
||||
template <>
|
||||
class component_loader<> {
|
||||
class factory_loader<> {
|
||||
public:
|
||||
struct fill_context {
|
||||
const str parent_address;
|
||||
@@ -57,71 +57,66 @@ namespace e2d
|
||||
: parent_address(std::move(nparent_address))
|
||||
, root(nroot) {}
|
||||
};
|
||||
public:
|
||||
};
|
||||
|
||||
//
|
||||
// component_creator_base
|
||||
// factory_creator
|
||||
//
|
||||
|
||||
class component_creator_base;
|
||||
using component_creator_base_iptr = intrusive_ptr<component_creator_base>;
|
||||
class factory_creator;
|
||||
using factory_creator_iptr = intrusive_ptr<factory_creator>;
|
||||
|
||||
class component_creator_base
|
||||
class factory_creator
|
||||
: private noncopyable
|
||||
, public ref_counter<component_creator_base> {
|
||||
, public ref_counter<factory_creator> {
|
||||
public:
|
||||
component_creator_base() = default;
|
||||
virtual ~component_creator_base() noexcept = default;
|
||||
factory_creator() = default;
|
||||
virtual ~factory_creator() noexcept = default;
|
||||
|
||||
virtual bool validate_json(
|
||||
const rapidjson::Value& root) const = 0;
|
||||
|
||||
virtual bool fill_prototype(
|
||||
ecs::prototype& prototype,
|
||||
const component_loader<>::fill_context& ctx) const = 0;
|
||||
const factory_loader<>::fill_context& ctx) const = 0;
|
||||
|
||||
virtual bool collect_dependencies(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const = 0;
|
||||
const factory_loader<>::collect_context& ctx) const = 0;
|
||||
};
|
||||
|
||||
//
|
||||
// component_creator
|
||||
//
|
||||
|
||||
template < typename Component >
|
||||
class component_creator : public component_creator_base {
|
||||
class typed_factory_creator final : public factory_creator {
|
||||
public:
|
||||
component_creator();
|
||||
~component_creator() noexcept override = default;
|
||||
typed_factory_creator();
|
||||
~typed_factory_creator() noexcept final = default;
|
||||
|
||||
bool validate_json(
|
||||
const rapidjson::Value& root) const override;
|
||||
const rapidjson::Value& root) const final;
|
||||
|
||||
bool fill_prototype(
|
||||
ecs::prototype& prototype,
|
||||
const component_loader<>::fill_context& ctx) const override;
|
||||
const factory_loader<>::fill_context& ctx) const final;
|
||||
|
||||
bool collect_dependencies(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const override;
|
||||
const factory_loader<>::collect_context& ctx) const final;
|
||||
private:
|
||||
component_loader<Component> loader_;
|
||||
factory_loader<Component> loader_;
|
||||
std::unique_ptr<rapidjson::SchemaDocument> schema_;
|
||||
};
|
||||
|
||||
//
|
||||
// component_factory
|
||||
// factory
|
||||
//
|
||||
|
||||
class component_factory : public module<component_factory> {
|
||||
class factory : public module<factory> {
|
||||
public:
|
||||
component_factory() = default;
|
||||
~component_factory() noexcept final = default;
|
||||
factory() = default;
|
||||
~factory() noexcept final = default;
|
||||
|
||||
template < typename Component >
|
||||
component_factory& register_component(str_hash type);
|
||||
factory& register_component(str_hash type);
|
||||
|
||||
bool validate_json(
|
||||
str_hash type,
|
||||
@@ -130,19 +125,19 @@ namespace e2d
|
||||
bool fill_prototype(
|
||||
str_hash type,
|
||||
ecs::prototype& prototype,
|
||||
const component_loader<>::fill_context& ctx) const;
|
||||
const factory_loader<>::fill_context& ctx) const;
|
||||
|
||||
bool collect_dependencies(
|
||||
str_hash type,
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const;
|
||||
const factory_loader<>::collect_context& ctx) const;
|
||||
private:
|
||||
component_creator_base_iptr find_creator(str_hash type) const;
|
||||
factory_creator_iptr find_creator(str_hash type) const;
|
||||
private:
|
||||
mutable std::mutex mutex_;
|
||||
hash_map<str_hash, component_creator_base_iptr> creators_;
|
||||
hash_map<str_hash, factory_creator_iptr> creators_;
|
||||
};
|
||||
}
|
||||
|
||||
#include "component.inl"
|
||||
#include "factory.inl"
|
||||
#endif
|
||||
@@ -4,32 +4,32 @@
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef E2D_INCLUDE_GUARD_85A0D62C0D794C4C9DDFB1BAED3C0A18
|
||||
#define E2D_INCLUDE_GUARD_85A0D62C0D794C4C9DDFB1BAED3C0A18
|
||||
#ifndef E2D_INCLUDE_GUARD_6CDF0C8E49C9459EB7762C8AF7F7ED85
|
||||
#define E2D_INCLUDE_GUARD_6CDF0C8E49C9459EB7762C8AF7F7ED85
|
||||
#pragma once
|
||||
|
||||
#include "_high.hpp"
|
||||
#include "component.hpp"
|
||||
#include "factory.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
//
|
||||
// component_creator
|
||||
// typed_factory_creator
|
||||
//
|
||||
|
||||
template < typename Component >
|
||||
component_creator<Component>::component_creator() {
|
||||
typed_factory_creator<Component>::typed_factory_creator() {
|
||||
rapidjson::Document doc;
|
||||
if ( doc.Parse(loader_.schema_source).HasParseError() ) {
|
||||
the<debug>().error("COMPONENT: Failed to parse component loader schema");
|
||||
throw bad_component_factory_operation();
|
||||
the<debug>().error("FACTORY: Failed to parse factory loader schema");
|
||||
throw bad_factory_operation();
|
||||
}
|
||||
json_utils::add_common_schema_definitions(doc);
|
||||
schema_ = std::make_unique<rapidjson::SchemaDocument>(doc);
|
||||
}
|
||||
|
||||
template < typename Component >
|
||||
bool component_creator<Component>::validate_json(
|
||||
bool typed_factory_creator<Component>::validate_json(
|
||||
const rapidjson::Value& root) const
|
||||
{
|
||||
rapidjson::SchemaValidator validator(*schema_);
|
||||
@@ -38,10 +38,10 @@ namespace e2d
|
||||
}
|
||||
rapidjson::StringBuffer sb;
|
||||
if ( !validator.GetInvalidDocumentPointer().StringifyUriFragment(sb) ) {
|
||||
the<debug>().error("COMPONENT: Failed to validate component json");
|
||||
the<debug>().error("FACTORY: Failed to validate component json");
|
||||
return false;
|
||||
}
|
||||
the<debug>().error("COMPONENT: Failed to validate component json:\n"
|
||||
the<debug>().error("FACTORY: Failed to validate component json:\n"
|
||||
"--> Invalid schema keyword: %0\n"
|
||||
"--> Invalid document pointer: %1",
|
||||
validator.GetInvalidSchemaKeyword(),
|
||||
@@ -50,9 +50,9 @@ namespace e2d
|
||||
}
|
||||
|
||||
template < typename Component >
|
||||
bool component_creator<Component>::fill_prototype(
|
||||
bool typed_factory_creator<Component>::fill_prototype(
|
||||
ecs::prototype& prototype,
|
||||
const component_loader<>::fill_context& ctx) const
|
||||
const factory_loader<>::fill_context& ctx) const
|
||||
{
|
||||
Component component;
|
||||
prototype.apply_to_component(component);
|
||||
@@ -66,27 +66,26 @@ namespace e2d
|
||||
}
|
||||
|
||||
template < typename Component >
|
||||
bool component_creator<Component>::collect_dependencies(
|
||||
bool typed_factory_creator<Component>::collect_dependencies(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const
|
||||
const factory_loader<>::collect_context& ctx) const
|
||||
{
|
||||
return loader_(dependencies, ctx);
|
||||
}
|
||||
|
||||
//
|
||||
// component_factory
|
||||
// factory
|
||||
//
|
||||
|
||||
template < typename Component >
|
||||
component_factory& component_factory::register_component(str_hash type) {
|
||||
factory& factory::register_component(str_hash type) {
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
if ( creators_.count(type) > 0 ) {
|
||||
throw bad_component_factory_operation();
|
||||
throw bad_factory_operation();
|
||||
}
|
||||
component_creator_base_iptr creator(new component_creator<Component>());
|
||||
factory_creator_iptr creator(new typed_factory_creator<Component>());
|
||||
creators_.emplace(type, std::move(creator));
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <enduro2d/high/assets/prefab_asset.hpp>
|
||||
|
||||
#include <enduro2d/high/component.hpp>
|
||||
#include <enduro2d/high/factory.hpp>
|
||||
#include <enduro2d/high/assets/json_asset.hpp>
|
||||
|
||||
namespace
|
||||
@@ -83,7 +83,7 @@ namespace
|
||||
++component_root )
|
||||
{
|
||||
{
|
||||
bool success = the<component_factory>().validate_json(
|
||||
bool success = the<factory>().validate_json(
|
||||
component_root->name.GetString(),
|
||||
component_root->value);
|
||||
if ( !success ) {
|
||||
@@ -91,10 +91,10 @@ namespace
|
||||
}
|
||||
}
|
||||
{
|
||||
component_loader<>::collect_context ctx(
|
||||
factory_loader<>::collect_context ctx(
|
||||
parent_address,
|
||||
component_root->value);
|
||||
bool success = the<component_factory>().collect_dependencies(
|
||||
bool success = the<factory>().collect_dependencies(
|
||||
component_root->name.GetString(),
|
||||
dependencies,
|
||||
ctx);
|
||||
@@ -145,11 +145,11 @@ namespace
|
||||
component_root != components_root.MemberEnd();
|
||||
++component_root )
|
||||
{
|
||||
component_loader<>::fill_context ctx(
|
||||
factory_loader<>::fill_context ctx(
|
||||
parent_address,
|
||||
component_root->value,
|
||||
dependencies);
|
||||
the<component_factory>().fill_prototype(
|
||||
the<factory>().fill_prototype(
|
||||
component_root->name.GetString(),
|
||||
content.prototype(),
|
||||
ctx);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_loader<actor>::schema_source = R"json({
|
||||
const char* factory_loader<actor>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
@@ -19,9 +19,9 @@ namespace e2d
|
||||
}
|
||||
})json";
|
||||
|
||||
bool component_loader<actor>::operator()(
|
||||
bool factory_loader<actor>::operator()(
|
||||
actor& component,
|
||||
const component_loader<>::fill_context& ctx) const
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
if ( !component.node() ) {
|
||||
component.node(node::create());
|
||||
@@ -57,9 +57,9 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
|
||||
bool component_loader<actor>::operator()(
|
||||
bool factory_loader<actor>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(dependencies, ctx);
|
||||
return true;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_loader<camera>::schema_source = R"json({
|
||||
const char* factory_loader<camera>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
@@ -20,9 +20,9 @@ namespace e2d
|
||||
}
|
||||
})json";
|
||||
|
||||
bool component_loader<camera>::operator()(
|
||||
bool factory_loader<camera>::operator()(
|
||||
camera& component,
|
||||
const component_loader<>::fill_context& ctx) const
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("depth") ) {
|
||||
auto depth = component.depth();
|
||||
@@ -67,9 +67,9 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
|
||||
bool component_loader<camera>::operator()(
|
||||
bool factory_loader<camera>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(dependencies, ctx);
|
||||
return true;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_loader<flipbook_player>::schema_source = R"json({
|
||||
const char* factory_loader<flipbook_player>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
@@ -22,9 +22,9 @@ namespace e2d
|
||||
}
|
||||
})json";
|
||||
|
||||
bool component_loader<flipbook_player>::operator()(
|
||||
bool factory_loader<flipbook_player>::operator()(
|
||||
flipbook_player& component,
|
||||
const component_loader<>::fill_context& ctx) const
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("time") ) {
|
||||
auto time = component.time();
|
||||
@@ -83,9 +83,9 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
|
||||
bool component_loader<flipbook_player>::operator()(
|
||||
bool factory_loader<flipbook_player>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(dependencies, ctx);
|
||||
return true;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_loader<flipbook_source>::schema_source = R"json({
|
||||
const char* factory_loader<flipbook_source>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
@@ -17,9 +17,9 @@ namespace e2d
|
||||
}
|
||||
})json";
|
||||
|
||||
bool component_loader<flipbook_source>::operator()(
|
||||
bool factory_loader<flipbook_source>::operator()(
|
||||
flipbook_source& component,
|
||||
const component_loader<>::fill_context& ctx) const
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("flipbook") ) {
|
||||
auto flipbook = ctx.dependencies.find_asset<flipbook_asset>(
|
||||
@@ -38,9 +38,9 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
|
||||
bool component_loader<flipbook_source>::operator()(
|
||||
bool factory_loader<flipbook_source>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("flipbook") ) {
|
||||
dependencies.add_dependency<flipbook_asset>(
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_loader<model_renderer>::schema_source = R"json({
|
||||
const char* factory_loader<model_renderer>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
@@ -17,9 +17,9 @@ namespace e2d
|
||||
}
|
||||
})json";
|
||||
|
||||
bool component_loader<model_renderer>::operator()(
|
||||
bool factory_loader<model_renderer>::operator()(
|
||||
model_renderer& component,
|
||||
const component_loader<>::fill_context& ctx) const
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("model") ) {
|
||||
auto model = ctx.dependencies.find_asset<model_asset>(
|
||||
@@ -38,9 +38,9 @@ namespace e2d
|
||||
return true;;
|
||||
}
|
||||
|
||||
bool component_loader<model_renderer>::operator()(
|
||||
bool factory_loader<model_renderer>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("model") ) {
|
||||
dependencies.add_dependency<model_asset>(
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_loader<renderer>::schema_source = R"json({
|
||||
const char* factory_loader<renderer>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
@@ -21,9 +21,9 @@ namespace e2d
|
||||
}
|
||||
})json";
|
||||
|
||||
bool component_loader<renderer>::operator()(
|
||||
bool factory_loader<renderer>::operator()(
|
||||
renderer& component,
|
||||
const component_loader<>::fill_context& ctx) const
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("enabled") ) {
|
||||
auto enabled = component.enabled();
|
||||
@@ -60,9 +60,9 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
|
||||
bool component_loader<renderer>::operator()(
|
||||
bool factory_loader<renderer>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("materials") ) {
|
||||
const rapidjson::Value& materials_root = ctx.root["materials"];
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_loader<scene>::schema_source = R"json({
|
||||
const char* factory_loader<scene>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
@@ -17,9 +17,9 @@ namespace e2d
|
||||
}
|
||||
})json";
|
||||
|
||||
bool component_loader<scene>::operator()(
|
||||
bool factory_loader<scene>::operator()(
|
||||
scene& component,
|
||||
const component_loader<>::fill_context& ctx) const
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("depth") ) {
|
||||
auto depth = component.depth();
|
||||
@@ -33,9 +33,9 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
|
||||
bool component_loader<scene>::operator()(
|
||||
bool factory_loader<scene>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(dependencies, ctx);
|
||||
return true;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* component_loader<sprite_renderer>::schema_source = R"json({
|
||||
const char* factory_loader<sprite_renderer>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
@@ -19,9 +19,9 @@ namespace e2d
|
||||
}
|
||||
})json";
|
||||
|
||||
bool component_loader<sprite_renderer>::operator()(
|
||||
bool factory_loader<sprite_renderer>::operator()(
|
||||
sprite_renderer& component,
|
||||
const component_loader<>::fill_context& ctx) const
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("tint") ) {
|
||||
auto tint = component.tint();
|
||||
@@ -58,9 +58,9 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
|
||||
bool component_loader<sprite_renderer>::operator()(
|
||||
bool factory_loader<sprite_renderer>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
if ( ctx.root.HasMember("sprite") ) {
|
||||
dependencies.add_dependency<sprite_asset>(
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/high/component.hpp>
|
||||
#include <enduro2d/high/factory.hpp>
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
bool component_factory::validate_json(
|
||||
bool factory::validate_json(
|
||||
str_hash type,
|
||||
const rapidjson::Value& root) const
|
||||
{
|
||||
@@ -18,10 +18,10 @@ namespace e2d
|
||||
: false;
|
||||
}
|
||||
|
||||
bool component_factory::fill_prototype(
|
||||
bool factory::fill_prototype(
|
||||
str_hash type,
|
||||
ecs::prototype& prototype,
|
||||
const component_loader<>::fill_context& ctx) const
|
||||
const factory_loader<>::fill_context& ctx) const
|
||||
{
|
||||
auto creator = find_creator(type);
|
||||
return creator
|
||||
@@ -29,10 +29,10 @@ namespace e2d
|
||||
: false;
|
||||
}
|
||||
|
||||
bool component_factory::collect_dependencies(
|
||||
bool factory::collect_dependencies(
|
||||
str_hash type,
|
||||
asset_dependencies& dependencies,
|
||||
const component_loader<>::collect_context& ctx) const
|
||||
const factory_loader<>::collect_context& ctx) const
|
||||
{
|
||||
auto creator = find_creator(type);
|
||||
return creator
|
||||
@@ -40,7 +40,7 @@ namespace e2d
|
||||
: false;
|
||||
}
|
||||
|
||||
component_creator_base_iptr component_factory::find_creator(str_hash type) const {
|
||||
factory_creator_iptr factory::find_creator(str_hash type) const {
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
const auto iter = creators_.find(type);
|
||||
return iter != creators_.end()
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <enduro2d/high/starter.hpp>
|
||||
|
||||
#include <enduro2d/high/world.hpp>
|
||||
#include <enduro2d/high/factory.hpp>
|
||||
#include <enduro2d/high/library.hpp>
|
||||
#include <enduro2d/high/component.hpp>
|
||||
|
||||
#include <enduro2d/high/components/actor.hpp>
|
||||
#include <enduro2d/high/components/camera.hpp>
|
||||
@@ -125,7 +125,7 @@ namespace e2d
|
||||
|
||||
starter::starter(int argc, char *argv[], const parameters& params) {
|
||||
safe_module_initialize<engine>(argc, argv, params.engine_params());
|
||||
safe_module_initialize<component_factory>()
|
||||
safe_module_initialize<factory>()
|
||||
.register_component<actor>("actor")
|
||||
.register_component<camera>("camera")
|
||||
.register_component<flipbook_player>("flipbook_player")
|
||||
@@ -141,7 +141,7 @@ namespace e2d
|
||||
starter::~starter() noexcept {
|
||||
modules::shutdown<world>();
|
||||
modules::shutdown<library>();
|
||||
modules::shutdown<component_factory>();
|
||||
modules::shutdown<factory>();
|
||||
modules::shutdown<engine>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user