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
{
28
using
create_processor_func
= std::function<std::shared_ptr<T>()>;
30
using
name_creator_map
= std::unordered_map<std::string, create_processor_func>;
31
32
public
:
33
AbstractFactory
() {}
34
AbstractFactory
(
const
AbstractFactory
&) =
delete
;
35
AbstractFactory
&
operator=
(
const
AbstractFactory
&) =
delete
;
36
virtual
~AbstractFactory
() =
default
;
37
43
std::shared_ptr<T>
create_processor
(
const
std::string& processor_name);
44
50
static
void
register_creator
(
const
std::string& processor_name,
create_processor_func
creator);
51
53
static
std::shared_ptr<AbstractFactory<T>>
get_instance
();
54
55
protected
:
57
static
std::shared_ptr<AbstractFactory<T>>
s_single_factory
;
58
59
private
:
61
static
name_creator_map
&
get_creators
();
62
};
63
64
}
// namespace tpglibs
65
66
#include "
tpglibs/AbstractFactory.hxx
"
67
68
#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:30
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:18
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:28
tpglibs::AbstractFactory::get_instance
static std::shared_ptr< AbstractFactory< T > > get_instance()
Singleton get instance function.
Definition
AbstractFactory.hxx:48
tpglibs::AbstractFactory::create_processor
std::shared_ptr< T > create_processor(const std::string &processor_name)
Create the requested processor.
Definition
AbstractFactory.hxx:36
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:24
tpglibs::AbstractFactory::AbstractFactory
AbstractFactory()
Definition
AbstractFactory.hpp:33
tpglibs::AbstractFactory::s_single_factory
static std::shared_ptr< AbstractFactory< T > > s_single_factory
Singleton instance.
Definition
AbstractFactory.hpp:57
tpglibs
Definition
AbstractFactory.hpp:20
AbstractFactory.hxx
Generated on
for DUNE-DAQ by
1.17.0