using namespace std;
-data_block::data_block(tape_block& idol)
- :tape_block(idol)
-{
-}
-
-data_block::~data_block(){
-}
+/*!
+ *\brief Specialisation constructor.
+ */
+data_block::data_block(tape_block& org)
+ :tape_block(org)
+{}
+/*!
+ *\brief Determine block type.
+ *\return the block type extracted from the block's data.
+ */
int data_block::get_type(){
if ((init_state==TBS_OK)&&word_data)
return (word_data[0]&0xf000)>>12;
return block_type;
}
-int data_block::get_subtype(){
- if (get_type()==0)
- return (new data_block_0(*this))->get_subtype();
- else return 0;
-}
-
/*!
*\brief Get the block's size in 16 bit words.
- *\return The block's 16-bit data buffer's size including header and checksum.
+ *\return The block's 16-bit data buffer's size including
+ * header and checksum.
*/
int data_block::get_word_size(){
return word_size;
}
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block::get_description(){
+ vector<string> result;
+ string r_string="***** "+get_typestring()+"Untyped data block, this \
+ is an illegal condition!";
+ result.insert(result.end(),r_string);
+ return result;
+}
+
/*!
*\brief Extract 6 byte symbol name from word memory.
*
- *\param startbyte the first byte of the desired symbol name
+ *\param firstbyte the first byte of the desired symbol name
*\return a string containing the symbol name.
* Trailing spaces are included.
*\note The word_data is handled system-intependently big endian!
*/
-string data_block::extract_string(int startbyte){
+string data_block::extract_label(int firstbyte){
string result=""; // Start with empty string
// We don't accept negative arguments!
- if (startbyte<0) return result;
+ if (firstbyte<0) return result;
// We also don't want segmentation faults!
- if (word_size<(startbyte/2+1)) return result;
+ if (word_size<(firstbyte/2+1)) return result;
// Here we pick out the characters.
- for (int posi=startbyte;posi<startbyte+6;posi++)
+ for (int posi=firstbyte;posi<firstbyte+6;posi++)
result+=(word_data[posi/2]>>(8*(1-posi%2)))&0x7f;
return result;
}
+
-#ifndef DATA_BLOCK_HH
-#define DATA_BLOCK_HH
+#ifndef DATA_BLOCK_H
+#define DATA_BLOCK_H
+#include<vector>
#include<string>
+
#include "tape_block.hh"
using namespace std;
+/*!
+ * Class representating a data tape block.
+ */
class data_block
: public tape_block
{
-private:
- data_block();
-
-public:
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+private:
data_block(tape_block&);
- ~data_block();
-
- virtual int get_type();
- virtual int get_subtype();
+
+public:
+ int get_type();
int get_word_size();
- //protected:
- string extract_string(int startbyte);
+ virtual vector<string> get_description();
+protected:
+ string extract_label(int);
};
-#include <string>
-
#include "data_block_0.hh"
-#include "data_block.hh"
/*!
*\brief Parent class copy constructor.
:data_block(org)
{}
-
/*!
- *\brief Default destructor.
- */
-data_block_0::~data_block_0(){}
-
+ * Determine the block's subtype.
+ *\return The block's subtype, read from block data.
+ */
int data_block_0::get_subtype(){
return (word_data[0]&0x0fc0)>>6;
}
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0::get_description(){
+ vector<string> result;
+ char buffer[150];
+ sprintf(buffer," (0-%02o) Type 0 data block, unknown\
+ subtype, this is an illegal condition!",get_subtype());
+ string r_string=buffer;
+ result.insert(result.end(),r_string);
+ return result;
+}
+
+
#ifndef DATA_BLOCK_0_H
#define DATA_BLOCK_0_H
+#include <vector>
#include <string>
+
#include "data_block.hh"
/*!
class data_block_0
: public data_block
{
- public:
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+private:
data_block_0(data_block&);
- virtual ~data_block_0();
+
+public:
int get_subtype();
-protected:
+ vector<string> get_description();
+
};
#endif
+
+
--- /dev/null
+#include "data_block_0_0.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_0::data_block_0_0(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_0::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_0_H
+#define DATA_BLOCK_0_0_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_0
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_0(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_1.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_1::data_block_0_1(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_1::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_1_H
+#define DATA_BLOCK_0_1_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_1
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_1(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_10.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_10::data_block_0_10(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_10::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_10_H
+#define DATA_BLOCK_0_10_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_10
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_10(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_14.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_14::data_block_0_14(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_14::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_14_H
+#define DATA_BLOCK_0_14_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_14
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_14(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_2.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_2::data_block_0_2(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_2::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_2_H
+#define DATA_BLOCK_0_2_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_2
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_2(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_24.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_24::data_block_0_24(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_24::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_24_H
+#define DATA_BLOCK_0_24_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_24
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_24(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_3.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_3::data_block_0_3(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_3::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_3_H
+#define DATA_BLOCK_0_3_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_3
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_3(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_30.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_30::data_block_0_30(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_30::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_30_H
+#define DATA_BLOCK_0_30_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_30
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_30(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_4.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_4::data_block_0_4(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_4::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_4_H
+#define DATA_BLOCK_0_4_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_4
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_4(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_44.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_44::data_block_0_44(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_44::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_44_H
+#define DATA_BLOCK_0_44_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_44
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_44(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_50.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_50::data_block_0_50(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_50::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_50_H
+#define DATA_BLOCK_0_50_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_50
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_50(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_54.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_54::data_block_0_54(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_54::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_54_H
+#define DATA_BLOCK_0_54_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_54
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_54(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_60.hh"
+
+#include <stdio.h>
+
+/*!
+ *\brief Parent class copy constructor.
+ */
+data_block_0_60::data_block_0_60(data_block_0 & org)
+ :data_block_0(org)
+{}
+
+/*!
+ *\brief Describe the block.
+ *\return A vector of text lines describing this block.
+ */
+vector<string> data_block_0_60::get_description(){
+ vector<string> result;
+ result.insert(result.end(),"Fixme! "+get_typestring()+"Default 0-* block");
+ return result;
+}
+
--- /dev/null
+#ifndef DATA_BLOCK_0_60_H
+#define DATA_BLOCK_0_60_H
+
+#include <vector>
+#include <string>
+
+#include "data_block_0.hh"
+
+/*!
+ *\brief Class for block type (0-0).
+ */
+class data_block_0_60
+ : public data_block_0
+{
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public:
+ vector<string> get_description();
+
+protected:
+ data_block_0_60(data_block_0&);
+
+
+};
+
+#endif
--- /dev/null
+#include "data_block_0_label_extractor.hh"
+
+/*!
+ *\brief Default constructor.
+ */
+
+/*!
+ *\brief Extract labels from data_block_0_* blocks
+ *\return A vector containing all labels present in the block
+ */
+vector<string> data_block_0_label_extractor::get_labels(){
+ int l_count=word_size/3-1;
+ vector<string> result;
+ for (int l_no=0; l_no<l_count;l_no++)
+ result.insert(result.end(),extract_label(4+6*l_no));
+ return result;
+}
--- /dev/null
+#ifndef DATA_BLOCK_0_LABEL_EXTRACTOR_H
+#define DATA_BLOCK_0_LABEL_EXTRACTOR_H
+
+#include <vector>
+#include <string>
+
+#include "data_block.hh"
+
+/*!
+ *\brief Abstract class providing label extraction for some data_block_0 subtypes.
+ * This class cannot be instantiated.\n
+ */
+class data_block_0_label_extractor
+ : public virtual data_block
+{
+
+private:
+ data_block_0_label_extractor();
+
+protected:
+ vector<string> get_labels();
+
+};
+
+#endif
+#include <string>
+#include <vector>
+
+#include "discard_block.hh"
+#include "tape_block.hh"
+
+using namespace std;
+
+/***************************************************************/
+/*!
+ *\brief Copy constructor.
+ */
+discard_block::discard_block(discard_block & org){
+ operator=(org);
+}
+
+/***************************************************************/
+/*!
+ *\brief Get a cleartext description of the block.
+ *\return ldc style descriptive line for the block
+ */
+vector<string> discard_block::get_description(){
+ string r_string;
+ switch(init_state){
+ case TBS_OK:
+ r_string="***** (X-XX) Discard block, init_status OK,\
+ this is an illegal condition!";
+ break;
+ case TBS_EOF_LEGAL:
+ r_string=" (EOF) Legal EOF";
+ break;
+ case TBS_EOF_ILLEGAL:
+ r_string=" (EOF) Illegal EOF while in block!";
+ break;
+ case TBS_CHECKSUM:
+ r_string=" (CHK) Checksum error in Block!";
+ break;
+ case TBS_IOERR:
+ r_string=" (IOE) IO-Error during initialisation!";
+ break;
+ case TBS_DEFAULT:
+ r_string="***** (X-XX) Discard block, init_status not set,\
+ this is an illegal condition!";
+ break;
+ default:
+ r_string="***** (X-XX) Discard block, init_status unknown,\
+ this is an illegal condition!";
+ break;
+ }
+ vector<string> result;
+ result.insert(result.end(),r_string);
+ return result;
+}
+
+/***************************************************************/
+/*!
+ *\brief Specialisation constructor
+ */
+discard_block::discard_block(tape_block & org)
+ : tape_block(org)
+{
+}
+
+/***************************************************************/
+/*!
+ *\brief Default constructor.
+ */
+discard_block::discard_block(){}
+#ifndef DISCARD_BLOCK_H
+#define DISCARD_BLOCK_H
+
+#include <string>
+#include <vector>
+
+#include "tape_block.hh"
+
+using namespace std;
+
+/*!
+ *\brief Class representating an invalid block.
+ *
+ *Reasons for a block to be invalid are:\n
+ * - EOF on fd used to initialise,
+ * - Checksum error in a block
+ * - IO error while reading from fd
+ * The reason for the block to be a discard_block can be
+ * resolved by using get_state().
+ */
+class discard_block
+ :public tape_block
+{
+ friend tape_block* tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public: // methods
+ discard_block(discard_block &);
+ virtual vector<string> get_description();
+
+discard_block(tape_block &);
+private: // methods
+
+ discard_block();
+
+}; // class discard_block
+
+
+#endif
+#include <string>
+#include <vector>
+
+#include "eot_block.hh"
+#include "tape_block.hh"
+
+using namespace std;
+
+/***************************************************************/
+/*!
+ *\brief Copy constructor.
+ */
+eot_block::eot_block(eot_block & org){
+ operator=(org);
+}
+
+/***************************************************************/
+/*!
+ *\brief Get a cleartext description of the block.
+ *\return ldc style descriptive line for the block
+ */
+vector<string> eot_block:: get_description(){
+ vector<string> result;
+ string r_string=" (EOT) End of Tape mark";
+ result.insert(result.end(),r_string);
+ return result;
+}
+
+/***************************************************************/
+/*!
+ *\brief Specialisation constructor
+ */
+eot_block::eot_block(tape_block & org)
+ : tape_block(org)
+{}
+
+/***************************************************************/
+/*!
+ *\brief Default constructor.
+ */
+eot_block::eot_block(){}
-
#ifndef EOT_BLOCK_H
#define EOT_BLOCK_H
#include <string>
+#include <vector>
+
+#include "tape_block.hh"
+
using namespace std;
-class eot_block
- : public tape_block
+/*!
+ *\brief Class representating an End of Tape block.
+ */
+class eot_block : public tape_block
{
-private:
+ friend tape_block * tape_block::gen_from_fd(int,void(*)(void*),
+ void(*)(void*),void*);
+public: // methods
+ eot_block(eot_block &);
+ virtual vector<string> get_description();
+
+private: // methods
+ eot_block(tape_block &);
eot_block();
-public:
- eot_block(tape_block&);
- ~eot_block();
-
- virtual int get_type();
- virtual int get_subtype();
- int get_word_size();
-
+}; // class eot_block
-};
#endif
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-
-#include <string>
-#include <vector>
+#include <stdio.h>
#include "tape_block.hh"
#include "data_block.hh"
#include "data_block_0.hh"
+#include "data_block_0_0.hh"
+#include "data_block_0_1.hh"
+#include "data_block_0_2.hh"
+#include "data_block_0_3.hh"
+#include "data_block_0_4.hh"
+#include "data_block_0_10.hh"
+#include "data_block_0_14.hh"
+#include "data_block_0_24.hh"
+#include "data_block_0_44.hh"
+#include "data_block_0_30.hh"
+#include "data_block_0_54.hh"
+#include "data_block_0_60.hh"
+#include "data_block_0_50.hh"
+#include "eot_block.hh"
+#include "discard_block.hh"
#include "silent_code.hh"
#include "hw_constants.hh"
*\return ldc style descriptive line for the block
*/
vector<string> tape_block:: get_description(){
- char buffer[100];
- sprintf(buffer," (%0o-%02o) Untyped tape block",
- get_type(),get_subtype());
vector<string> result;
- result.insert(result.end(),buffer);
+ result.insert(result.end(),
+ "***** "+get_typestring()+"Untyped tape block");
return result;
}
*\brief Static factory method with file descriptor support.
*
* This method creates a tape_block by using the private
- * constructor with file descriptor support.\t
+ * constructor with file descriptor support.\n
* It always returns a valid pointer, errors
* or exceptional conditions during creation are marked in the
* object's state.\n
* This allows for easy use of the object using it's virtual
* interface methods or a cast of the pointer to a sub type pointer
* according to the type information, and then using the subtype's
- * methods not already present in tape_block.\t
- * Objects of the following subclasses are automagically generated:\t
+ * methods not already present in tape_block.\n
+ * Objects of the following subclasses are automagically generated:\n
* - eot_block
+ * - discard_block
* - data_block
- * -data_block_0
- * -data_block_0_0
- * -data_block_0_1
- * -data_block_0_2
- * -data_block_0_3
- * -data_block_0_4
- * -data_block_0_10
- * -data_block_0_14
- * -data_block_0_24
- * -data_block_0_30
- * -data_block_0_50
- * -data_block_0_54
- * -data_block_0_60
- * -data_block_1
- * -data_block_2
- * -data_block_3
- * -data_block_4
- * -data_block_5
- * -data_block_6
- * -data_block_7
+ * - data_block_0
+ * - data_block_0_0
+ * - data_block_0_1
+ * - data_block_0_2
+ * - data_block_0_3
+ * - data_block_0_4
+ * - data_block_0_10
+ * - data_block_0_14
+ * - data_block_0_24
+ * - data_block_0_30
+ * - data_block_0_50
+ * - data_block_0_54
+ * - data_block_0_60
+ * - data_block_1
+ * - data_block_2
+ * - data_block_3
+ * - data_block_4
+ * - data_block_5
+ * - data_block_6
+ * - data_block_7
*
*\return Pointer to an object of type tape_block or a subclass.
*\param fd A file descriptor where the read is taken from.
{
tape_block * res_block;
res_block=new tape_block(fd,input_start,input_stop,start_stop_arg);
- data_block * d_block;
- data_block_0 * d0_block;
-
+ data_block * d_block;
+ data_block_0 * d0_block;
+ eot_block * e_block;
+ discard_block * di_block;
+
// Retype to data_block if possible
switch(res_block->get_type()){
case tape_block::TBT_DATA: // Make pointer a data block
delete res_block;
res_block=d_block;
break;
+ case tape_block::TBT_EOT:
+ e_block=new eot_block(*res_block);
+ delete res_block;
+ res_block=e_block;
+ break;
+ case tape_block::TBT_DISCARD:
+ di_block=new discard_block(*res_block);
+ delete res_block;
+ res_block=di_block;
+ break;
default: // All other cases
return res_block;
}
res_block=d_block;
if (res_block->get_type()==0) switch(d0_block->get_subtype()){
-// case 000: d0_block=new data_block_0_00(d0_block); break;
-// case 001: d0_block=new data_block_0_01(d0_block); break;
-// case 002: d0_block=new data_block_0_02(d0_block); break;
-// case 003: d0_block=new data_block_0_03(d0_block); break;
-// case 004: d0_block=new data_block_0_04(d0_block); break;
-// case 010: d0_block=new data_block_0_10(d0_block); break;
-// case 014: d0_block=new data_block_0_14(d0_block); break;
-// case 024: d0_block=new data_block_0_24(d0_block); break;
-// case 030: d0_block=new data_block_0_30(d0_block); break;
-// case 054: d0_block=new data_block_0_54(d0_block); break;
-// case 060: d0_block=new data_block_0_60(d0_block); break;
-// case 060: d0_block=new data_block_0_50(d0_block); break;
+ case 000: d0_block=new data_block_0_0(*d0_block); break;
+ case 001: d0_block=new data_block_0_1(*d0_block); break;
+ case 002: d0_block=new data_block_0_2(*d0_block); break;
+ case 003: d0_block=new data_block_0_3(*d0_block); break;
+ case 004: d0_block=new data_block_0_4(*d0_block); break;
+ case 010: d0_block=new data_block_0_10(*d0_block); break;
+ case 014: d0_block=new data_block_0_14(*d0_block); break;
+ case 024: d0_block=new data_block_0_24(*d0_block); break;
+ case 044: d0_block=new data_block_0_44(*d0_block); break;
+ case 030: d0_block=new data_block_0_30(*d0_block); break;
+ case 054: d0_block=new data_block_0_54(*d0_block); break;
+ case 060: d0_block=new data_block_0_60(*d0_block); break;
+ case 050: d0_block=new data_block_0_50(*d0_block); break;
default:
return res_block;
}
*/
tape_block::tape_block(){}
+/***************************************************************/
+/*!
+ *\brief get a short type description string.
+ *\return A small string to be used in description methods.
+ *
+ * The string is always 19 characters long.\n
+ * An example is "(99-99) ".
+ */
+string tape_block::get_typestring(){
+ char buffer[13];
+ sprintf(buffer,"(%o-%o) ",get_type(),get_subtype());
+ buffer[10]=0;
+ return string(buffer);
+}
/***************************************************************/
/*!
void * start_stop_arg=0
);
-private: // methods
+protected: // methods
tape_block();
+ string get_typestring();
+
+private: // methods
tape_block (int fd_p,
void(*input_start)(void *)=0,
void (*input_stop)(void *)=0,