diff --git a/include/HepMC3/ReaderAscii.h b/include/HepMC3/ReaderAscii.h index 77051aa7..0878b845 100644 --- a/include/HepMC3/ReaderAscii.h +++ b/include/HepMC3/ReaderAscii.h @@ -150,8 +150,8 @@ class ReaderAscii : public Reader { private: std::ifstream m_file; //!< Input file - std::shared_ptr m_shared_stream;///< For ctor when reading from temp. stream - std::istream* m_stream; ///< For ctor when reading from stream + std::shared_ptr m_shared_stream = nullptr;///< For ctor when reading from temp. stream + std::istream* m_stream = nullptr; ///< For ctor when reading from stream bool m_isstream; ///< toggles usage of m_file or m_stream /** @brief Temp storage for sets of incoming/outgoing ids for explicit vertices.*/ diff --git a/include/HepMC3/ReaderAsciiHepMC2.h b/include/HepMC3/ReaderAsciiHepMC2.h index c0f37ef8..bc749854 100644 --- a/include/HepMC3/ReaderAsciiHepMC2.h +++ b/include/HepMC3/ReaderAsciiHepMC2.h @@ -129,8 +129,8 @@ class ReaderAsciiHepMC2 : public Reader { // private: std::ifstream m_file; //!< Input file - std::shared_ptr m_shared_stream; ///< For ctor when reading from temp stream - std::istream* m_stream; ///< For ctor when reading from stream + std::shared_ptr m_shared_stream = nullptr; ///< For ctor when reading from temp stream + std::istream* m_stream = nullptr; ///< For ctor when reading from stream bool m_isstream; ///< toggles usage of m_file or m_stream std::vector m_vertex_cache; //!< Vertex cache diff --git a/include/HepMC3/ReaderGZ.h b/include/HepMC3/ReaderGZ.h index 59c228ac..7c7a77e6 100644 --- a/include/HepMC3/ReaderGZ.h +++ b/include/HepMC3/ReaderGZ.h @@ -73,8 +73,8 @@ template class ReaderGZ : public Reader { private: ///@brief Close file stream - std::shared_ptr< std::istream > m_zstr; ///< Stream to read - std::shared_ptr m_reader; ///< Actual reader + std::shared_ptr< std::istream > m_zstr = nullptr; ///< Stream to read + std::shared_ptr m_reader = nullptr; ///< Actual reader }; diff --git a/include/HepMC3/ReaderHEPEVT.h b/include/HepMC3/ReaderHEPEVT.h index 01523d51..87d0a94a 100644 --- a/include/HepMC3/ReaderHEPEVT.h +++ b/include/HepMC3/ReaderHEPEVT.h @@ -72,8 +72,8 @@ class ReaderHEPEVT : public Reader char* hepevtbuffer = nullptr; //!< Pointer to HEPEVT Fortran common block/C struct private: std::ifstream m_file; //!< Input file - std::shared_ptr m_shared_stream; //!< For ctor when reading from temp stream - std::istream* m_stream; //!< For ctor when reading from stream + std::shared_ptr m_shared_stream = nullptr; //!< For ctor when reading from temp stream + std::istream* m_stream = nullptr; //!< For ctor when reading from stream bool m_isstream; //!< toggles usage of m_file or m_stream HEPEVT_Wrapper_Template<100000> m_hepevt_interface; //!< Templated HEPEVT interface }; diff --git a/include/HepMC3/ReaderLHEF.h b/include/HepMC3/ReaderLHEF.h index 6239cbeb..f2233241 100644 --- a/include/HepMC3/ReaderLHEF.h +++ b/include/HepMC3/ReaderLHEF.h @@ -52,9 +52,9 @@ class ReaderLHEF : public Reader ~ReaderLHEF() ; private: void init(); ///< Init helper - std::shared_ptr m_shared_stream; ///< Holds temporary stream - std::shared_ptr m_reader; ///< The actual reader - std::shared_ptr m_hepr; ///< Holder of attributes + std::shared_ptr m_shared_stream = nullptr; ///< Holds temporary stream + std::shared_ptr m_reader = nullptr; ///< The actual reader + std::shared_ptr m_hepr = nullptr; ///< Holder of attributes int m_neve = 0; ///< Event counter bool m_failed = false; ///< State of reader std::deque m_storage; /// m_shared_stream;///< Output temp. stream - std::ostream* m_stream; //!< Output stream + std::shared_ptr m_shared_stream = nullptr;///< Output temp. stream + std::ostream* m_stream = nullptr; //!< Output stream int m_precision = 16; //!< Output precision char* m_buffer = nullptr; //!< Stream buffer diff --git a/include/HepMC3/WriterGZ.h b/include/HepMC3/WriterGZ.h index 74e0c748..eb42ac2e 100644 --- a/include/HepMC3/WriterGZ.h +++ b/include/HepMC3/WriterGZ.h @@ -38,6 +38,12 @@ template class WriterGZ : public Write m_writer = std::make_shared(*(m_zstr.get()), run); } + /// @brief Constructor from ostream + WriterGZ(std::shared_ptr s_stream, std::shared_ptr run = std::shared_ptr()) { + m_zstr = std::shared_ptr< std::ostream >(new ostream(*(s_stream.get()), C)); + m_writer = std::make_shared(m_zstr, run); + } + /// @brief Destructor ~WriterGZ() {}; @@ -63,8 +69,8 @@ template class WriterGZ : public Write std::shared_ptr run_info() const override { return m_writer?m_writer->run_info():nullptr; } private: - std::shared_ptr< std::ostream > m_zstr; ///< Stream to write - std::shared_ptr m_writer; //!< actual writter + std::shared_ptr< std::ostream > m_zstr = nullptr; ///< Stream to write + std::shared_ptr m_writer = nullptr; //!< actual writter }; diff --git a/src/ReaderAscii.cc b/src/ReaderAscii.cc index a5d4bc58..9d3fe456 100644 --- a/src/ReaderAscii.cc +++ b/src/ReaderAscii.cc @@ -22,7 +22,7 @@ namespace HepMC3 { ReaderAscii::ReaderAscii(const std::string &filename) - : m_file(filename), m_stream(nullptr), m_isstream(false) + : m_file(filename), m_isstream(false) { if ( !m_file.is_open() ) { HEPMC3_ERROR("ReaderAscii: could not open input file: " << filename) diff --git a/src/ReaderAsciiHepMC2.cc b/src/ReaderAsciiHepMC2.cc index 7e9c8c28..d96d6478 100644 --- a/src/ReaderAsciiHepMC2.cc +++ b/src/ReaderAsciiHepMC2.cc @@ -23,7 +23,7 @@ namespace HepMC3 { ReaderAsciiHepMC2::ReaderAsciiHepMC2(const std::string& filename): - m_file(filename), m_stream(nullptr), m_isstream(false) { + m_file(filename), m_isstream(false) { if ( !m_file.is_open() ) { HEPMC3_ERROR("ReaderAsciiHepMC2: could not open input file: " << filename ) } diff --git a/src/ReaderHEPEVT.cc b/src/ReaderHEPEVT.cc index 6a33d1a4..b9425349 100644 --- a/src/ReaderHEPEVT.cc +++ b/src/ReaderHEPEVT.cc @@ -16,7 +16,7 @@ namespace HepMC3 { ReaderHEPEVT::ReaderHEPEVT(const std::string &filename) - : m_file(filename), m_stream(nullptr), m_isstream(false) + : m_file(filename), m_isstream(false) { if ( !m_file.is_open() ) { HEPMC3_ERROR("ReaderHEPEVT: could not open input file: " << filename)