MIXAL
Public Member Functions | List of all members
mixal::IODeviceLinePrinter Class Reference

#include <io.h>

Inheritance diagram for mixal::IODeviceLinePrinter:
mixal::IODeviceSeqWriter mixal::IODeviceStorage mixal::IODevice

Public Member Functions

 IODeviceLinePrinter (int32_t storageSize=4096, int32_t pageSize=20)
 
void control (int32_t operation) final
 
int32_t pageSize () const
 
int32_t pageOffsetAt (int32_t index) const
 
std::string line (int32_t pageNum, int32_t lineNum) const
 
- Public Member Functions inherited from mixal::IODeviceSeqWriter
 IODeviceSeqWriter (int32_t storageSize=4096)
 
- Public Member Functions inherited from mixal::IODeviceStorage
 IODeviceStorage (int32_t storageSize=4096)
 
 IODeviceStorage (const IODeviceStorage &)=default
 
IODeviceStorageoperator= (const IODeviceStorage &)=default
 
bool ready (int32_t elapsed) override
 
void read (ComputerWord *memory, int32_t address) override
 
void write (const ComputerWord *memory, int32_t address) override
 
ComputerWordwordAt (int32_t index) override
 
- Public Member Functions inherited from mixal::IODevice
 IODevice (int32_t blockSize, bool allowRead, bool allowWrite)
 
IODeviceType type () const
 
int blockSize () const
 
bool allowRead () const
 
bool allowWrite () const
 

Additional Inherited Members

- Protected Member Functions inherited from mixal::IODeviceStorage
void doRead () override
 
- Protected Attributes inherited from mixal::IODeviceStorage
IODeviceStatus _status
 
int32_t _address
 
int32_t _locator
 
ComputerWord_memory
 
std::vector< ComputerWord_buffer
 
std::vector< ComputerWord_storage
 
- Protected Attributes inherited from mixal::IODevice
IODeviceType _type
 
int32_t _blockSize
 
bool _allowRead
 
bool _allowWrite
 
int32_t _timestamp
 
double _readyRate
 

Detailed Description

Line printer.

Definition at line 166 of file io.h.

Member Function Documentation

◆ control()

void mixal::IODeviceLinePrinter::control ( int32_t  operation)
finalvirtual

Skip the printer to the top of the following page.

Reimplemented from mixal::IODevice.

Definition at line 140 of file io.cpp.

140  {
141  _locator += (_pageSize - _locator / _blockSize % _pageSize) * _blockSize;
142 }

References mixal::IODevice::_blockSize.

◆ line()

std::string mixal::IODeviceLinePrinter::line ( int32_t  pageNum,
int32_t  lineNum 
) const

Get the printed line with the given page number and line number in the page.

Definition at line 148 of file io.cpp.

148  {
149  int32_t offset = pageOffsetAt(pageNum) + lineNum * _blockSize;
150  std::ostringstream out;
151  for (int i = 0; i < _blockSize; ++i) {
152  out << _storage[offset + i].getCharacters();
153  }
154  return out.str();
155 }

References mixal::IODevice::_blockSize, and pageOffsetAt().

◆ pageOffsetAt()

int32_t mixal::IODeviceLinePrinter::pageOffsetAt ( int32_t  index) const

Get the beginning offset of the page based on the given page number.

Definition at line 144 of file io.cpp.

144  {
145  return index * _pageSize * _blockSize;
146 }

References mixal::IODevice::_blockSize.

Referenced by line().

◆ pageSize()

int32_t mixal::IODeviceLinePrinter::pageSize ( ) const
inline

Number of lines/blocks in one page.

Definition at line 172 of file io.h.

172 { return _pageSize; }

The documentation for this class was generated from the following files:
mixal::IODevice::_blockSize
int32_t _blockSize
Definition: io.h:74
mixal::IODeviceLinePrinter::pageOffsetAt
int32_t pageOffsetAt(int32_t index) const
Definition: io.cpp:144