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/Context.hpp>
26#include <ers/Issue.hpp>
27#include <ers/Severity.hpp>
28
29#include <map>
30
36
37ERS_DECLARE_ISSUE(ers, InvalidFormat, "Creator for the \"" << key << "\" stream is not found", ((std::string)key))
38
39namespace ers {
40class InputStream;
41class OutputStream;
42template<class>
43class SingletonCreator;
44
53
54class StreamFactory
55{
56 friend std::ostream& operator<<(std::ostream&, const ers::StreamFactory&);
57 template<class>
58 friend class SingletonCreator;
59
60 typedef ers::InputStream* (*InputStreamCreator)(const std::initializer_list<std::string>& params);
61 typedef ers::OutputStream* (*OutputStreamCreator)(const std::string& format);
62
63public:
64 static StreamFactory& instance();
65
66 void register_in_stream(const std::string& name,
67 InputStreamCreator callback);
68
69 void register_out_stream(const std::string& name,
70 OutputStreamCreator callback);
71
72 InputStream* create_in_stream(const std::string& stream,
73 const std::string& filter) const;
74
75 InputStream* create_in_stream(const std::string& stream, const std::initializer_list<std::string>& params)
76 const;
77
78 OutputStream* create_out_stream(const std::string& format) const;
79
80private:
81 StreamFactory() { ; }
82
83 typedef std::map<std::string, InputStreamCreator> InFunctionMap;
84 typedef std::map<std::string, OutputStreamCreator> OutFunctionMap;
85
86 InFunctionMap m_in_factories;
87 OutFunctionMap m_out_factories;
88};
89
90std::ostream&
91operator<<(std::ostream&, const ers::StreamFactory&);
92}
93
94#endif
void operator<<(TraceStreamer &x, const ers::Issue &r)
Definition Logger.hxx:128
ERS Issue input stream interface.
ERS abstract output stream interface.
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message_, attributes)
Definition macro.hpp:71