31 #ifndef __STRUCTPORT_H 32 #define __STRUCTPORT_H 41 template <
class CDataStruct>
77 CDataStruct *pDataStruct =
static_cast<CDataStruct*
>(
this);
78 if( InternalAddress < 0 || Length < 0 || InternalAddress + Length >
sizeof(CDataStruct) )
80 memcpy( pBuffer, (uint8_t*)pDataStruct + InternalAddress, (
size_t)Length );
89 CDataStruct *pDataStruct =
static_cast<CDataStruct*
>(
this);
90 if( InternalAddress < 0 || Length < 0 || InternalAddress + Length >
sizeof(CDataStruct) )
91 throw RUNTIME_EXCEPTION(
"CTestPortStruct::Write - Invalid address and/or length");
92 memcpy( (uint8_t*)pDataStruct + InternalAddress, pBuffer, (
size_t)Length );
102 memset( static_cast<CDataStruct*>(
this), FillValue,
sizeof(CDataStruct) );
140 #endif // __STRUCTPORT_H CTestPortStruct(int64_t BaseAddress=0)
int64_t GetNumReads()
Returns the number of reads since lastReset Statistics.
int64_t m_NumWrites
Number of writes since last reset.
void ResetStatistics()
Resets the read/write statistics.
void MemSet(const char FillValue)
Implements a register spaces based on a C++ struct.
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
virtual void Read(void *pBuffer, int64_t Address, int64_t Length)
Reads a chunk of bytes from the port.
virtual void Write(const void *pBuffer, int64_t Address, int64_t Length)
Writes a chunk of bytes to the port.
interface GENAPI_DECL_ABSTRACT int64_t Address
int64_t m_BaseAddress
the base address used for the struct
interface GENAPI_DECL_ABSTRACT int64_t int64_t Length
virtual GENAPI_NAMESPACE::EAccessMode GetAccessMode() const
Get the access mode of the node.
enum GENAPI_NAMESPACE::_EAccessMode EAccessMode
access mode of a node
virtual GENAPI_NAMESPACE::EInterfaceType GetPrincipalInterfaceType() const
Get the type of the main interface of a node.
Standard implementation for a port !
int64_t m_NumReads
Number of reads since last reset.
int64_t GetNumWrites()
Returns the number of writes since lastReset Statistics.
Part of the generic device API.
enum GENAPI_NAMESPACE::_EInterfaceType EInterfaceType
typedef for interface type