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>
39 class InputCharDeviceConcept {
40 public:
49  ecl_compile_time_concept_test(InputCharDeviceConcept) {
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);
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>
116 class InputOutputCharDeviceConcept {
117 public:
129  ecl_compile_time_concept_test(InputOutputCharDeviceConcept)
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>
159 class InputByteDeviceConcept {
160 public:
171  ecl_compile_time_concept_test(InputByteDeviceConcept) {
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>
205 class OutputByteDeviceConcept {
206 public:
218  ecl_compile_time_concept_test(OutputByteDeviceConcept)
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>
255 class InputOutputByteDeviceConcept {
256 public:
270  ecl_compile_time_concept_test(InputOutputByteDeviceConcept)
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_ */
ecl::InputCharDeviceConcept::input_char_device
Implementation input_char_device
Definition: devices.hpp:78
ecl::OutputCharDeviceConcept::output_char_device
Implementation output_char_device
Definition: devices.hpp:111
ecl::InputOutputCharDeviceConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(InputOutputCharDeviceConcept)
Implements a concept test for input-output byte devices.
Definition: devices.hpp:137
macros.hpp
Mechanisms enabling compile time checking of metaprogramming concepts.
ecl::InputOutputByteDeviceConcept::input_output_byte_device
Implementation input_output_byte_device
Definition: devices.hpp:314
ecl::OutputByteDeviceConcept::output_byte_device
Implementation output_byte_device
Definition: devices.hpp:249
ecl::OutputByteDeviceConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(OutputByteDeviceConcept)
Implements a concept test for output byte devices.
Definition: devices.hpp:226
ecl::InputByteDeviceConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(InputByteDeviceConcept)
Implements a concept test for input devices.
Definition: devices.hpp:179
ecl::InputOutputCharDeviceConcept::input_output_char_device
Implementation input_output_char_device
Definition: devices.hpp:153
ecl::InputCharDeviceConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(InputCharDeviceConcept)
Implements a concept test for input devices.
Definition: devices.hpp:63
ecl::OutputCharDeviceConcept
Validates functionality for the output char device concept.
Definition: devices.hpp:82
ecl::InputOutputByteDeviceConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(InputOutputByteDeviceConcept)
Implements a concept test for input-output byte devices.
Definition: devices.hpp:278
ecl::InputByteDeviceConcept::input_byte_device
Implementation input_byte_device
Definition: devices.hpp:200
ecl
Embedded control libraries.
ecl::OutputCharDeviceConcept::ecl_compile_time_concept_test
ecl_compile_time_concept_test(OutputCharDeviceConcept)
Implements a concept test for output char devices.
Definition: devices.hpp:95


ecl_concepts
Author(s): Daniel Stonier
autogenerated on Sun Aug 2 2020 03:12:08