DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
StreamFactory.hpp File Reference
#include <ers/Severity.hpp>
#include <ers/Context.hpp>
#include <ers/Issue.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.

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