Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:14

0001 // -*- C++ -*-
0002 //
0003 // This file is part of HepMC
0004 // Copyright (C) 2014-2023 The HepMC collaboration (see AUTHORS for details)
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 /** Information about input.
0035 
0036     This class deduces information about the input file from the
0037     filename, such as
0038 
0039     - is it a remote file
0040     - is reading from it an error
0041     - is it a ROOT file
0042     - is it a protobuf file
0043     - is it ASCII (v3)
0044     - is it ASCII (v2)
0045     - is it LHEF file
0046     - is it HEPEVT
0047 
0048     It can also return a reader
0049 */
0050 class InputInfo {
0051 public:
0052     /// @brief Constructor
0053     InputInfo() {};
0054     /// @brief Constructor
0055     InputInfo(const std::string &filename);
0056     /// @brief Classify input
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     /// @brief Get native (built-in) reader
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