hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DRCEFileStream.hpp
Go to the documentation of this file.
1 
14 #ifndef DRCE_FILE_STREAM_HPP
15 #define DRCE_FILE_STREAM_HPP
16 
17 #include <fstream>
18 #include <iostream>
19 
20 namespace HCE
21 {
22 namespace drce
23 {
24 //-----------------------------------------------------------------------------
26 {
27 public:
28  typedef std::ios_base::openmode OpenMode;
29 
30  static const OpenMode write = (std::fstream::trunc|std::fstream::binary|std::fstream::out);
31  static const OpenMode read = (std::fstream::binary|std::fstream::in);
32 
33  FileStream(void);
34  FileStream(const std::string& fileName, OpenMode openMode=write);
35  ~FileStream(void);
36 
37  bool isOpen(void) const;
38  void open(const std::string& fileName, OpenMode openMode=write);
39  void close(void);
40 
41  FileStream& operator<<(const std::string& data);
42  FileStream& operator>>(std::string& data);
43 
44  static std::string getDataFileName(const std::string& dir, unsigned int taskId);
45  static std::string getStatusFileName(const std::string& dir, unsigned int taskId);
46  static std::string getRequestFileName(const std::string& dir, unsigned int taskId);
47  static std::string getDumpFileName(const std::string& dir, const std::string& nodeName);
48 
49  static bool isStatusFileName(const std::string& fileName);
50 private:
51  std::fstream fs;
52 };
53 //-----------------------------------------------------------------------------
54 //-----------------------------------------------------------------------------
55 } // end namespace drce
56 } // end namespace HCE
57 
58 #endif // DRCE_FILE_STREAM_HPP