DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
tpglibs
include
tpglibs
AbstractFactory.hpp
Go to the documentation of this file.
1
8
9
#ifndef TPGLIBS_ABSTRACTFACTORY_HPP_
10
#define TPGLIBS_ABSTRACTFACTORY_HPP_
11
12
#include <cstdint>
13
#include <exception>
14
#include <functional>
15
#include <iostream>
16
#include <memory>
17
#include <string>
18
#include <unordered_map>
19
20
namespace
tpglibs
{
21
25
template
<
typename
T>
26
class
AbstractFactory
27
{
29
using
create_processor_func
= std::function<std::shared_ptr<T>()>;
31
using
name_creator_map
= std::unordered_map<std::string, create_processor_func>;
32
33
public
:
34
AbstractFactory
() {}
35
AbstractFactory
(
const
AbstractFactory
&) =
delete
;
36
AbstractFactory
&
operator=
(
const
AbstractFactory
&) =
delete
;
37
virtual
~AbstractFactory
() =
default
;
38
44
std::shared_ptr<T>
create_processor
(
const
std::string& processor_name);
45
51
static
void
register_creator
(
const
std::string& processor_name,
create_processor_func
creator);
52
54
static
std::shared_ptr<AbstractFactory<T>>
get_instance
();
55
56
protected
:
58
static
std::shared_ptr<AbstractFactory<T>>
s_single_factory
;
59
60
private
:
62
static
name_creator_map
&
get_creators
();
63
};
64
65
}
// namespace tpglibs
66
67
#include "
tpglibs/AbstractFactory.hxx
"
68
69
#endif
// TPGLIBS_ABSTRACTFACTORY_HPP_
tpglibs::AbstractFactory::AbstractFactory
AbstractFactory(const AbstractFactory &)=delete
tpglibs::AbstractFactory::name_creator_map
std::unordered_map< std::string, create_processor_func > name_creator_map
Map from processor name to processor creation function.
Definition
AbstractFactory.hpp:31
tpglibs::AbstractFactory::operator=
AbstractFactory & operator=(const AbstractFactory &)=delete
tpglibs::AbstractFactory::get_creators
static name_creator_map & get_creators()
Returns singleton instance of creation map.
Definition
AbstractFactory.hxx:19
tpglibs::AbstractFactory::~AbstractFactory
virtual ~AbstractFactory()=default
tpglibs::AbstractFactory::create_processor_func
std::function< std::shared_ptr< T >()> create_processor_func
Function that creates shared_ptrs of type T.
Definition
AbstractFactory.hpp:29
tpglibs::AbstractFactory::get_instance
static std::shared_ptr< AbstractFactory< T > > get_instance()
Singleton get instance function.
Definition
AbstractFactory.hxx:55
tpglibs::AbstractFactory::create_processor
std::shared_ptr< T > create_processor(const std::string &processor_name)
Create the requested processor.
Definition
AbstractFactory.hxx:41
tpglibs::AbstractFactory::register_creator
static void register_creator(const std::string &processor_name, create_processor_func creator)
Register the processor creation function to a given name.
Definition
AbstractFactory.hxx:27
tpglibs::AbstractFactory::AbstractFactory
AbstractFactory()
Definition
AbstractFactory.hpp:34
tpglibs::AbstractFactory::s_single_factory
static std::shared_ptr< AbstractFactory< T > > s_single_factory
Singleton instance.
Definition
AbstractFactory.hpp:58
tpglibs
Definition
AbstractFactory.hpp:20
AbstractFactory.hxx
Generated on
for DUNE-DAQ by
1.18.0