devices.hpp
Go to the documentation of this file.
1 
10 /*****************************************************************************
11 ** Ifdefs
12 *****************************************************************************/
13 
14 #ifndef ECL_CONCEPTS_DEVICES_HPP_
15 #define ECL_CONCEPTS_DEVICES_HPP_
16 
17 /*****************************************************************************
18 ** Includes
19 *****************************************************************************/
20 
21 #include "macros.hpp"
22 
23 /*****************************************************************************
24 ** Namespaces
25 *****************************************************************************/
26 
27 namespace ecl {
28 
29 /*****************************************************************************
30 ** Concept [InputCharDevice]
31 *****************************************************************************/
32 
38 template <typename Implementation>
40 public:
50  char c;
51  char buffer[10];
52  long no_read;
53  bool result;
54  result = input_char_device.open();
55  no_read = input_char_device.read(c);
56  no_read = input_char_device.read(buffer,10);
57  (void) no_read; // remove set but unused warnings
58  (void) result; // remove set but unused warnings
59  }
60 
61 private:
62  // Putting instantiations here actually saves instantiation (which can cause a
63  // problem if there is no default constructor).
64  Implementation input_char_device;
65 };
66 
67 /*****************************************************************************
68 ** Concept [OutputCharDevice]
69 *****************************************************************************/
75 template <typename Implementation>
77 public:
88  {
89  long no_written;
90  char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
91  bool result;
92  result = output_char_device.open();
93  no_written = output_char_device.write('\n');
94  no_written = output_char_device.write(write_buffer,5);
95  output_char_device.flush();
96  (void) no_written; // remove set but unused warnings
97  (void) result; // remove set but unused warnings
98  }
99 
100 private:
101  // Putting instantiations here actually saves instantiation (which can cause a
102  // problem if there is no default constructor).
103  Implementation output_char_device;
104 };
105 
106 /*****************************************************************************
107 ** Concept [InputOutputByteDevice]
108 *****************************************************************************/
109 
115 template <typename Implementation>
117 public:
130  {
131  char c;
132  char read_buffer[10];
133  long no_read;
134  no_read = input_output_char_device.read(c);
135  no_read = input_output_char_device.read(read_buffer,10);
136  long no_written;
137  char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
138  no_written = input_output_char_device.write('\n');
139  no_written = input_output_char_device.write(write_buffer,5);
140  input_output_char_device.flush();
141  }
142 private:
143  // Putting instantiations here actually saves instantiation (which can cause a
144  // problem if there is no default constructor).
145  Implementation input_output_char_device;
146 };
147 
148 /*****************************************************************************
149 ** Concept [InputByteDevice]
150 *****************************************************************************/
151 
158 template <typename Implementation>
160 public:
172  signed char sc;
173  signed char sbuffer[10];
174  char c;
175  char buffer[10];
176  unsigned char usc;
177  unsigned char usbuffer[10];
178  long no_read;
179  bool result;
180  result = input_byte_device.isOpen();
181  no_read = input_byte_device.read(sc);
182  no_read = input_byte_device.read(sbuffer,10);
183  no_read = input_byte_device.read(c);
184  no_read = input_byte_device.read(buffer,10);
185  no_read = input_byte_device.read(usc);
186  no_read = input_byte_device.read(usbuffer,10);
187  }
188 
189 private:
190  // Putting instantiations here actually saves instantiation (which can cause a
191  // problem if there is no default constructor).
192  Implementation input_byte_device;
193 };
194 
195 /*****************************************************************************
196 ** Concept [OutputByteDevice]
197 *****************************************************************************/
204 template <typename Implementation>
206 public:
219  {
220  long no_written;
221  signed char sc = '\n';
222  char c = '\n';
223  unsigned char usc = 0x01;
224  signed char s_write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
225  char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
226  unsigned char us_write_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
227  bool result;
228  result = output_byte_device.isOpen();
229  no_written = output_byte_device.write(sc);
230  no_written = output_byte_device.write(c);
231  no_written = output_byte_device.write(usc);
232  no_written = output_byte_device.write(s_write_buffer,5);
233  no_written = output_byte_device.write(write_buffer,5);
234  no_written = output_byte_device.write(us_write_buffer,5);
235  output_byte_device.flush();
236  }
237 
238 private:
239  // Putting instantiations here actually saves instantiation (which can cause a
240  // problem if there is no default constructor).
241  Implementation output_byte_device;
242 };
243 
244 /*****************************************************************************
245 ** Concept [InputOutputByteDevice]
246 *****************************************************************************/
247 
254 template <typename Implementation>
256 public:
271  {
272  signed char sc;
273  signed char sbuffer[10];
274  char c;
275  char buffer[10];
276  unsigned char usc;
277  unsigned char usbuffer[10];
278  long no_read;
279  bool result;
280  result = input_output_byte_device.isOpen();
281  no_read = input_output_byte_device.read(sc);
282  no_read = input_output_byte_device.read(sbuffer,10);
283  no_read = input_output_byte_device.read(c);
284  no_read = input_output_byte_device.read(buffer,10);
285  no_read = input_output_byte_device.read(usc);
286  no_read = input_output_byte_device.read(usbuffer,10);
287 
288  long no_written;
289  sc = '\n';
290  c = '\n';
291  usc = 0x01;
292  signed char s_write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
293  char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
294  unsigned char us_write_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
295  no_written = input_output_byte_device.write(sc);
296  no_written = input_output_byte_device.write(c);
297  no_written = input_output_byte_device.write(usc);
298  no_written = input_output_byte_device.write(s_write_buffer,5);
299  no_written = input_output_byte_device.write(write_buffer,5);
300  no_written = input_output_byte_device.write(us_write_buffer,5);
301  input_output_byte_device.flush();
302  }
303 private:
304  // Putting instantiations here actually saves instantiation (which can cause a
305  // problem if there is no default constructor).
306  Implementation input_output_byte_device;
307 };
308 
309 }; // namespace ecl
310 
311 #endif /* ECL_CONCEPTS_DEVICES_HPP_ */
Implementation input_output_byte_device
Definition: devices.hpp:306
Embedded control libraries.
Implementation input_output_char_device
Definition: devices.hpp:145
ecl_compile_time_concept_test(InputOutputByteDeviceConcept)
Implements a concept test for input-output byte devices.
Definition: devices.hpp:270
Validates functionality for the output char device concept.
Definition: devices.hpp:76
Implementation input_char_device
Definition: devices.hpp:64
Validates functionality for the input-output char device concept.
Definition: devices.hpp:116
Implementation output_char_device
Definition: devices.hpp:103
ecl_compile_time_concept_test(OutputCharDeviceConcept)
Implements a concept test for output char devices.
Definition: devices.hpp:87
Implementation output_byte_device
Definition: devices.hpp:241
Validates functionality for the output byte device concept.
Definition: devices.hpp:205
Mechanisms enabling compile time checking of metaprogramming concepts.
ecl_compile_time_concept_test(OutputByteDeviceConcept)
Implements a concept test for output byte devices.
Definition: devices.hpp:218
Validates functionality for the input-output byte device concept.
Definition: devices.hpp:255
Implementation input_byte_device
Definition: devices.hpp:192
Validates functionality for the input byte device concept.
Definition: devices.hpp:159
Validates functionality for the input char device concept.
Definition: devices.hpp:39
ecl_compile_time_concept_test(InputCharDeviceConcept)
Implements a concept test for input devices.
Definition: devices.hpp:49
ecl_compile_time_concept_test(InputOutputCharDeviceConcept)
Implements a concept test for input-output byte devices.
Definition: devices.hpp:129
ecl_compile_time_concept_test(InputByteDeviceConcept)
Implements a concept test for input devices.
Definition: devices.hpp:171


ecl_concepts
Author(s): Daniel Stonier
autogenerated on Mon Feb 28 2022 22:18:33