File indexing completed on 2025-01-18 10:01:14
0001
0002
0003
0004
0005
0006 #ifndef HEPMC3_READERFACTORY_FWD_H
0007 #define HEPMC3_READERFACTORY_FWD_H
0008
0009 #include <memory>
0010 #include <string>
0011 #include <sys/stat.h>
0012 #include <string.h>
0013
0014 #include "HepMC3/ReaderAscii.h"
0015 #include "HepMC3/ReaderAsciiHepMC2.h"
0016 #include "HepMC3/ReaderHEPEVT.h"
0017 #include "HepMC3/ReaderLHEF.h"
0018 #include "HepMC3/ReaderPlugin.h"
0019 #include "HepMC3/CompressedIO.h"
0020
0021 namespace HepMC3 {
0022 #if ! (defined(__darwin__) || defined(__APPLE__)) && ! ((defined(WIN32) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__))
0023 const std::string libHepMC3rootIO = "libHepMC3rootIO.so.3";
0024 const std::string libHepMC3protobufIO = "libHepMC3protobufIO.so.1";
0025 #endif
0026 #if defined(__darwin__) || defined(__APPLE__)
0027 const std::string libHepMC3rootIO = "libHepMC3rootIO.dylib";
0028 const std::string libHepMC3protobufIO = "libHepMC3protobufIO.dylib";
0029 #endif
0030 #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__)
0031 const std::string libHepMC3protobufIO = "HepMC3protobufIO.dll";
0032 const std::string libHepMC3rootIO = "HepMC3rootIO.dll";
0033 #endif
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 class InputInfo {
0051 public:
0052
0053 InputInfo() {};
0054
0055 InputInfo(const std::string &filename);
0056
0057 void classify();
0058 std::vector<std::string> m_head;
0059 bool m_remote = false;
0060 bool m_pipe = false;
0061 bool m_error = false;
0062 bool m_init = false;
0063 bool m_root = false;
0064 bool m_protobuf = false;
0065 bool m_asciiv3 = false;
0066 bool m_iogenevent = false;
0067 bool m_lhef = false;
0068 bool m_hepevt = false;
0069 std::shared_ptr<Reader> m_reader = nullptr;
0070
0071 template <class T> std::shared_ptr<Reader> native_reader(T& argument);
0072 };
0073
0074 std::shared_ptr<Reader> deduce_reader(std::istream &stream);
0075
0076 std::shared_ptr<Reader> deduce_reader(std::shared_ptr<std::istream> stream);
0077
0078 template <class T> std::shared_ptr<Reader> InputInfo::native_reader(T& argument) {
0079
0080 if (m_asciiv3) {
0081 HEPMC3_DEBUG(10, "Attempt ReaderAscii");
0082 return std::shared_ptr<Reader>((Reader*) ( new ReaderAscii(argument)));
0083 }
0084 if (m_iogenevent) {
0085 HEPMC3_DEBUG(10, "Attempt ReaderAsciiHepMC2");
0086 return std::shared_ptr<Reader>((Reader*) ( new ReaderAsciiHepMC2(argument)));
0087 }
0088 if (m_lhef) {
0089 HEPMC3_DEBUG(10, "Attempt ReaderLHEF");
0090
0091 return std::shared_ptr<Reader>((Reader*) ( new ReaderLHEF(argument)));
0092 }
0093 if (m_hepevt) {
0094 HEPMC3_DEBUG(10, "Attempt ReaderHEPEVT");
0095 return std::shared_ptr<Reader>((Reader*) ( new ReaderHEPEVT(argument)));
0096 }
0097 HEPMC3_DEBUG(10, "deduce_reader: all attempts failed");
0098 return std::shared_ptr<Reader>(nullptr);
0099 }
0100
0101 }
0102 #endif