Add a templated helper function for read and write to simplify the code

next
Erik Hofman 4 years ago
parent 4b530e9376
commit 0530bc2cd7

@ -78,9 +78,19 @@ public:
// read data from the topic.
int read(char *buf, int length);
template<typename T>
bool read(T& sample) {
return (read((char*)&sample, sizeof(T)) == sizeof(T)) ? true : false;
}
// write data to the topic.
int write(const char *buf, const int length);
template<typename T>
bool write(const T& sample) {
return (write((char*)&sample, sizeof(T)) == sizeof(T)) ? true : false;
}
// close the participant.
bool close();

Loading…
Cancel
Save