xsens::Cmt1f Class Reference

The low-level file communication class. More...

#include <Robots/SeaBeeIII/IMUDataServer/cmt1.h>

List of all members.

Public Member Functions

 Cmt1f ()
 Default constructor, initializes all members to their default values.
 ~Cmt1f ()
 Destructor.
XsensResultValue appendData (const uint32_t length, const void *data)
 Write data to the end of the file.
XsensResultValue close (void)
 Close the file.
XsensResultValue closeAndDelete (void)
 Close the file and delete it.
XsensResultValue create (const char *filename)
 Open an empty file.
XsensResultValue create (const wchar_t *filename)
 Open an empty file using a unicode path + filename.
XsensResultValue deleteData (const CmtFilePos start, const uint32_t length)
 Delete the given data from the file.
XsensResultValue find (const void *needle, const uint32_t needleLength, CmtFilePos &pos)
 Find a string of bytes in the file.
XsensResultValue flushData (void)
 Flush all data to be written. This function writes any remaining data immediately and does not return until this is done.
CmtFilePos getFileSize (void) const
 Return the size of the file.
XsensResultValue getLastResult (void) const
 Return the result code of the last operation.
XsensResultValue getName (char *filename) const
 Retrieve the filename that was last successfully opened.
XsensResultValue getName (wchar_t *filename) const
 Retrieve the filename that was last successfully opened in unicode.
CmtFilePos getReadPos (void) const
 Return the current read position.
CmtFilePos getWritePos (void) const
 Return the current write position.
XsensResultValue insertData (const CmtFilePos start, const uint32_t length, const void *data)
 Insert the given data into the file.
bool isOpen (void) const
 Return whether the file is open or not.
bool isReadOnly (void) const
 Return whether the file is readonly or not.
XsensResultValue open (const char *filename, const bool create, const bool readOnly)
 Open a file.
XsensResultValue open (const wchar_t *filename, const bool create, const bool readOnly)
 Open a file using a unicode filename.
XsensResultValue readData (const uint32_t maxLength, void *data, uint32_t *length)
 Read data from the file and put it into the data buffer.
XsensResultValue readData (const uint32_t maxLength, const char terminator, void *data, uint32_t *length)
 Read data from the file and put it into the data buffer.
XsensResultValue setReadPos (const CmtFilePos pos)
 Set the new absolute read position.
XsensResultValue setWritePos (const CmtFilePos pos=-1)
 Set the new absolute write position.
XsensResultValue writeData (const uint32_t length, const void *data)
 Write data to the file.

Protected Member Functions

void gotoRead (void)
 Change from writing to reading mode.
void gotoWrite (void)
 Change from reading to writing mode.

Protected Attributes

FILE * m_handle
 The file handle.
CmtFilePos m_fileSize
 Contains the size of the file.
CmtFilePos m_readPos
 The last read position in the file.
CmtFilePos m_writePos
 The last write position in the file.
XsensResultValue m_lastResult
 The last result of an operation.
char m_filename [CMT_MAX_FILENAME_LENGTH]
 Contains the name of the file that was last successfully opened.
wchar_t m_filename_w [CMT_MAX_FILENAME_LENGTH]
 Contains the name of the file that was last successfully opened using unicode.
bool m_isOpen
 Indicates if the file is open or not.
bool m_unicode
 Indicates if we're using the unicode filename or the regular filename.
bool m_reading
 Indicates whether the last operation was a read or write operation.
bool m_readOnly
 Indicates if the file was opened in read-only mode.

Detailed Description

The low-level file communication class.

Definition at line 216 of file cmt1.h.


Constructor & Destructor Documentation

xsens::Cmt1f::Cmt1f (  ) 

Default constructor, initializes all members to their default values.

Definition at line 634 of file cmt1.cpp.

References m_filename, m_fileSize, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, and m_writePos.

xsens::Cmt1f::~Cmt1f (  ) 

Destructor.

Definition at line 649 of file cmt1.cpp.

References close().


Member Function Documentation

XsensResultValue xsens::Cmt1f::appendData ( const uint32_t  length,
const void *  data 
)

Write data to the end of the file.

The function writes the given data to the file at the end. The current write position is also moved to the end of the file.

Definition at line 656 of file cmt1.cpp.

References m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, and m_writePos.

Referenced by xsens::Cmt2f::writeMessage().

XsensResultValue xsens::Cmt1f::close ( void   ) 

Close the file.

Definition at line 677 of file cmt1.cpp.

References m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, and m_writePos.

Referenced by xsens::Cmt2f::close(), xsens::Cmt2f::create(), and ~Cmt1f().

XsensResultValue xsens::Cmt1f::closeAndDelete ( void   ) 

Close the file and delete it.

Definition at line 702 of file cmt1.cpp.

References m_filename, m_filename_w, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, and m_writePos.

Referenced by xsens::Cmt2f::closeAndDelete().

XsensResultValue xsens::Cmt1f::create ( const wchar_t *  filename  ) 

Open an empty file using a unicode path + filename.

Definition at line 797 of file cmt1.cpp.

References create(), m_filename, m_filename_w, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, and m_writePos.

XsensResultValue xsens::Cmt1f::create ( const char *  filename  ) 

Open an empty file.

Test:
does this work for non-existing files? Or do we need a check and create?

Definition at line 755 of file cmt1.cpp.

References m_filename, m_filename_w, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, and m_writePos.

Referenced by xsens::Cmt2f::create(), and create().

XsensResultValue xsens::Cmt1f::deleteData ( const CmtFilePos  start,
const uint32_t  length 
)

Delete the given data from the file.

The function erases the given data from the file at the given write position. This operation may take a while to complete, but is faster than insertData.

The write position is not changed and the read position is checked for validity.

Definition at line 835 of file cmt1.cpp.

References gotoWrite(), m_fileSize, m_handle, m_isOpen, m_lastResult, m_readOnly, and m_writePos.

Referenced by xsens::Cmt2f::create().

XsensResultValue xsens::Cmt1f::find ( const void *  needle,
const uint32_t  needleLength,
CmtFilePos &  pos 
)

Find a string of bytes in the file.

The function searches from the current read position until the given needle is found. If the needle is not found, XsensResultValue::NOT_FOUND is returned. The function will update the seek position to the first character of the found needle.

Parameters:
needle The byte string to find.
needleLength The length of the byte string.
pos Out: The position where the needle was found. This will point to the first character of the found needle.

Definition at line 911 of file cmt1.cpp.

References gotoRead(), m_handle, m_isOpen, m_lastResult, and m_readPos.

Referenced by xsens::Cmt2f::readMessage().

XsensResultValue xsens::Cmt1f::flushData ( void   ) 

Flush all data to be written. This function writes any remaining data immediately and does not return until this is done.

Definition at line 970 of file cmt1.cpp.

References m_handle, and m_lastResult.

CmtFilePos xsens::Cmt1f::getFileSize ( void   )  const [inline]

Return the size of the file.

Definition at line 296 of file cmt1.h.

References m_fileSize.

Referenced by xsens::Cmt2f::getFileSize().

XsensResultValue xsens::Cmt1f::getLastResult ( void   )  const [inline]

Return the result code of the last operation.

Definition at line 298 of file cmt1.h.

References m_lastResult.

XsensResultValue xsens::Cmt1f::getName ( wchar_t *  filename  )  const

Retrieve the filename that was last successfully opened in unicode.

Parameters:
filename A buffer for storing the filename. The buffer should be able to hold the filename. A safe size is to make it at least 256 wide characters.

Definition at line 987 of file cmt1.cpp.

References m_filename, m_filename_w, and m_lastResult.

XsensResultValue xsens::Cmt1f::getName ( char *  filename  )  const

Retrieve the filename that was last successfully opened.

Parameters:
filename A buffer for storing the filename. The buffer should be able to hold the filename. A safe size is to make it at least 256 bytes.

Definition at line 979 of file cmt1.cpp.

References m_filename, and m_lastResult.

Referenced by xsens::Cmt2f::getName().

CmtFilePos xsens::Cmt1f::getReadPos ( void   )  const [inline]

Return the current read position.

Definition at line 312 of file cmt1.h.

References m_readPos.

Referenced by xsens::Cmt2f::getReadPosition().

CmtFilePos xsens::Cmt1f::getWritePos ( void   )  const [inline]

Return the current write position.

Definition at line 314 of file cmt1.h.

References m_writePos.

void xsens::Cmt1f::gotoRead ( void   )  [protected]

Change from writing to reading mode.

Definition at line 999 of file cmt1.cpp.

References m_reading, and m_readPos.

Referenced by find(), and readData().

void xsens::Cmt1f::gotoWrite ( void   )  [protected]

Change from reading to writing mode.

Definition at line 1010 of file cmt1.cpp.

References m_reading, and m_writePos.

Referenced by deleteData(), insertData(), and writeData().

XsensResultValue xsens::Cmt1f::insertData ( const CmtFilePos  start,
const uint32_t  length,
const void *  data 
)

Insert the given data into the file.

The function writes the given data to the file at the current write position. This operation may take a while to complete.

The write position is placed at the end of the inserted data.

Definition at line 1021 of file cmt1.cpp.

References gotoWrite(), m_fileSize, m_handle, m_isOpen, m_lastResult, m_readOnly, and m_writePos.

bool xsens::Cmt1f::isOpen ( void   )  const [inline]

Return whether the file is open or not.

Definition at line 325 of file cmt1.h.

References m_isOpen.

Referenced by xsens::Cmt2f::close(), xsens::Cmt2f::closeAndDelete(), xsens::Cmt2f::create(), xsens::Cmt2f::isOpen(), and xsens::Cmt2f::open().

bool xsens::Cmt1f::isReadOnly ( void   )  const [inline]

Return whether the file is readonly or not.

Definition at line 327 of file cmt1.h.

References m_isOpen, and m_readOnly.

XsensResultValue xsens::Cmt1f::open ( const wchar_t *  filename,
const bool  create,
const bool  readOnly 
)

Open a file using a unicode filename.

Definition at line 1139 of file cmt1.cpp.

References m_filename, m_filename_w, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, m_writePos, and open().

XsensResultValue xsens::Cmt1f::open ( const char *  filename,
const bool  create,
const bool  readOnly 
)

Open a file.

Test:
does this work for non-existing files? Or do we need a check and create?

Definition at line 1086 of file cmt1.cpp.

References m_filename, m_filename_w, m_fileSize, m_handle, m_isOpen, m_lastResult, m_reading, m_readOnly, m_readPos, m_unicode, and m_writePos.

Referenced by xsens::Cmt2f::open(), and open().

XsensResultValue xsens::Cmt1f::readData ( const uint32_t  maxLength,
const char  terminator,
void *  data,
uint32_t *  length 
)

Read data from the file and put it into the data buffer.

This function reads upp to the number of bytes as requested from the file. The function will also stop if the given terminator character is encountered. The terminator is included in the output buffer.

Parameters:
maxLength The amount of data that will be read.
data Pointer to a buffer that will store the read data.
terminator A character that will end the read operation if encountered.
length The actual number of bytes read, including the terminator character, if encountered.

Definition at line 1215 of file cmt1.cpp.

References gotoRead(), m_handle, m_isOpen, m_lastResult, and m_readPos.

XsensResultValue xsens::Cmt1f::readData ( const uint32_t  maxLength,
void *  data,
uint32_t *  length 
)

Read data from the file and put it into the data buffer.

This function reads exactly the number of bytes as requested from the file.

Parameters:
maxLength The amount of data that will be read.
data Pointer to a buffer that will store the read data.
length pointer to a variable that will store the number of bytes that were actually read. The parameter may be NULL.

Definition at line 1191 of file cmt1.cpp.

References gotoRead(), m_handle, m_isOpen, m_lastResult, and m_readPos.

Referenced by xsens::Cmt3::openLogFile(), and xsens::Cmt2f::readMessage().

XsensResultValue xsens::Cmt1f::setReadPos ( const CmtFilePos  pos  ) 

Set the new absolute read position.

The read position is checked against the filesize before committing.

Definition at line 1246 of file cmt1.cpp.

References m_isOpen, m_lastResult, m_reading, and m_readPos.

Referenced by xsens::Cmt3::openLogFile(), xsens::Cmt2f::readMessage(), and xsens::Cmt2f::setReadPosition().

XsensResultValue xsens::Cmt1f::setWritePos ( const CmtFilePos  pos = -1  ) 

Set the new absolute write position.

The write position is checked against the filesize before committing.

Definition at line 1263 of file cmt1.cpp.

References m_isOpen, m_lastResult, m_reading, m_readOnly, and m_writePos.

XsensResultValue xsens::Cmt1f::writeData ( const uint32_t  length,
const void *  data 
)

Write data to the file.

The function writes the given data to the file at the current write position.

Definition at line 1292 of file cmt1.cpp.

References gotoWrite(), m_fileSize, m_handle, m_isOpen, m_lastResult, m_readOnly, and m_writePos.

Referenced by xsens::Cmt2f::create().


Member Data Documentation

char xsens::Cmt1f::m_filename[CMT_MAX_FILENAME_LENGTH] [protected]

Contains the name of the file that was last successfully opened.

Definition at line 233 of file cmt1.h.

Referenced by closeAndDelete(), Cmt1f(), create(), getName(), and open().

wchar_t xsens::Cmt1f::m_filename_w[CMT_MAX_FILENAME_LENGTH] [protected]

Contains the name of the file that was last successfully opened using unicode.

Definition at line 235 of file cmt1.h.

Referenced by closeAndDelete(), create(), getName(), and open().

CmtFilePos xsens::Cmt1f::m_fileSize [protected]

Contains the size of the file.

Definition at line 225 of file cmt1.h.

Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), deleteData(), getFileSize(), insertData(), open(), and writeData().

FILE* xsens::Cmt1f::m_handle [protected]

The file handle.

Definition at line 223 of file cmt1.h.

Referenced by appendData(), close(), closeAndDelete(), create(), deleteData(), find(), flushData(), insertData(), open(), readData(), and writeData().

bool xsens::Cmt1f::m_isOpen [protected]

Indicates if the file is open or not.

Definition at line 237 of file cmt1.h.

Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), deleteData(), find(), insertData(), isOpen(), isReadOnly(), open(), readData(), setReadPos(), setWritePos(), and writeData().

XsensResultValue xsens::Cmt1f::m_lastResult [mutable, protected]
bool xsens::Cmt1f::m_reading [protected]

Indicates whether the last operation was a read or write operation.

This value is used to check whether or not a seek is required to perform a requested read or write operation.

Definition at line 245 of file cmt1.h.

Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), gotoRead(), gotoWrite(), open(), setReadPos(), and setWritePos().

bool xsens::Cmt1f::m_readOnly [protected]

Indicates if the file was opened in read-only mode.

Definition at line 247 of file cmt1.h.

Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), deleteData(), insertData(), isReadOnly(), open(), setWritePos(), and writeData().

CmtFilePos xsens::Cmt1f::m_readPos [protected]

The last read position in the file.

Definition at line 227 of file cmt1.h.

Referenced by close(), closeAndDelete(), Cmt1f(), create(), find(), getReadPos(), gotoRead(), open(), readData(), and setReadPos().

bool xsens::Cmt1f::m_unicode [protected]

Indicates if we're using the unicode filename or the regular filename.

Definition at line 239 of file cmt1.h.

Referenced by closeAndDelete(), Cmt1f(), create(), and open().

CmtFilePos xsens::Cmt1f::m_writePos [protected]

The last write position in the file.

Definition at line 229 of file cmt1.h.

Referenced by appendData(), close(), closeAndDelete(), Cmt1f(), create(), deleteData(), getWritePos(), gotoWrite(), insertData(), open(), setWritePos(), and writeData().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:31:47 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3