Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::ComponentFromJSON< TComponent, Enable > Struct Template Reference

A struct that describes how a JSON component description is turned into a component. More...

#include <ecs_world.hpp>

Static Public Member Functions

static TComponent get (const nlohmann::json &jsonComponent)
 Get method that automatically invokes a from_json function, found by nlohmann json.
 

Detailed Description

template<typename TComponent, typename Enable = void>
struct ToyMaker::ComponentFromJSON< TComponent, Enable >

A struct that describes how a JSON component description is turned into a component.

Specialization example:

template <typename TComponent>
std::shared_ptr<TComponent>,
typename std::enable_if<
std::is_base_of<BaseClass, TComponent>::value
>::type> {
static std::shared_ptr<TComponent> get(const nlohmann::json& jsonComponent) {
// your custom way for constructing/retrieving a component
// based on json
return component;
}
};
STL namespace.
A struct that describes how a JSON component description is turned into a component.
Definition ecs_world.hpp:289
static TComponent get(const nlohmann::json &jsonComponent)
Get method that automatically invokes a from_json function, found by nlohmann json.
Definition ecs_world.hpp:296

Member Function Documentation

◆ get()

template<typename TComponent, typename Enable = void>
static TComponent ToyMaker::ComponentFromJSON< TComponent, Enable >::get ( const nlohmann::json & jsonComponent)
inlinestatic

Get method that automatically invokes a from_json function, found by nlohmann json.

Parameters
jsonComponentA description of the component in JSON
Returns
TComponent The type of the component the json component will be used to construct

The documentation for this struct was generated from the following file: