DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
StreamFactory.hpp
Go to the documentation of this file.
1/*
2 * DUNE DAQ modification notice:
3 * This file has been modified from the original ATLAS ers source for the DUNE DAQ project.
4 * Fork baseline commit: 8267df82a4f6fe6bf02c4014923eba19eddc4614 (2020-04-14).
5 * Renamed since fork: yes (from ers/StreamFactory.h to include/ers/StreamFactory.hpp).
6 *
7 * Original copyright:
8 * Copyright (C) 2001-2020 CERN for the benefit of the ATLAS collaboration.
9 * Licensed under the Apache License, Version 2.0.
10 */
11
12/*
13 * StreamFactory.h
14 * ers
15 *
16 * Created by Matthias Wiesmann on 21.01.05.
17 * Modified by Serguei Kolos on 21.11.05.
18 * Copyright 2005 CERN. All rights reserved.
19 *
20 */
21
22#ifndef ERS_STREAM_FACTORY_H
23#define ERS_STREAM_FACTORY_H
24
25#include <ers/Severity.hpp>
26#include <ers/Context.hpp>
27#include <ers/Issue.hpp>
28
29#include <map>
30
36
38 InvalidFormat,
39 "Creator for the \"" << key << "\" stream is not found",
40 ((std::string)key ) )
41
42namespace ers
43{
44 class InputStream;
45 class OutputStream;
46 template <class > class SingletonCreator;
47
56
57 class StreamFactory
58 {
59 friend std::ostream & operator<<( std::ostream &, const ers::StreamFactory & );
60 template <class > friend class SingletonCreator;
61
62 typedef ers::InputStream * (*InputStreamCreator) ( const std::initializer_list<std::string> & params );
63 typedef ers::OutputStream * (*OutputStreamCreator)( const std::string & format );
64
65 public:
66
67 static StreamFactory & instance();
68
69 void register_in_stream( const std::string & name,
70 InputStreamCreator callback );
71
72 void register_out_stream( const std::string & name,
73 OutputStreamCreator callback );
74
75 InputStream * create_in_stream( const std::string & stream,
76 const std::string & filter ) const;
77
78 InputStream * create_in_stream( const std::string & stream,
79 const std::initializer_list<std::string> & params ) const;
80
81 OutputStream * create_out_stream( const std::string & format ) const;
82
83 private:
84 StreamFactory( )
85 { ; }
86
87 typedef std::map<std::string, InputStreamCreator> InFunctionMap;
88 typedef std::map<std::string, OutputStreamCreator> OutFunctionMap;
89
90 InFunctionMap m_in_factories;
91 OutFunctionMap m_out_factories;
92 };
93
94 std::ostream & operator<<( std::ostream &, const ers::StreamFactory & );
95}
96
97#endif
98
void operator<<(TraceStreamer &x, const ers::Issue &r)
Definition Logger.hxx:102
ERS Issue input stream interface.
ERS abstract output stream interface.
#define ERS_DECLARE_ISSUE( namespace_name, class_name, message_, attributes)
Definition macro.hpp:65
std::ostream & operator<<(std::ostream &, const ers::Configuration &)