LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
stringstream_mfPlugin.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
4 #include "cetlib/PluginTypeDeducer.h"
5 #include "cetlib/ProvideFilePathMacro.h"
6 #include "cetlib/ProvideMakePluginMacros.h"
12 
13 #include <iostream>
14 #include <map>
15 #include <memory>
16 #include <sstream>
17 #include <string>
18 
19 using namespace std;
21 
22 namespace {
23 
24  map<string, cet::ostream_handle> streams;
25 
26 } // unnamed namespace
27 
28 ostringstream&
29 mf::getStringStream(string const& psetName)
30 {
31  auto const I = streams.find(psetName);
32  if (I != streams.end()) {
33  return dynamic_cast<ostringstream&>(static_cast<ostream&>(I->second));
34  }
35  throw Exception(errors::Configuration, "mf::getStringStream:")
36  << "Unable to find specified messagefacility logging stream \"" << psetName
37  << ":\" please ensure it has been configured as a destination.";
38 }
39 
40 MAKE_PLUGIN_START(auto, string const& psetName, fhicl::ParameterSet const& pset)
41 {
42  auto ret = streams.emplace(psetName, cet::ostream_handle{ostringstream{}});
43  return make_unique<ELostreamOutput>(pset, ret.first->second);
44 }
45 MAKE_PLUGIN_END
46 
47 CET_PROVIDE_FILE_PATH()
48 DEFINE_BASIC_PLUGINTYPE_FUNC(mf::service::ELdestination)
STL namespace.
std::ostringstream & getStringStream(std::string const &psetName)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
#define FHICL_PROVIDE_ALLOWED_CONFIGURATION(klass)
MAKE_PLUGIN_START(auto, string const &psetName, fhicl::ParameterSet const &pset)