MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/driver/IDataLink.hh
2024-06-07 11:12:56 +03:00

48 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* IDataLink.h
*
* Created on: 13 сент. 2018 г.
* Author: titov
*/
#ifndef SOURCE_DRIVER_IDATALINK_H_
#define SOURCE_DRIVER_IDATALINK_H_
#include <cstddef>
namespace driver {
//! Интерфейс передачи данных.
class ITxLink {
public:
virtual bool send( const char * data, std::size_t size ) = 0;
template<typename T>
bool operator <<( const T & );
virtual ~ITxLink() {}
};
//! Интерфейс приемах данных.
class IRxLink {
public:
virtual bool receive( char * data, std::size_t size ) = 0;
template<typename T>
bool operator >>( T & );
virtual ~IRxLink() {}
};
class IDataLink : public ITxLink, public IRxLink {};
}
template<typename T>
inline bool driver::ITxLink::operator <<( const T & data ) {
return send( reinterpret_cast<const char *>(&data), sizeof(data) );
}
template<typename T>
inline bool driver::IRxLink::operator >>( T & data ) {
return receive( reinterpret_cast<char *>(&data), sizeof(data) );
}
#endif /* SOURCE_DRIVER_IDATALINK_H_ */