# VectorNav C++ Library: include/vn/memoryport.h Source File

memoryport.h
Go to the documentation of this file.
#ifndef _MEMORYPORT_H_
#define _MEMORYPORT_H_
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4996)
#endif
#include <string>
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#include "int.h"
#include "port.h"
#include "nocopy.h"
namespace vn {
namespace util {
class MemoryPort : public xplat::IPort, private NoCopy
{
typedef void(*DataWrittenHandler)(void* userData, const char* rawData, size_t length);
// Constructors ///////////////////////////////////////////////////////////
public:
MemoryPort();
~MemoryPort();
// Public Methods /////////////////////////////////////////////////////////
public:
virtual void open();
virtual void close();
virtual bool isOpen();
virtual void write(const char data[], size_t length);
virtual void read(char dataBuffer[], size_t numOfBytesToRead, size_t &numOfBytesActuallyRead);
virtual void registerDataReceivedHandler(void* userData, DataReceivedHandler handler);
virtual void unregisterDataReceivedHandler();
void registerDataWrittenHandler(void* userData, DataWrittenHandler handler);
void unregisterDataWrittenHandler();
void SendDataBackDoor(const uint8_t data[], size_t length);
void SendDataBackDoor(const char data[], size_t length);
void SendDataBackDoor(const std::string data);
// Private Members ////////////////////////////////////////////////////////
private:
// Contains internal data, mainly stuff that is required for support.
struct Impl;
Impl *_pi;
};
}
}
#endif
vn::xplat::IPort::DataReceivedHandler
void(* DataReceivedHandler)(void *userData)
Callback handler signature that can receive notification when new data has been received on the port...
Definition: port.h:24
vn::util::MemoryPort::unregisterDataReceivedHandler
virtual void unregisterDataReceivedHandler()
Unregisters the registered callback method.
int.h
vn::util::MemoryPort::registerDataWrittenHandler
void registerDataWrittenHandler(void *userData, DataWrittenHandler handler)
Registers a callback method for notification when new data is written.
nocopy.h
vn::util::MemoryPort::MemoryPort
MemoryPort()
Creates a new MemoryPort.
vn::xplat::IPort
Interface for a simple port.
Definition: port.h:12
vn::util::MemoryPort::write
virtual void write(const char data[], size_t length)
Writes out data to the simple port.
vn::util::MemoryPort
Useful test class for taking place where vn::common::ISimplePort may be used.
Definition: memoryport.h:29
vn::util::MemoryPort::SendDataBackDoor
void SendDataBackDoor(const uint8_t data[], size_t length)
Sends data to the MemoryPort which can then be read by read.
vn::util::MemoryPort::close
virtual void close()
Closes the simple port.
vn::util::MemoryPort::read
virtual void read(char dataBuffer[], size_t numOfBytesToRead, size_t &numOfBytesActuallyRead)
Allows reading data from the simple port.
vn::util::NoCopy
Identifies a derived class as being unable to be copied and prevents copy attempts.
Definition: nocopy.h:21
vn
Definition: attitude.h:8
vn::util::MemoryPort::registerDataReceivedHandler
virtual void registerDataReceivedHandler(void *userData, DataReceivedHandler handler)
Registers a callback method for notification when new data is received on the port.
vn::util::MemoryPort::open
virtual void open()
Opens the simple port.
vn::util::MemoryPort::unregisterDataWrittenHandler
void unregisterDataWrittenHandler()
Unregisters the registered callback method.
vn::util::MemoryPort::isOpen
virtual bool isOpen()
Indicates if the simple port is open.