DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
StreamFactory.hpp File Reference
#include <ers/Context.hpp>
#include <ers/Issue.hpp>
#include <ers/Severity.hpp>
#include <map>
Include dependency graph for StreamFactory.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 ERS_DECLARE_ISSUE (ers, InvalidFormat, "Creator for the \""<< key<< "\" stream is not found",((std::string) key)) namespace ers

Function Documentation

◆ ERS_DECLARE_ISSUE()

ERS_DECLARE_ISSUE ( ers ,
InvalidFormat ,
"Creator for the \""<< key<< "\" stream is not found" ,
((std::string) key)  )

The StreamFactory class is responsible for creating a new instance of a known stream implementation. This class uses singleton pattern. Users should not use this class directly but use the ERS_REGISTER_OUTPUT_STREAM macro instead.

Author
Serguei Kolos Factory for ERS stream implementations.
See also
ers::StreamManager

<return the singleton

<register a stream creator

<register a stream creator

<create new stream

<create new stream

<create new stream

<collection of factories to build input streams

<collection of factories to build output streams

Definition at line 37 of file StreamFactory.hpp.

39 {
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}
void operator<<(TraceStreamer &x, const ers::Issue &r)
Definition Logger.hxx:128