DASH  0.3.0
IOStream.h
1 #ifndef DASH__IO__IOSTREM_H__INCLUDED
2 #define DASH__IO__IOSTREM_H__INCLUDED
3 
4 #include <cstdint>
5 #include <type_traits>
6 
7 namespace dash {
8 namespace io {
9 
16 enum class IOSBaseMode : uint32_t
17 {
18  no_flags = 0,
21  app = 1 << 0,
23  ate = 1 << 1,
25  binary = 1 << 2,
27  in = 1 << 3,
29  out = 1 << 4,
31  trunk = 1 << 5
32 }; // class IOStream
33 
45 template<typename IOSModeType>
47 {
48 private:
49 
51  using UT = std::underlying_type<IOSBaseMode>::type;
52 
53 public:
54 
56 
57  IOStreamMode(IOSModeType ios_base = IOSBaseMode::no_flags)
58  : _ios_mode(ios_base)
59  { }
60 
62 
63  inline operator IOSModeType() const {
64  return _ios_mode;
65  }
66 
70  inline operator bool() const {
71  return _ios_mode != IOSBaseMode::no_flags;
72  }
73 
75 
76  inline self_t & operator|=(const self_t & rhs) {
77  _ios_mode |= rhs._ios_mode;
78  return *this;
79  }
80 
81  inline self_t & operator&=(const self_t & rhs) {
82  _ios_mode &= rhs._ios_mode;
83  return *this;
84  }
85 
86  inline self_t & operator^=(const self_t & rhs) {
87  _ios_mode ^= rhs._ios_mode;
88  return *this;
89  }
90 
91  inline self_t operator~() {
92  return self_t(~_ios_mode);
93  }
94 
95  inline self_t operator|(const self_t & rhs) {
96  return self_t(static_cast<IOSModeType>(
97  static_cast<UT>(_ios_mode)
98  | static_cast<UT>(rhs._ios_mode))
99  );
100  }
101 
102  inline self_t operator&(const self_t & rhs) {
103  return self_t(static_cast<IOSModeType>(
104  static_cast<UT>(_ios_mode)
105  & static_cast<UT>(rhs._ios_mode))
106  );
107  }
108 
109  inline self_t operator^(const self_t & rhs) {
110  return self_t(static_cast<IOSModeType>(
111  static_cast<UT>(_ios_mode)
112  ^ static_cast<UT>(rhs._ios_mode))
113  );
114  }
115 
116 private:
117 
118  IOSModeType _ios_mode;
119 
120 }; // class IOStream
121 
175 template<typename IOSModeType>
176 class IOSBase
177 {
178 public:
179 
181 
182 public:
183 
184  IOSBase()
185  : _io_stream_mode(IOSBaseMode::no_flags)
186  { }
187 
188 protected:
189 
190  ios_mode_type _io_stream_mode;
191 
192 }; // class IOStreamBase
193 
194 } // namespace io
195 } // namespace dash
196 
197 #endif // DASH__IO__IOSTREM_H__INCLUDED
self_t & operator|=(const self_t &rhs)
Binary operators.
Definition: IOStream.h:76
IOStreamMode(IOSModeType ios_base=IOSBaseMode::no_flags)
Constructors.
Definition: IOStream.h:57
This class is a simple memory pool which holds allocates elements of size ValueType.
Definition: AllOf.h:8
Append: set the stream position to the end of the stream before output operations.
Allow output operations on the stream.
At End: set the stream position to the end of the stream on open.
Truncate: discard content of the stream on open.
Allow input operations on the stream.
IOSBaseMode
Modes defined for all parallel IO devices.
Definition: IOStream.h:16
Base type for device-specific IO streams.
Definition: IOStream.h:176
Binary: Consider stream as raw data.
Type facade wrapping dash::io::IOSBaseMode and its device-dependent specializations.
Definition: IOStream.h:46