FreeNOS
IOBuffer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIB_LIBFS_IOBUFFER_H
19 #define __LIB_LIBFS_IOBUFFER_H
20 
21 #include <Types.h>
22 #include <Macros.h>
23 #include <Memory.h>
24 #include "FileSystemMessage.h"
25 
37 class IOBuffer
38 {
39  public:
40 
44  IOBuffer();
45 
51  IOBuffer(const FileSystemMessage *msg);
52 
56  virtual ~IOBuffer();
57 
63  Size getCount() const;
64 
70  void addCount(const Size bytes);
71 
80  void setMessage(const FileSystemMessage *msg);
81 
87  const FileSystemMessage * getMessage() const;
88 
94  u8 * getBuffer();
95 
105  FileSystem::Result read(void *buffer,
106  const Size size,
107  const Size offset = ZERO);
108 
118  FileSystem::Result write(const void *buffer,
119  const Size size,
120  const Size offset = ZERO);
121 
128 
137  FileSystem::Result bufferedWrite(const void *buffer,
138  const Size size);
139 
146 
154  u8 operator[] (Size index) const;
155 
156  private:
157 
169 
172 
175 
178 
181 
184 };
185 
191 #endif /* __LIB_LIBFS_IOBUFFER_H */
IOBuffer::flushWrite
FileSystem::Result flushWrite()
Flush write buffers.
Definition: IOBuffer.cpp:204
Memory::Range
Memory range.
Definition: Memory.h:55
Macros.h
Types.h
IOBuffer::m_directMapRange
Memory::Range m_directMapRange
Contains the memory address range of the direct memory mapping.
Definition: IOBuffer.h:174
IOBuffer::getCount
Size getCount() const
Get byte count.
Definition: IOBuffer.cpp:109
IOBuffer::addCount
void addCount(const Size bytes)
Increment byte counter.
Definition: IOBuffer.cpp:114
IOBuffer::getMessage
const FileSystemMessage * getMessage() const
Get filesystem message.
Definition: IOBuffer.cpp:120
IOBuffer::bufferedWrite
FileSystem::Result bufferedWrite(const void *buffer, const Size size)
Buffered write bytes to the I/O buffer.
Definition: IOBuffer.cpp:146
IOBuffer::m_directMapped
bool m_directMapped
True if using directly memory-mapped memory (unbuffered)
Definition: IOBuffer.h:171
IOBuffer::~IOBuffer
virtual ~IOBuffer()
Destructor.
Definition: IOBuffer.cpp:43
FileSystemMessage
FileSystem IPC message.
Definition: FileSystemMessage.h:37
IOBuffer::IOBuffer
IOBuffer()
Default empty constructor.
Definition: IOBuffer.cpp:24
IOBuffer::setMessage
void setMessage(const FileSystemMessage *msg)
Set filesystem message.
Definition: IOBuffer.cpp:63
IOBuffer::m_message
const FileSystemMessage * m_message
Current request being processed.
Definition: IOBuffer.h:168
IOBuffer::m_buffer
u8 * m_buffer
Buffer for storing temporary data.
Definition: IOBuffer.h:177
IOBuffer
Abstract Input/Output buffer.
Definition: IOBuffer.h:37
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
Memory.h
IOBuffer::getBuffer
u8 * getBuffer()
Get raw buffer.
Definition: IOBuffer.cpp:125
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
u8
unsigned char u8
Unsigned 8-bit number.
Definition: Types.h:59
IOBuffer::m_count
Size m_count
Bytes written to the buffer.
Definition: IOBuffer.h:183
IOBuffer::m_size
Size m_size
Buffer size.
Definition: IOBuffer.h:180
IOBuffer::operator[]
u8 operator[](Size index) const
Byte index operator.
Definition: IOBuffer.cpp:217
IOBuffer::bufferedRead
FileSystem::Result bufferedRead()
Buffered read bytes from the I/O buffer.
Definition: IOBuffer.cpp:130
IOBuffer::read
FileSystem::Result read(void *buffer, const Size size, const Size offset=ZERO)
Read bytes from the I/O buffer.
Definition: IOBuffer.cpp:156
IOBuffer::write
FileSystem::Result write(const void *buffer, const Size size, const Size offset=ZERO)
Write bytes to the I/O buffer.
Definition: IOBuffer.cpp:180
ZERO
#define ZERO
Zero value.
Definition: Macros.h:43
FileSystemMessage.h