class ngraph::FactoryRegistry

Overview

Registry of factories that can construct objects derived from BASE_TYPE. More…

#include <factory.hpp>

template <typename BASE_TYPE>
class FactoryRegistry
{
public:
    // typedefs

    typedef std::function<BASE_TYPE \*()> Factory;
    typedef std::unordered_map<typename BASE_TYPE::type_info_t, Factory> FactoryMap;

    // methods

    template <typename DERIVED_TYPE>
    static Factory get_default_factory();

    void register_factory(
        const typename BASE_TYPE::type_info_t& type_info,
        Factory factory
        );

    template <
        typename DERIVED_TYPE,
        typename std::enable_if<!HasTypeInfoMember<DERIVED_TYPE>::value, bool>::type = true
        >
    void register_factory(Factory factory);

    template <typename DERIVED_TYPE>
    void register_factory();

    bool has_factory(const typename BASE_TYPE::type_info_t& info);

    template <
        typename DERIVED_TYPE,
        typename std::enable_if<!HasTypeInfoMember<DERIVED_TYPE>::value, bool>::type = true
        >
    bool has_factory();

    BASE_TYPE \* create(const typename BASE_TYPE::type_info_t& type_info) const;

    template <
        typename DERIVED_TYPE,
        typename std::enable_if<!HasTypeInfoMember<DERIVED_TYPE>::value, bool>::type = true
        >
    BASE_TYPE \* create() const;
};

Detailed Documentation

Registry of factories that can construct objects derived from BASE_TYPE.

Methods

void register_factory(
    const typename BASE_TYPE::type_info_t& type_info,
    Factory factory
    )

Register a custom factory for type_info.

template <
    typename DERIVED_TYPE,
    typename std::enable_if<!HasTypeInfoMember<DERIVED_TYPE>::value, bool>::type = true
    >
void register_factory(Factory factory)

Register a custom factory for DERIVED_TYPE.

template <typename DERIVED_TYPE>
void register_factory()

Register the defualt constructor factory for DERIVED_TYPE.

bool has_factory(const typename BASE_TYPE::type_info_t& info)

Check to see if a factory is registered.

template <
    typename DERIVED_TYPE,
    typename std::enable_if<!HasTypeInfoMember<DERIVED_TYPE>::value, bool>::type = true
    >
bool has_factory()

Check to see if DERIVED_TYPE has a registered factory.

BASE_TYPE \* create(const typename BASE_TYPE::type_info_t& type_info) const

Create an instance for type_info.

template <
    typename DERIVED_TYPE,
    typename std::enable_if<!HasTypeInfoMember<DERIVED_TYPE>::value, bool>::type = true
    >
BASE_TYPE \* create() const

Create an instance using factory for DERIVED_TYPE.