Jpp  18.2.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JGZFileReader.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JGZFILEREADER__
2 #define __JLANG__JGZFILEREADER__
3 
4 #include <istream>
5 
6 #include "JLang/gzstream.h"
7 #include "JLang/JAccessible.hh"
9 #include "JLang/JException.hh"
10 
11 
12 /**
13  * \author mdejong
14  */
15 
16 namespace JLANG {}
17 namespace JPP { using namespace JLANG; }
18 
19 namespace JLANG {
20 
21 
22  /**
23  * Object reading from gzipped file.
24  *
25  * This class implements the JAccessibleObjectIterator interface.
26  */
27  template<class T>
28  class JGZFileReader :
29  public igzstream,
30  public JStreamObjectIterator <T>,
32  {
33  public:
34  /**
35  * Default constructor.
36  */
38  igzstream(),
39  JStreamObjectIterator<T>(static_cast<std::istream&>(*this))
40  {}
41 
42 
43  /**
44  * Constructor.
45  *
46  * \param file_name file name
47  */
48  JGZFileReader(const char* file_name) :
49  JAccessible(),
50  igzstream(file_name),
51  JStreamObjectIterator<T>(static_cast<std::istream&>(*this))
52  {}
53 
54 
55  /**
56  * Check is file is open.
57  *
58  * \return true if open; else false
59  */
60  virtual bool is_open() const override
61  {
62  return igzstream::is_open();
63  }
64 
65 
66  /**
67  * Open file.
68  *
69  * \param file_name file name
70  */
71  virtual void open(const char* file_name) override
72  {
73  igzstream::open(file_name);
74 
75  if (!this->is_open()) {
76  this->Throw(JFileOpenException(std::string("Error opening file ") + file_name));
77  }
78  }
79 
80 
81  /**
82  * Close file.
83  */
84  virtual void close() override
85  {
87  }
88  };
89 }
90 
91 #endif
Exception for opening of file.
Definition: JException.hh:358
virtual void close() override
Close file.
virtual void open(const char *file_name) override
Open file.
Exceptions.
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
virtual bool is_open() const override
Check is file is open.
JGZFileReader(const char *file_name)
Constructor.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
then awk string
Interface for object iteration with named access.
void close()
Definition: gzstream.h:185
JGZFileReader()
Default constructor.
Object reading from gzipped file.
bool is_open() const
Definition: gzstream.h:194
void open(const char *name, int open_mode=std::ios::in)
Definition: gzstream.h:208
Interface for named access of a device.
Definition: JAccessible.hh:20
static void Throw(const bool option)
Enable/disable throw option.
Definition: JThrow.hh:37