w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
Rw11UnitTape.cpp
Go to the documentation of this file.
1// $Id: Rw11UnitTape.cpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2015-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2018-12-19 1090 1.0.3 use RosPrintf(bool)
8// 2018-12-09 1080 1.0.2 use HasVirt(); Virt() returns ref
9// 2017-04-07 868 1.0.1 Dump(): add detail arg
10// 2015-06-04 686 1.0 Initial version
11// 2015-05-17 683 0.1 First draft
12// ---------------------------------------------------------------------------
13
19
20#include "librtools/RosFill.hpp"
22
23#include "Rw11UnitTape.hpp"
24
25using namespace std;
26
32// all method definitions in namespace Retro
33namespace Retro {
34
35//------------------------------------------+-----------------------------------
37
39 : Rw11UnitVirt<Rw11VirtTape>(pcntl, index),
40 fType(),
41 fEnabled(false),
42 fWProt(false),
43 fCapacity(0)
44{}
45
46//------------------------------------------+-----------------------------------
48
50{}
51
52//------------------------------------------+-----------------------------------
54
55void Rw11UnitTape::SetType(const std::string& /*type*/)
56{
57 throw Rexception("Rw11UnitTape::SetType",
58 string("Bad args: only type '") + fType + "' supported");
59}
60
61//------------------------------------------+-----------------------------------
63
64void Rw11UnitTape::SetWProt(bool wprot)
65{
66 if (HasVirt()) throw Rexception("Rw11UnitTape::SetWProt",
67 "not allowed when tape attached");
68 fWProt = wprot;
69 return;
70}
71
72//------------------------------------------+-----------------------------------
74
75void Rw11UnitTape::SetCapacity(size_t nbyte)
76{
77 if (HasVirt()) throw Rexception("Rw11UnitTape::SetCapacity",
78 "not allowed when tape attached");
79 fCapacity = nbyte;
80 return;
81}
82
83//------------------------------------------+-----------------------------------
85
86void Rw11UnitTape::SetPosFile(int posfile)
87{
88 if (!HasVirt()) throw Rexception("Rw11UnitTape::SetPosFile",
89 "no tape attached");
90 Virt().SetPosFile(posfile);
91 return;
92}
93
94//------------------------------------------+-----------------------------------
96
98{
99 if (!HasVirt()) throw Rexception("Rw11UnitTape::SetPosRecord",
100 "no tape attached");
101 Virt().SetPosRecord(posrec);
102 return;
103}
104
105//------------------------------------------+-----------------------------------
107
109{
110 if (!HasVirt()) return false;
111 return Virt().Bot();
112}
113
114//------------------------------------------+-----------------------------------
116
118{
119 if (!HasVirt()) return false;
120 return Virt().Eot();
121}
122
123//------------------------------------------+-----------------------------------
125
127{
128 if (!HasVirt()) return false;
129 return Virt().Eom();
130}
131
132//------------------------------------------+-----------------------------------
134
136{
137 if (!HasVirt()) return -1;
138 return Virt().PosFile();
139}
140
141//------------------------------------------+-----------------------------------
143
145{
146 if (!HasVirt()) return -1;
147 return Virt().PosRecord();
148}
149
150//------------------------------------------+-----------------------------------
152
153bool Rw11UnitTape::VirtReadRecord(size_t nbyte, uint8_t* data, size_t& ndone,
154 int& opcode, RerrMsg& emsg)
155{
156 if (!HasVirt()) {
157 emsg.Init("Rw11UnitTape::VirtReadRecord", "no tape attached");
158 return false;
159 }
160 return Virt().ReadRecord(nbyte, data, ndone, opcode, emsg);
161}
162
163//------------------------------------------+-----------------------------------
165
166bool Rw11UnitTape::VirtWriteRecord(size_t nbyte, const uint8_t* data,
167 int& opcode, RerrMsg& emsg)
168{
169 if (!HasVirt()) {
170 emsg.Init("Rw11UnitTape::VirtWriteRecord", "no tape attached");
171 return false;
172 }
173 return Virt().WriteRecord(nbyte, data, opcode, emsg);
174}
175
176//------------------------------------------+-----------------------------------
178
180{
181 if (!HasVirt()) {
182 emsg.Init("Rw11UnitTape::VirtWriteEof", "no tape attached");
183 return false;
184 }
185 return Virt().WriteEof(emsg);
186}
187
188//------------------------------------------+-----------------------------------
190
191bool Rw11UnitTape::VirtSpaceForw(size_t nrec, size_t& ndone,
192 int& opcode, RerrMsg& emsg)
193{
194 if (!HasVirt()) {
195 emsg.Init("Rw11UnitTape::VirtSpaceForw", "no tape attached");
196 return false;
197 }
198 return Virt().SpaceForw(nrec, ndone, opcode, emsg);
199}
200
201//------------------------------------------+-----------------------------------
203
204bool Rw11UnitTape::VirtSpaceBack(size_t nrec, size_t& ndone,
205 int& opcode, RerrMsg& emsg)
206{
207 if (!HasVirt()) {
208 emsg.Init("Rw11UnitTape::VirtSpaceBack", "no tape attached");
209 return false;
210 }
211 return Virt().SpaceBack(nrec, ndone, opcode, emsg);
212}
213
214//------------------------------------------+-----------------------------------
216
217bool Rw11UnitTape::VirtRewind(int& opcode, RerrMsg& emsg)
218{
219 if (!HasVirt()) {
220 emsg.Init("Rw11UnitTape::VirtRewind", "no tape attached");
221 return false;
222 }
223 return Virt().Rewind(opcode, emsg);
224}
225
226//------------------------------------------+-----------------------------------
228
229void Rw11UnitTape::Dump(std::ostream& os, int ind, const char* text,
230 int detail) const
231{
232 RosFill bl(ind);
233 os << bl << (text?text:"--") << "Rw11UnitTape @ " << this << endl;
234 os << bl << " fType: " << fType << endl;
235 os << bl << " fEnabled: " << RosPrintf(fEnabled) << endl;
236 os << bl << " fWProt: " << RosPrintf(fWProt) << endl;
237 os << bl << " fCapacity: " << fCapacity << endl;
238
239 Rw11UnitVirt<Rw11VirtTape>::Dump(os, ind, " ^", detail);
240 return;
241}
242
243
244} // end namespace Retro
FIXME_docs.
Definition: RerrMsg.hpp:25
void Init(const std::string &meth, const std::string &text)
FIXME_docs.
Definition: RerrMsg.cpp:74
FIXME_docs.
Definition: Rexception.hpp:29
I/O appicator to generate fill characters.
Definition: RosFill.hpp:24
FIXME_docs.
Definition: Rw11Cntl.hpp:42
bool VirtWriteRecord(size_t nbyte, const uint8_t *data, int &opcode, RerrMsg &emsg)
FIXME_docs.
bool Eom() const
FIXME_docs.
virtual void SetType(const std::string &type)
FIXME_docs.
bool VirtSpaceForw(size_t nrec, size_t &ndone, int &opcode, RerrMsg &emsg)
FIXME_docs.
size_t fCapacity
capacity in byte (0=unlimited)
bool Eot() const
FIXME_docs.
bool fEnabled
unit enabled
std::string fType
drive type
void SetCapacity(size_t nbyte)
FIXME_docs.
void SetPosRecord(int posrec)
FIXME_docs.
bool VirtSpaceBack(size_t nrec, size_t &ndone, int &opcode, RerrMsg &emsg)
FIXME_docs.
int PosFile() const
FIXME_docs.
bool VirtRewind(int &opcode, RerrMsg &emsg)
FIXME_docs.
bool Bot() const
FIXME_docs.
~Rw11UnitTape()
Destructor.
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
bool VirtWriteEof(RerrMsg &emsg)
FIXME_docs.
bool VirtReadRecord(size_t nbyte, uint8_t *data, size_t &ndone, int &opcode, RerrMsg &emsg)
FIXME_docs.
bool fWProt
unit write protected
int PosRecord() const
FIXME_docs.
void SetWProt(bool wprot)
FIXME_docs.
void SetPosFile(int posfile)
FIXME_docs.
Rw11UnitTape(Rw11Cntl *pcntl, size_t index)
Constructor.
Implemenation (inline) of Rw11UnitVirt.
Rw11VirtTape & Virt()
FIXME_docs.
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
bool HasVirt() const
FIXME_docs.
void SetPosFile(int posfile)
FIXME_docs.
virtual bool SpaceForw(size_t nrec, size_t &ndone, int &opcode, RerrMsg &emsg)=0
bool Eom() const
FIXME_docs.
int PosFile() const
FIXME_docs.
int PosRecord() const
FIXME_docs.
void SetPosRecord(int posrec)
FIXME_docs.
virtual bool Rewind(int &opcode, RerrMsg &emsg)=0
bool Eot() const
FIXME_docs.
virtual bool WriteRecord(size_t nbyte, const uint8_t *data, int &opcode, RerrMsg &emsg)=0
virtual bool ReadRecord(size_t nbyte, uint8_t *data, size_t &ndone, int &opcode, RerrMsg &emsg)=0
virtual bool SpaceBack(size_t nrec, size_t &ndone, int &opcode, RerrMsg &emsg)=0
bool Bot() const
FIXME_docs.
virtual bool WriteEof(RerrMsg &emsg)=0
RosPrintfS< bool > RosPrintf(bool value, const char *form=0, int width=0, int prec=0)
Creates a print object for the formatted output of a bool value.
Definition: RosPrintf.ipp:38
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47