Main MRPT website > C++ reference for MRPT 1.9.9
iointerface.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #include <xsens/xsthread.h>
10 #include "iointerface.h"
11 #include <errno.h>
12 #ifndef _WIN32
13 #include <unistd.h> // close
14 #include <sys/ioctl.h> // ioctl
15 #include <fcntl.h> // open, O_RDWR
16 #include <string.h> // strcpy
17 #include <sys/param.h>
18 #include <stdarg.h>
19 #else
20 #include <winbase.h>
21 #include <io.h>
22 #endif
23 
24 #ifndef _CRT_SECURE_NO_DEPRECATE
25 #define _CRT_SECURE_NO_DEPRECATE
26 #ifdef _WIN32
27 #pragma warning(disable : 4996)
28 #endif
29 #endif
30 
31 // lint -emacro(534, FSEEK, FSEEK_R)
32 // lint -emacro({534}, FSEEK, FSEEK_R)
33 #ifdef _WIN32
34 #define FSEEK(x) _fseeki64(m_handle, x, SEEK_SET)
35 #define FSEEK_R(x) _fseeki64(m_handle, x, SEEK_END)
36 #define FTELL() _ftelli64(m_handle)
37 #else
38 #define FSEEK(x) fseeko(m_handle, x, SEEK_SET)
39 #define FSEEK_R(x) fseeko(m_handle, x, SEEK_END)
40 #define FTELL() ftello(m_handle)
41 #endif
42 
43 /*! \class IoInterface
44  \brief An abstract IO interface
45  \details An %IoInterface provides a generic interface for dealing with an
46  interface device such
47  as a file, a com port or a USB port.
48  \note The class is not thread safe.
49 */
50 
51 // IOInterface functions
52 /*! \copydoc SerialInterface::open(const XsPortInfo&, uint32_t, uint32_t) */
54  const XsPortInfo&, uint32_t readBufSize, uint32_t writeBufSize)
55 {
56  (void)readBufSize;
57  (void)writeBufSize;
58  return XRV_INVALIDOPERATION;
59 }
60 /*! \copydoc SerialInterface::setTimeout(uint32_t) */
62 {
63  (void)ms;
64  return XRV_INVALIDOPERATION;
65 }
66 /*! \copydoc SerialInterface::waitForData(XsSize, XsByteArray&) */
68 {
69  (void)maxLength;
70  (void)data;
71  return XRV_INVALIDOPERATION;
72 }
73 /*! \copydoc SerialInterface::cancelIo(void) const */
74 void IoInterface::cancelIo(void) const {}
75 // IOInterfaceFile functions
76 /*! \copydoc IoInterfaceFile::appendData() */
78 {
79  (void)bdata;
80  return XRV_INVALIDOPERATION;
81 }
82 /*! \copydoc IoInterfaceFile::closeAndDelete() */
84 /*! \copydoc IoInterfaceFile::create(const XsString&) */
86 {
87  (void)filename;
88  return XRV_INVALIDOPERATION;
89 }
90 /*! \copydoc IoInterfaceFile::deleteData(XsFilePos, XsSize) */
92 {
93  (void)start;
94  (void)length;
95  return XRV_INVALIDOPERATION;
96 }
97 /*! \copydoc IoInterfaceFile::find(const XsByteArray&, XsFilePos&) */
99 {
100  (void)needleV;
101  (void)pos;
102  return XRV_INVALIDOPERATION;
103 }
104 /*! \copydoc IoInterfaceFile::getFileSize() const */
105 XsFilePos IoInterface::getFileSize(void) const { return 0; }
106 /*! \copydoc IoInterfaceFile::getName(XsString&) const */
108 {
109  (void)filename;
110  return XRV_INVALIDOPERATION;
111 }
112 /*! \copydoc IoInterfaceFile::getReadPosition() const */
113 XsFilePos IoInterface::getReadPosition(void) const { return 0; }
114 /*! \copydoc IoInterfaceFile::getWritePosition() const */
115 XsFilePos IoInterface::getWritePosition(void) const { return 0; }
116 /*! \copydoc IoInterfaceFile::insertData(XsFilePos, const XsByteArray&) */
118 {
119  (void)start;
120  (void)data;
121  return XRV_INVALIDOPERATION;
122 }
123 /*! \copydoc IoInterfaceFile::isReadOnly() const */
124 bool IoInterface::isReadOnly(void) const { return true; }
125 /*! \copydoc IoInterfaceFile::open(const XsString&, bool, bool) */
127  const XsString& filename, bool createNew, bool readOnly)
128 {
129  (void)filename;
130  (void)createNew;
131  (void)readOnly;
132  return XRV_INVALIDOPERATION;
133 }
134 /*! \copydoc IoInterfaceFile::setReadPosition(XsFilePos) */
136 {
137  (void)pos;
138  return XRV_INVALIDOPERATION;
139 }
140 /*! \copydoc IoInterfaceFile::setWritePosition(XsFilePos) */
142 {
143  (void)pos;
144  return XRV_INVALIDOPERATION;
145 }
IoInterface::getName
virtual XsResultValue getName(XsString &filename) const
Retrieve the filename that was last successfully opened.
Definition: iointerface.cpp:107
XsString
struct XsString XsString
Definition: xsstring.h:34
maxLength
GLsizei maxLength
Definition: glext.h:4932
IoInterface::setTimeout
virtual XsResultValue setTimeout(uint32_t ms)
Set the default timeout value to use in blocking operations.
Definition: iointerface.cpp:61
IoInterface::find
virtual XsResultValue find(const XsByteArray &needleV, XsFilePos &pos)
Find a string of bytes in the file.
Definition: iointerface.cpp:98
XsPortInfo
Definition: xsportinfo.h:46
XsByteArray
struct XsByteArray XsByteArray
Definition: xsbytearray.h:25
IoInterface::getWritePosition
virtual XsFilePos getWritePosition(void) const
Return the current write position.
Definition: iointerface.cpp:115
start
GLuint start
Definition: glext.h:3528
IoInterface::open
virtual XsResultValue open(const XsPortInfo &portInfo, uint32_t readBufSize=XS_DEFAULT_READ_BUFFER_SIZE, uint32_t writeBufSize=XS_DEFAULT_WRITE_BUFFER_SIZE)
Open a communication channel to the given port info.
Definition: iointerface.cpp:53
xsthread.h
iointerface.h
IoInterface::create
virtual XsResultValue create(const XsString &filename)
Create an empty file.
Definition: iointerface.cpp:85
XRV_INVALIDOPERATION
@ XRV_INVALIDOPERATION
Definition: xsens_std.h:133
length
GLuint GLsizei GLsizei * length
Definition: glext.h:4064
XsResultValue
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:27
IoInterface::insertData
virtual XsResultValue insertData(XsFilePos start, const XsByteArray &data)
Insert the given data into the file.
Definition: iointerface.cpp:117
data
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3547
IoInterface::deleteData
virtual XsResultValue deleteData(XsFilePos start, XsSize length)
Delete the given data from the file.
Definition: iointerface.cpp:91
IoInterface::cancelIo
virtual void cancelIo(void) const
Cancel any pending io requests.
Definition: iointerface.cpp:74
XsSize
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:19
IoInterface::setWritePosition
virtual XsResultValue setWritePosition(XsFilePos pos=-1)
Set the new absolute write position.
Definition: iointerface.cpp:141
IoInterface::getFileSize
virtual XsFilePos getFileSize(void) const
Return the size of the file.
Definition: iointerface.cpp:105
IoInterface::getReadPosition
virtual XsFilePos getReadPosition(void) const
Return the current read position.
Definition: iointerface.cpp:113
void
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
IoInterface::isReadOnly
virtual bool isReadOnly(void) const
Return whether the file is readonly or not.
Definition: iointerface.cpp:124
IoInterface::waitForData
virtual XsResultValue waitForData(XsSize maxLength, XsByteArray &data)
Wait for data to arrive or a timeout to occur.
Definition: iointerface.cpp:67
IoInterface::setReadPosition
virtual XsResultValue setReadPosition(XsFilePos pos)
Set the new absolute read position.
Definition: iointerface.cpp:135
XsFilePos
__int64 XsFilePos
The type that is used for positioning inside a file.
Definition: xsfilepos.h:34
IoInterface::closeAndDelete
virtual XsResultValue closeAndDelete(void)
Close the file and delete it.
Definition: iointerface.cpp:83
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47
IoInterface::appendData
virtual XsResultValue appendData(const XsByteArray &bdata)
Write data to the end of the file.
Definition: iointerface.cpp:77



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST