$search
00001 00010 /***************************************************************************** 00011 ** Ifdefs 00012 *****************************************************************************/ 00013 00014 #ifndef ECL_CONCEPTS_DEVICES_HPP_ 00015 #define ECL_CONCEPTS_DEVICES_HPP_ 00016 00017 /***************************************************************************** 00018 ** Includes 00019 *****************************************************************************/ 00020 00021 #include "macros.hpp" 00022 00023 /***************************************************************************** 00024 ** Namespaces 00025 *****************************************************************************/ 00026 00027 namespace ecl { 00028 00029 /***************************************************************************** 00030 ** Concept [InputCharDevice] 00031 *****************************************************************************/ 00032 00038 template <typename Implementation> 00039 class InputCharDeviceConcept { 00040 public: 00049 ecl_compile_time_concept_test(InputCharDeviceConcept) { 00050 char c; 00051 char buffer[10]; 00052 long no_read; 00053 bool result; 00054 result = input_char_device.open(); 00055 no_read = input_char_device.read(c); 00056 no_read = input_char_device.read(buffer,10); 00057 (void) no_read; // remove set but unused warnings 00058 (void) result; // remove set but unused warnings 00059 } 00060 00061 private: 00062 // Putting instantiations here actually saves instantiation (which can cause a 00063 // problem if there is no default constructor). 00064 Implementation input_char_device; 00065 }; 00066 00067 /***************************************************************************** 00068 ** Concept [OutputCharDevice] 00069 *****************************************************************************/ 00075 template <typename Implementation> 00076 class OutputCharDeviceConcept { 00077 public: 00087 ecl_compile_time_concept_test(OutputCharDeviceConcept) 00088 { 00089 long no_written; 00090 char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' }; 00091 bool result; 00092 result = output_char_device.open(); 00093 no_written = output_char_device.write('\n'); 00094 no_written = output_char_device.write(write_buffer,5); 00095 output_char_device.flush(); 00096 (void) no_written; // remove set but unused warnings 00097 (void) result; // remove set but unused warnings 00098 } 00099 00100 private: 00101 // Putting instantiations here actually saves instantiation (which can cause a 00102 // problem if there is no default constructor). 00103 Implementation output_char_device; 00104 }; 00105 00106 /***************************************************************************** 00107 ** Concept [InputOutputByteDevice] 00108 *****************************************************************************/ 00109 00115 template <typename Implementation> 00116 class InputOutputCharDeviceConcept { 00117 public: 00129 ecl_compile_time_concept_test(InputOutputCharDeviceConcept) 00130 { 00131 char c; 00132 char read_buffer[10]; 00133 long no_read; 00134 no_read = input_output_char_device.read(c); 00135 no_read = input_output_char_device.read(read_buffer,10); 00136 long no_written; 00137 char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' }; 00138 no_written = input_output_char_device.write('\n'); 00139 no_written = input_output_char_device.write(write_buffer,5); 00140 input_output_char_device.flush(); 00141 } 00142 private: 00143 // Putting instantiations here actually saves instantiation (which can cause a 00144 // problem if there is no default constructor). 00145 Implementation input_output_char_device; 00146 }; 00147 00148 /***************************************************************************** 00149 ** Concept [InputByteDevice] 00150 *****************************************************************************/ 00151 00158 template <typename Implementation> 00159 class InputByteDeviceConcept { 00160 public: 00171 ecl_compile_time_concept_test(InputByteDeviceConcept) { 00172 signed char sc; 00173 signed char sbuffer[10]; 00174 char c; 00175 char buffer[10]; 00176 unsigned char usc; 00177 unsigned char usbuffer[10]; 00178 long no_read; 00179 bool result; 00180 result = input_byte_device.isOpen(); 00181 no_read = input_byte_device.read(sc); 00182 no_read = input_byte_device.read(sbuffer,10); 00183 no_read = input_byte_device.read(c); 00184 no_read = input_byte_device.read(buffer,10); 00185 no_read = input_byte_device.read(usc); 00186 no_read = input_byte_device.read(usbuffer,10); 00187 } 00188 00189 private: 00190 // Putting instantiations here actually saves instantiation (which can cause a 00191 // problem if there is no default constructor). 00192 Implementation input_byte_device; 00193 }; 00194 00195 /***************************************************************************** 00196 ** Concept [OutputByteDevice] 00197 *****************************************************************************/ 00204 template <typename Implementation> 00205 class OutputByteDeviceConcept { 00206 public: 00218 ecl_compile_time_concept_test(OutputByteDeviceConcept) 00219 { 00220 long no_written; 00221 signed char sc = '\n'; 00222 char c = '\n'; 00223 unsigned char usc = 0x01; 00224 signed char s_write_buffer[] = { 'd', 'u', 'd', 'e', '\n' }; 00225 char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' }; 00226 unsigned char us_write_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; 00227 bool result; 00228 result = output_byte_device.isOpen(); 00229 no_written = output_byte_device.write(sc); 00230 no_written = output_byte_device.write(c); 00231 no_written = output_byte_device.write(usc); 00232 no_written = output_byte_device.write(s_write_buffer,5); 00233 no_written = output_byte_device.write(write_buffer,5); 00234 no_written = output_byte_device.write(us_write_buffer,5); 00235 output_byte_device.flush(); 00236 } 00237 00238 private: 00239 // Putting instantiations here actually saves instantiation (which can cause a 00240 // problem if there is no default constructor). 00241 Implementation output_byte_device; 00242 }; 00243 00244 /***************************************************************************** 00245 ** Concept [InputOutputByteDevice] 00246 *****************************************************************************/ 00247 00254 template <typename Implementation> 00255 class InputOutputByteDeviceConcept { 00256 public: 00270 ecl_compile_time_concept_test(InputOutputByteDeviceConcept) 00271 { 00272 signed char sc; 00273 signed char sbuffer[10]; 00274 char c; 00275 char buffer[10]; 00276 unsigned char usc; 00277 unsigned char usbuffer[10]; 00278 long no_read; 00279 bool result; 00280 result = input_output_byte_device.isOpen(); 00281 no_read = input_output_byte_device.read(sc); 00282 no_read = input_output_byte_device.read(sbuffer,10); 00283 no_read = input_output_byte_device.read(c); 00284 no_read = input_output_byte_device.read(buffer,10); 00285 no_read = input_output_byte_device.read(usc); 00286 no_read = input_output_byte_device.read(usbuffer,10); 00287 00288 long no_written; 00289 sc = '\n'; 00290 c = '\n'; 00291 usc = 0x01; 00292 signed char s_write_buffer[] = { 'd', 'u', 'd', 'e', '\n' }; 00293 char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' }; 00294 unsigned char us_write_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05 }; 00295 no_written = input_output_byte_device.write(sc); 00296 no_written = input_output_byte_device.write(c); 00297 no_written = input_output_byte_device.write(usc); 00298 no_written = input_output_byte_device.write(s_write_buffer,5); 00299 no_written = input_output_byte_device.write(write_buffer,5); 00300 no_written = input_output_byte_device.write(us_write_buffer,5); 00301 input_output_byte_device.flush(); 00302 } 00303 private: 00304 // Putting instantiations here actually saves instantiation (which can cause a 00305 // problem if there is no default constructor). 00306 Implementation input_output_byte_device; 00307 }; 00308 00309 }; // namespace ecl 00310 00311 #endif /* ECL_CONCEPTS_DEVICES_HPP_ */