CppFactory  0.1.0
Modern c++ object factory implementation in <200 lines
Static Public Member Functions | List of all members
CppFactory::Object< TObject > Class Template Reference

Represents an object that is created via a "factory" More...

#include <CppFactory.hpp>

Static Public Member Functions

template<int TZone = 0>
static void RegisterAllocator (const std::function< std::shared_ptr< TObject >()> &alloc)
 Registers logic capable of allocating (and optionally deallocating) an object of type TObject More...
 
static void UnregisterAllocator ()
 Unregisters all allocators for all zones for type TObject More...
 
template<int TZone>
static void UnregisterAllocator ()
 Unregisters all allocators for a particular zone for type TObject More...
 
template<int TZone = 0>
static std::shared_ptr< TObject > Get ()
 Gets (and allocates, if needed) an object (optionally from a particular zone) for type TObject More...
 

Detailed Description

template<class TObject>
class CppFactory::Object< TObject >

Represents an object that is created via a "factory"

Parameters
TObjectThe type of object

Member Function Documentation

◆ Get()

template<class TObject>
template<int TZone = 0>
static std::shared_ptr<TObject> CppFactory::Object< TObject >::Get ( )
inlinestatic

Gets (and allocates, if needed) an object (optionally from a particular zone) for type TObject

Parameters
TZoneThe zone to get from
Returns
The object

Object<TObject>::Get();

◆ RegisterAllocator()

template<class TObject>
template<int TZone = 0>
static void CppFactory::Object< TObject >::RegisterAllocator ( const std::function< std::shared_ptr< TObject< TObject > >()> &  alloc)
inlinestatic

Registers logic capable of allocating (and optionally deallocating) an object of type TObject

Parameters
TZoneThe zone to register for
allocFunction that allocates an object

Object<TObject>::RegisterAllocator([] { return std::make_shared<TObject>(); });

◆ UnregisterAllocator() [1/2]

template<class TObject>
static void CppFactory::Object< TObject >::UnregisterAllocator ( )
inlinestatic

Unregisters all allocators for all zones for type TObject

Object<TObject>::UnregisterAllocator();

◆ UnregisterAllocator() [2/2]

template<class TObject>
template<int TZone>
static void CppFactory::Object< TObject >::UnregisterAllocator ( )
inlinestatic

Unregisters all allocators for a particular zone for type TObject

Parameters
TZoneThe zone to unregister

Object<TObject>::UnregisterAllocator(10);


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