ezconfig
Create C++ Objects from Yaml and Json
Loading...
Searching...
No Matches
factory.hpp File Reference

Factory base class. More...

#include <functional>
#include <map>
#include <memory>
#include <sstream>
#include "global.hpp"
Include dependency graph for factory.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ezconfig::GeneralFactory< many, Base, Args >
 A Factory creates objects in a class hierarchy. More...
 
struct  ezconfig::has_factory< many, Base, Args >
 Type trait that marks existing factories. More...
 

Concepts

concept  ezconfig::Constructible
 Concept that identifies existing factories.
 
concept  ezconfig::ManyConstructible
 Concept that identifies existing factories.
 

Macros

#define EZ_GENERAL_FACTORY_DECLARE(many, Base, ...)
 Declare a global factory instance.
 
#define EZ_GENERAL_FACTORY_DEFINE(many, Base, ...)
 Define a global factory instance.
 
#define EZ_GENERAL_FACTORY_INSTANCE(many, Base, ...)
 Retrieve the global factory instance.
 
#define EZ_GENERAL_FACTORY_REGISTER(many, tag, creator, Base, ...)
 Register a tag and creator method in the global factory instance.
 
#define EZ_FACTORY_DECLARE(Base, ...)
 
#define EZ_FACTORY_DEFINE(Base, ...)
 
#define EZ_FACTORY_INSTANCE(Base, ...)
 
#define EZ_FACTORY_REGISTER(tag, creator, Base, ...)
 

Typedefs

template<typename Base , typename... Args>
using ezconfig::Factory = GeneralFactory<false, Base, Args...>
 A factory that creates a single instance.
 
template<typename Base , typename... Args>
using ezconfig::ManyFactory = GeneralFactory<false, Base, Args...>
 A factory that creates a vector of instances.
 

Detailed Description

Factory base class.

Definition in file factory.hpp.

Macro Definition Documentation

◆ EZ_FACTORY_DECLARE

#define EZ_FACTORY_DECLARE ( Base,
... )
Value:
EZ_GENERAL_FACTORY_DECLARE(false, Base, __VA_ARGS__)
#define EZ_GENERAL_FACTORY_DECLARE(many, Base,...)
Declare a global factory instance.
Definition factory.hpp:98

Definition at line 120 of file factory.hpp.

◆ EZ_FACTORY_DEFINE

#define EZ_FACTORY_DEFINE ( Base,
... )
Value:
EZ_GENERAL_FACTORY_DEFINE(false, Base, __VA_ARGS__)
#define EZ_GENERAL_FACTORY_DEFINE(many, Base,...)
Define a global factory instance.
Definition factory.hpp:105

Definition at line 121 of file factory.hpp.

◆ EZ_FACTORY_INSTANCE

#define EZ_FACTORY_INSTANCE ( Base,
... )
Value:
EZ_GENERAL_FACTORY_INSTANCE(false, Base, __VA_ARGS__)
#define EZ_GENERAL_FACTORY_INSTANCE(many, Base,...)
Retrieve the global factory instance.
Definition factory.hpp:109

Definition at line 122 of file factory.hpp.

◆ EZ_FACTORY_REGISTER

#define EZ_FACTORY_REGISTER ( tag,
creator,
Base,
... )
Value:
EZ_GENERAL_FACTORY_REGISTER(false, tag, creator, Base, __VA_ARGS__)
#define EZ_GENERAL_FACTORY_REGISTER(many, tag, creator, Base,...)
Register a tag and creator method in the global factory instance.
Definition factory.hpp:113

Definition at line 123 of file factory.hpp.

◆ EZ_GENERAL_FACTORY_DECLARE

#define EZ_GENERAL_FACTORY_DECLARE ( many,
Base,
... )
Value:
EZ_GLOBAL_DECLARE(ezconfig::GeneralFactory<many, Base __VA_OPT__(, ) __VA_ARGS__>); \
template<> \
struct ezconfig::has_factory<many, Base __VA_OPT__(, ) __VA_ARGS__> : public std::true_type \
{}
A Factory creates objects in a class hierarchy.
Definition factory.hpp:31
#define EZ_GLOBAL_DECLARE(...)
Declare a template specialization of gInstance.
Definition global.hpp:29
Type trait that marks existing factories.
Definition factory.hpp:87

Declare a global factory instance.

Definition at line 98 of file factory.hpp.

◆ EZ_GENERAL_FACTORY_DEFINE

#define EZ_GENERAL_FACTORY_DEFINE ( many,
Base,
... )
Value:
EZ_GLOBAL_DEFINE(ezconfig::GeneralFactory<many, Base __VA_OPT__(, ) __VA_ARGS__>)
#define EZ_GLOBAL_DEFINE(...)
Define a template specialization of gInstance that returns the global instance.
Definition global.hpp:40

Define a global factory instance.

Definition at line 105 of file factory.hpp.

◆ EZ_GENERAL_FACTORY_INSTANCE

#define EZ_GENERAL_FACTORY_INSTANCE ( many,
Base,
... )
Value:
EZ_GLOBAL_INSTANCE(ezconfig::GeneralFactory<many, Base __VA_OPT__(, ) __VA_ARGS__>)
#define EZ_GLOBAL_INSTANCE(...)
Retrieve the global instance for a type.
Definition global.hpp:52

Retrieve the global factory instance.

Definition at line 109 of file factory.hpp.

◆ EZ_GENERAL_FACTORY_REGISTER

#define EZ_GENERAL_FACTORY_REGISTER ( many,
tag,
creator,
Base,
... )
Value:
EZ_STATIC_INVOKE( \
&ezconfig::GeneralFactory<many, Base __VA_OPT__(, ) __VA_ARGS__>::add, \
EZ_GENERAL_FACTORY_INSTANCE(many, Base, __VA_ARGS__), \
tag, \
creator)

Register a tag and creator method in the global factory instance.

Definition at line 113 of file factory.hpp.

Typedef Documentation

◆ Factory

template<typename Base , typename... Args>
using ezconfig::Factory = GeneralFactory<false, Base, Args...>

A factory that creates a single instance.

Definition at line 76 of file factory.hpp.

◆ ManyFactory

template<typename Base , typename... Args>
using ezconfig::ManyFactory = GeneralFactory<false, Base, Args...>

A factory that creates a vector of instances.

Definition at line 82 of file factory.hpp.