Skip to content

Commit

Permalink
Merge branch 'fixconstructors' into 'master'
Browse files Browse the repository at this point in the history
Add missing constructor for WriterGZ and use default values for multiple classes

See merge request hepmc/HepMC3!341
  • Loading branch information
Andrii Verbytskyi committed Apr 17, 2024
2 parents 7a018a0 + bb004df commit 2c45fd5
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions include/HepMC3/ReaderAscii.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ class ReaderAscii : public Reader {
private:

std::ifstream m_file; //!< Input file
std::shared_ptr<std::istream> m_shared_stream;///< For ctor when reading from temp. stream
std::istream* m_stream; ///< For ctor when reading from stream
std::shared_ptr<std::istream> 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.*/
Expand Down
4 changes: 2 additions & 2 deletions include/HepMC3/ReaderAsciiHepMC2.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class ReaderAsciiHepMC2 : public Reader {
//
private:
std::ifstream m_file; //!< Input file
std::shared_ptr<std::istream> m_shared_stream; ///< For ctor when reading from temp stream
std::istream* m_stream; ///< For ctor when reading from stream
std::shared_ptr<std::istream> 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<GenVertexPtr> m_vertex_cache; //!< Vertex cache
Expand Down
4 changes: 2 additions & 2 deletions include/HepMC3/ReaderGZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ template <class T> class ReaderGZ : public Reader {

private:
///@brief Close file stream
std::shared_ptr< std::istream > m_zstr; ///< Stream to read
std::shared_ptr<Reader> m_reader; ///< Actual reader
std::shared_ptr< std::istream > m_zstr = nullptr; ///< Stream to read
std::shared_ptr<Reader> m_reader = nullptr; ///< Actual reader

};

Expand Down
4 changes: 2 additions & 2 deletions include/HepMC3/ReaderHEPEVT.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::istream> m_shared_stream; //!< For ctor when reading from temp stream
std::istream* m_stream; //!< For ctor when reading from stream
std::shared_ptr<std::istream> 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
};
Expand Down
6 changes: 3 additions & 3 deletions include/HepMC3/ReaderLHEF.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class ReaderLHEF : public Reader
~ReaderLHEF() ;
private:
void init(); ///< Init helper
std::shared_ptr<std::istream> m_shared_stream; ///< Holds temporary stream
std::shared_ptr<LHEF::Reader> m_reader; ///< The actual reader
std::shared_ptr<HEPRUPAttribute> m_hepr; ///< Holder of attributes
std::shared_ptr<std::istream> m_shared_stream = nullptr; ///< Holds temporary stream
std::shared_ptr<LHEF::Reader> m_reader = nullptr; ///< The actual reader
std::shared_ptr<HEPRUPAttribute> m_hepr = nullptr; ///< Holder of attributes
int m_neve = 0; ///< Event counter
bool m_failed = false; ///< State of reader
std::deque<GenEvent> m_storage; ///<storage used for subevents.
Expand Down
4 changes: 2 additions & 2 deletions include/HepMC3/WriterAscii.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class WriterAscii : public Writer {
private:

std::ofstream m_file; //!< Output file
std::shared_ptr<std::ostream> m_shared_stream;///< Output temp. stream
std::ostream* m_stream; //!< Output stream
std::shared_ptr<std::ostream> 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
Expand Down
10 changes: 8 additions & 2 deletions include/HepMC3/WriterGZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ template <class T, Compression C = Compression::z> class WriterGZ : public Write
m_writer = std::make_shared<T>(*(m_zstr.get()), run);
}

/// @brief Constructor from ostream
WriterGZ(std::shared_ptr<std::ostream> s_stream, std::shared_ptr<GenRunInfo> run = std::shared_ptr<GenRunInfo>()) {
m_zstr = std::shared_ptr< std::ostream >(new ostream(*(s_stream.get()), C));
m_writer = std::make_shared<T>(m_zstr, run);
}

/// @brief Destructor
~WriterGZ() {};

Expand All @@ -63,8 +69,8 @@ template <class T, Compression C = Compression::z> class WriterGZ : public Write
std::shared_ptr<GenRunInfo> 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<Writer> m_writer; //!< actual writter
std::shared_ptr< std::ostream > m_zstr = nullptr; ///< Stream to write
std::shared_ptr<Writer> m_writer = nullptr; //!< actual writter

};

Expand Down
2 changes: 1 addition & 1 deletion src/ReaderAscii.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/ReaderAsciiHepMC2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
}
Expand Down
2 changes: 1 addition & 1 deletion src/ReaderHEPEVT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2c45fd5

Please sign in to comment.