neic-glass3  1.4.6
fileInput.h
Go to the documentation of this file.
1 /*****************************************
2  * This file is documented for Doxygen.
3  * If you modify this file please update
4  * the comments so that Doxygen will still
5  * be able to work.
6  ****************************************/
7 #ifndef FILEINPUT_H
8 #define FILEINPUT_H
9 
10 #include <json.h>
11 #include <threadbaseclass.h>
12 #include <input.h>
13 
14 #include <chrono>
15 #include <mutex>
16 #include <string>
17 #include <memory>
18 
19 #define GPICK_EXTENSION "gpick"
20 #define GPICKS_EXTENSION "gpicks"
21 #define JSON_EXTENSION "json"
22 #define CC_EXTENSION "dat"
23 
24 namespace glass3 {
35  public:
42  fileInput();
43 
54  explicit fileInput(const std::shared_ptr<const json::Object> &config);
55 
62  ~fileInput();
63 
74  bool setup(std::shared_ptr<const json::Object> config) override;
75 
82  void clear() override;
83 
90  const std::string getInputDir();
91 
98  void setInputDir(const std::string &dir);
99 
107  const std::string getArchiveDir();
108 
115  void setArchiveDir(const std::string &dir);
116 
124  const std::string getFormat();
125 
132  void setFormat(const std::string &format);
133 
141  void setShutdownWhenNoData(bool shutdown);
142 
151  bool getShutdownWhenNoData();
152 
160  void setShutdownWait(int waitTime);
161 
169  int getShutdownWait();
170 
171  protected:
181  std::string fetchRawData(std::string* pOutType) override;
182 
194  void cleanupFile(std::string filename, bool move,
195  std::string destinationdir);
196 
197  private:
201  std::string m_sInputDir;
202 
207  std::string m_sArchiveDir;
208 
213  std::string m_sFormat;
214 
219  std::atomic<bool> m_bShutdownWhenNoData;
220 
225  std::atomic<int> m_iShutdownWait;
226 
230  std::ifstream m_InputFile;
231 
235  std::string m_sFileName;
236 
240  std::chrono::high_resolution_clock::time_point m_tFileStartTime;
241 
245  int m_iDataCount;
246 
251  std::mutex & getMutex();
252 
256  std::mutex m_Mutex;
257 };
258 } // namespace glass3
259 #endif // FILEINPUT_H
void setShutdownWait(int waitTime)
Function to set the shutdown wait time.
Definition: fileInput.cpp:352
int getShutdownWait()
Function to retrieve the shutdown wait time.
Definition: fileInput.cpp:357
void clear() override
output clear function
Definition: fileInput.cpp:156
bool setup(std::shared_ptr< const json::Object > config) override
fileInput configuration function
Definition: fileInput.cpp:46
void setInputDir(const std::string &dir)
Function to set the name of the input directory.
Definition: fileInput.cpp:312
void setArchiveDir(const std::string &dir)
Function to set the name of the archive directory.
Definition: fileInput.cpp:324
bool getShutdownWhenNoData()
Function to retrieve whether to shutdown when no data.
Definition: fileInput.cpp:347
std::string fetchRawData(std::string *pOutType) override
get input data string and type
Definition: fileInput.cpp:172
fileInput()
fileInput constructor
Definition: fileInput.cpp:18
void setShutdownWhenNoData(bool shutdown)
Function to set whether to shutdown when no data.
Definition: fileInput.cpp:342
The neic-glass3 project namespace containing all the classes and functions that make up neic-glass3...
neic-glass3 Input class
Definition: input.h:66
glass fileInput class
Definition: fileInput.h:34
const std::string getInputDir()
Function to retrieve the name of the input directory.
Definition: fileInput.cpp:306
void setFormat(const std::string &format)
Function to set the format type (extension)
Definition: fileInput.cpp:336
const std::string getArchiveDir()
Function to retrieve the name of the archive directory.
Definition: fileInput.cpp:318
const std::string getFormat()
Function to retrieve the format type (extension)
Definition: fileInput.cpp:330
void cleanupFile(std::string filename, bool move, std::string destinationdir)
cleanup file function
Definition: fileInput.cpp:288
~fileInput()
fileInput destructor
Definition: fileInput.cpp:42