Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::ROFileMemorySpace Class Reference

Memory space implementation that exports the contents of a file as a memory space. More...

#include <MemoryConfig.hxx>

Inheritance diagram for openlcb::ROFileMemorySpace:
openlcb::FileMemorySpace openlcb::MemorySpace Destructable

Public Member Functions

 ROFileMemorySpace (int fd, address_t len=AUTO_LEN)
 Creates a memory space based on an fd.
 
 ROFileMemorySpace (const char *name, address_t len=AUTO_LEN)
 Creates a memory space based on a file name.
 
bool read_only () OVERRIDE
 
- Public Member Functions inherited from openlcb::FileMemorySpace
 FileMemorySpace (int fd, address_t len=AUTO_LEN)
 Creates a memory space based on an fd.
 
 FileMemorySpace (const char *name, address_t len=AUTO_LEN)
 Creates a memory space based on a file name.
 
address_t max_address () OVERRIDE
 
size_t write (address_t destination, const uint8_t *data, size_t len, errorcode_t *error, Notifiable *again) OVERRIDE
 
size_t read (address_t source, uint8_t *dst, size_t len, errorcode_t *error, Notifiable *again) OVERRIDE
 
- Public Member Functions inherited from openlcb::MemorySpace
virtual bool set_node (Node *node)
 Specifies which node the next operation pertains.
 
virtual address_t min_address ()
 
virtual errorcode_t freeze ()
 Handles space freeze command.
 
virtual errorcode_t unfreeze ()
 Handles space unfreeze command.
 

Additional Inherited Members

- Public Types inherited from openlcb::MemorySpace
typedef uint32_t address_t
 
typedef uint16_t errorcode_t
 
- Static Public Attributes inherited from openlcb::FileMemorySpace
static const address_t AUTO_LEN = (address_t) - 1
 
static const address_t UNLIMITED_LEN = (address_t) - 2
 
- Static Public Attributes inherited from openlcb::MemorySpace
static const errorcode_t ERROR_AGAIN = 0x3FFF
 This error code signals that the operation was only partially completed, the again notify was used and will be notified when the operation can be re-tried).
 

Detailed Description

Memory space implementation that exports the contents of a file as a memory space.

The file can be specified either as a path or an fd. By default writes are also allowed.

Definition at line 299 of file MemoryConfig.hxx.

Constructor & Destructor Documentation

◆ ROFileMemorySpace() [1/2]

openlcb::ROFileMemorySpace::ROFileMemorySpace ( int  fd,
address_t  len = AUTO_LEN 
)
inline

Creates a memory space based on an fd.

Parameters
fdis an open file descriptor with the data.
lentells how many bytes there are in the memory space. If specified as AUTO_LEN, then uses fstat to figure out the size of the file.

Definition at line 308 of file MemoryConfig.hxx.

◆ ROFileMemorySpace() [2/2]

openlcb::ROFileMemorySpace::ROFileMemorySpace ( const char *  name,
address_t  len = AUTO_LEN 
)
inline

Creates a memory space based on a file name.

Opens the file at the first use, and never closes it.

Parameters
nameis the file name to open. The pointer must stay alive so long as *this is around.
lentells how many bytes there are in the memory space. If specified as AUTO_LEN, then uses fstat to figure out the size of the file.

Definition at line 320 of file MemoryConfig.hxx.

Member Function Documentation

◆ read_only()

bool openlcb::ROFileMemorySpace::read_only ( )
inlinevirtual
Returns
whether the memory space does not accept writes.

Reimplemented from openlcb::FileMemorySpace.

Definition at line 323 of file MemoryConfig.hxx.


The documentation for this class was generated from the following file: