iointerfacefile.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #ifndef IOINTERFACEFILE_H
66 #define IOINTERFACEFILE_H
67 
68 #include <xstypes/xsplatform.h>
69 #include "iointerface.h"
70 #include <xstypes/xsresultvalue.h>
71 
75 {
76 protected:
94  bool m_reading;
96  bool m_readOnly;
97 
98  void gotoRead();
99  void gotoWrite();
100 public:
101  IoInterfaceFile();
103 
104  // Function overrides
105  XsResultValue close() override;
107  XsResultValue flushData() override;
108  bool isOpen() const override;
109  XsResultValue getLastResult() const override;
110  XsResultValue writeData(const XsByteArray& data, XsFilePos* written = nullptr) override;
111  XsResultValue readData(XsFilePos maxLength, XsByteArray& data) override;
113  XsResultValue readTerminatedData(XsFilePos maxLength, unsigned char terminator, XsByteArray& bdata);
114 
115  // Other functions
116  XsResultValue appendData(const XsByteArray& bdata);
118  XsResultValue create(const XsString& filename);
120  XsResultValue find(const XsByteArray& data, XsFilePos& pos);
121  XsFilePos getFileSize() const;
122  XsTimeStamp getFileDate() const;
123  XsResultValue getName(XsString& filename) const;
124  XsString getFileName() const;
125  XsFilePos getReadPosition() const;
126  XsFilePos getWritePosition() const;
127  XsResultValue insertData(XsFilePos start, const XsByteArray& data);
128  bool isReadOnly() const;
129  XsResultValue open(const XsString& filename, bool createNew, bool readOnly);
134 
136  static const XsFilePos m_fileBlockSize = 4096;
137 
139 };
140 
141 #endif
IoInterfaceFile::flushFileBuffers
XsResultValue flushFileBuffers()
Flushes the buffers of a specified file and causes all buffered data to be written to a file.
Definition: iointerfacefile.cpp:855
IoInterfaceFile::setWritePosition
XsResultValue setWritePosition(XsFilePos pos=-1)
Set the new absolute write position.
Definition: iointerfacefile.cpp:721
IoInterfaceFile::gotoWrite
void gotoWrite()
Change from reading to writing mode.
Definition: iointerfacefile.cpp:437
IoInterfaceFile::open
XsResultValue open(const XsString &filename, bool createNew, bool readOnly)
Open a file.
Definition: iointerfacefile.cpp:535
XsByteArray
A list of uint8_t values.
IoInterfaceFile::getFileName
XsString getFileName() const
Return the filename that was last successfully opened.
Definition: iointerfacefile.cpp:420
IoInterfaceFile::isReadOnly
bool isReadOnly() const
Return whether the file is read-only or not.
Definition: iointerfacefile.cpp:824
IoInterfaceFile::getName
XsResultValue getName(XsString &filename) const
Retrieve the filename that was last successfully opened.
Definition: iointerfacefile.cpp:412
IoInterfaceFile::flushData
XsResultValue flushData() override
Flush all data in the buffers to and from the device.
Definition: iointerfacefile.cpp:400
IoInterfaceFile::m_lastResult
XsResultValue m_lastResult
The last result of an operation.
Definition: iointerfacefile.h:86
IoInterfaceFile::appendData
XsResultValue appendData(const XsByteArray &bdata)
Write data to the end of the file.
Definition: iointerfacefile.cpp:123
IoInterfaceFile::m_writePos
XsFilePos m_writePos
The last write position in the file.
Definition: iointerfacefile.h:84
iointerface.h
IoInterfaceFile::getFileDate
XsTimeStamp getFileDate() const
Return the creation date of the file.
Definition: iointerfacefile.cpp:383
xsplatform.h
IoInterfaceFile::insertData
XsResultValue insertData(XsFilePos start, const XsByteArray &data)
Insert the given data into the file.
Definition: iointerfacefile.cpp:456
IoInterfaceFile
The low-level file communication class.
Definition: iointerfacefile.h:74
IoInterfaceFile::deleteData
XsResultValue deleteData(XsFilePos start, XsFilePos length)
Delete the given data from the file.
Definition: iointerfacefile.cpp:253
IoInterfaceFile::gotoRead
void gotoRead()
Change from writing to reading mode.
Definition: iointerfacefile.cpp:426
IoInterfaceFile::getReadPosition
XsFilePos getReadPosition() const
Return the current read position.
Definition: iointerfacefile.cpp:792
IoInterfaceFile::m_handle
XsFile * m_handle
The file handle, also indicates if the file is open or not.
Definition: iointerfacefile.h:78
IoInterfaceFile::m_readPos
XsFilePos m_readPos
The last read position in the file.
Definition: iointerfacefile.h:82
IoInterfaceFile::setReadPosition
XsResultValue setReadPosition(XsFilePos pos)
Set the new absolute read position.
Definition: iointerfacefile.cpp:701
XsResultValue
XsResultValue
Xsens result values.
Definition: xsresultvalue.h:82
IoInterfaceFile::m_fileBlockSize
static const XsFilePos m_fileBlockSize
The default file block size.
Definition: iointerfacefile.h:136
IoInterfaceFile::getFileSize
XsFilePos getFileSize() const
Return the size of the file.
Definition: iointerfacefile.cpp:375
IoInterfaceFile::readDataBlocks
XsResultValue readDataBlocks(XsFilePos blockCount, XsByteArray &data)
This function will read blocks of data aligned to m_fileBlockSize.
Definition: iointerfacefile.cpp:634
IoInterfaceFile::~IoInterfaceFile
~IoInterfaceFile()
Definition: iointerfacefile.cpp:106
IoInterfaceFile::XSENS_DISABLE_COPY
XSENS_DISABLE_COPY(IoInterfaceFile)
IoInterfaceFile::reserve
XsResultValue reserve(XsFilePos minSize)
Make sure the file is at least minSize bytes big.
Definition: iointerfacefile.cpp:834
IoInterfaceFile::closeFile
XsResultValue closeFile()
Close the file.
Definition: iointerfacefile.cpp:156
IoInterfaceFile::getWritePosition
XsFilePos getWritePosition() const
Return the current write position.
Definition: iointerfacefile.cpp:800
IoInterfaceFile::m_readOnly
bool m_readOnly
Indicates if the file was opened in read-only mode.
Definition: iointerfacefile.h:96
IoInterfaceFile::m_filename
XsString m_filename
Contains the name of the file that was last successfully opened.
Definition: iointerfacefile.h:88
IoInterfaceFile::find
XsResultValue find(const XsByteArray &data, XsFilePos &pos)
Find a string of bytes in the file.
Definition: iointerfacefile.cpp:312
IoInterfaceFile::IoInterfaceFile
IoInterfaceFile()
Definition: iointerfacefile.cpp:93
IoInterfaceFile::readTerminatedData
XsResultValue readTerminatedData(XsFilePos maxLength, unsigned char terminator, XsByteArray &bdata)
Read data from the file and put it into the data buffer.
Definition: iointerfacefile.cpp:656
IoInterfaceFile::getLastResult
XsResultValue getLastResult() const override
Return the result code of the last operation.
Definition: iointerfacefile.cpp:808
XsFile
Encapsulates a file, providing a platform independent interface.
Definition: xsfile.h:131
IoInterfaceFile::close
XsResultValue close() override
Close the file, overrides IoInterface::close().
Definition: iointerfacefile.cpp:148
IoInterface
An abstract IO interface.
Definition: iointerface.h:86
IoInterfaceFile::writeData
XsResultValue writeData(const XsByteArray &data, XsFilePos *written=nullptr) override
Write the data contained in data to the device.
Definition: iointerfacefile.cpp:751
IoInterfaceFile::m_fileSize
XsFilePos m_fileSize
Contains the size of the file.
Definition: iointerfacefile.h:80
IoInterfaceFile::isOpen
bool isOpen() const override
Return whether the file is open or not.
Definition: iointerfacefile.cpp:816
xsresultvalue.h
IoInterfaceFile::m_reading
bool m_reading
Indicates whether the last operation was a read or write operation.
Definition: iointerfacefile.h:94
IoInterfaceFile::readData
XsResultValue readData(XsFilePos maxLength, XsByteArray &data) override
Read at most maxLength bytes from the device into data.
Definition: iointerfacefile.cpp:598
XsFilePos
int64_t XsFilePos
The type that is used for positioning inside a file.
Definition: xsfilepos.h:102
XsString
A 0-terminated managed string of characters.
IoInterfaceFile::create
XsResultValue create(const XsString &filename)
Create an empty file.
Definition: iointerfacefile.cpp:210
XsTimeStamp
This class contains method to set, retrieve and compare timestamps.
Definition: xstimestamp.h:115
IoInterfaceFile::closeAndDelete
XsResultValue closeAndDelete()
Close the file and delete it.
Definition: iointerfacefile.cpp:179


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20