Program Listing for File devices.hpp
↰ Return to documentation for file (include/ecl/concepts/devices.hpp
)
/*****************************************************************************
** Ifdefs
*****************************************************************************/
#ifndef ECL_CONCEPTS_DEVICES_HPP_
#define ECL_CONCEPTS_DEVICES_HPP_
/*****************************************************************************
** Includes
*****************************************************************************/
#include "macros.hpp"
/*****************************************************************************
** Namespaces
*****************************************************************************/
namespace ecl {
/*****************************************************************************
** Concept [InputCharDevice]
*****************************************************************************/
template <typename Implementation>
class InputCharDeviceConcept {
public:
ecl_compile_time_concept_test(InputCharDeviceConcept) {
char c;
char buffer[10];
long no_read;
bool result;
result = input_char_device.open();
no_read = input_char_device.read(c);
no_read = input_char_device.read(buffer,10);
(void) no_read; // remove set but unused warnings
(void) result; // remove set but unused warnings
}
private:
// Putting instantiations here actually saves instantiation (which can cause a
// problem if there is no default constructor).
Implementation input_char_device;
};
/*****************************************************************************
** Concept [OutputCharDevice]
*****************************************************************************/
template <typename Implementation>
class OutputCharDeviceConcept {
public:
ecl_compile_time_concept_test(OutputCharDeviceConcept)
{
long no_written;
char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
bool result;
result = output_char_device.open();
no_written = output_char_device.write('\n');
no_written = output_char_device.write(write_buffer,5);
output_char_device.flush();
(void) no_written; // remove set but unused warnings
(void) result; // remove set but unused warnings
}
private:
// Putting instantiations here actually saves instantiation (which can cause a
// problem if there is no default constructor).
Implementation output_char_device;
};
/*****************************************************************************
** Concept [InputOutputByteDevice]
*****************************************************************************/
template <typename Implementation>
class InputOutputCharDeviceConcept {
public:
ecl_compile_time_concept_test(InputOutputCharDeviceConcept)
{
char c;
char read_buffer[10];
long no_read;
no_read = input_output_char_device.read(c);
no_read = input_output_char_device.read(read_buffer,10);
long no_written;
char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
no_written = input_output_char_device.write('\n');
no_written = input_output_char_device.write(write_buffer,5);
input_output_char_device.flush();
}
private:
// Putting instantiations here actually saves instantiation (which can cause a
// problem if there is no default constructor).
Implementation input_output_char_device;
};
/*****************************************************************************
** Concept [InputByteDevice]
*****************************************************************************/
template <typename Implementation>
class InputByteDeviceConcept {
public:
ecl_compile_time_concept_test(InputByteDeviceConcept) {
signed char sc;
signed char sbuffer[10];
char c;
char buffer[10];
unsigned char usc;
unsigned char usbuffer[10];
long no_read;
bool result;
result = input_byte_device.isOpen();
no_read = input_byte_device.read(sc);
no_read = input_byte_device.read(sbuffer,10);
no_read = input_byte_device.read(c);
no_read = input_byte_device.read(buffer,10);
no_read = input_byte_device.read(usc);
no_read = input_byte_device.read(usbuffer,10);
}
private:
// Putting instantiations here actually saves instantiation (which can cause a
// problem if there is no default constructor).
Implementation input_byte_device;
};
/*****************************************************************************
** Concept [OutputByteDevice]
*****************************************************************************/
template <typename Implementation>
class OutputByteDeviceConcept {
public:
ecl_compile_time_concept_test(OutputByteDeviceConcept)
{
long no_written;
signed char sc = '\n';
char c = '\n';
unsigned char usc = 0x01;
signed char s_write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
unsigned char us_write_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
bool result;
result = output_byte_device.isOpen();
no_written = output_byte_device.write(sc);
no_written = output_byte_device.write(c);
no_written = output_byte_device.write(usc);
no_written = output_byte_device.write(s_write_buffer,5);
no_written = output_byte_device.write(write_buffer,5);
no_written = output_byte_device.write(us_write_buffer,5);
output_byte_device.flush();
}
private:
// Putting instantiations here actually saves instantiation (which can cause a
// problem if there is no default constructor).
Implementation output_byte_device;
};
/*****************************************************************************
** Concept [InputOutputByteDevice]
*****************************************************************************/
template <typename Implementation>
class InputOutputByteDeviceConcept {
public:
ecl_compile_time_concept_test(InputOutputByteDeviceConcept)
{
signed char sc;
signed char sbuffer[10];
char c;
char buffer[10];
unsigned char usc;
unsigned char usbuffer[10];
long no_read;
bool result;
result = input_output_byte_device.isOpen();
no_read = input_output_byte_device.read(sc);
no_read = input_output_byte_device.read(sbuffer,10);
no_read = input_output_byte_device.read(c);
no_read = input_output_byte_device.read(buffer,10);
no_read = input_output_byte_device.read(usc);
no_read = input_output_byte_device.read(usbuffer,10);
long no_written;
sc = '\n';
c = '\n';
usc = 0x01;
signed char s_write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
char write_buffer[] = { 'd', 'u', 'd', 'e', '\n' };
unsigned char us_write_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
no_written = input_output_byte_device.write(sc);
no_written = input_output_byte_device.write(c);
no_written = input_output_byte_device.write(usc);
no_written = input_output_byte_device.write(s_write_buffer,5);
no_written = input_output_byte_device.write(write_buffer,5);
no_written = input_output_byte_device.write(us_write_buffer,5);
input_output_byte_device.flush();
}
private:
// Putting instantiations here actually saves instantiation (which can cause a
// problem if there is no default constructor).
Implementation input_output_byte_device;
};
} // namespace ecl
#endif /* ECL_CONCEPTS_DEVICES_HPP_ */