Class Byteline Ustyugov Dmitry MDSP November, 2009
2 Class Byteline Class Byteline implemented in memory.h –Is used to manipulate with entire byte combinations - bytelines. –Has its own private section –Methods and overloaded operators MDSP project, Intel Lab, Moscow Institute of Physics and Technology
3 Contents Private section and variables Constructors and destructors Methods and overloaded operators Overloaded operators MDSP project, Intel Lab, Moscow Institute of Physics and Technology
4 Private section and variables private: vector *byte_line;// pointer to vector of //Bytes MDSP project, Intel Lab, Moscow Institute of Physics and Technology
5 Constructors ByteLine(); –Creates empty object of Byteline class... Byteline example; // an empty object created... ByteLine( unsigned int); –Creates object of Byteline class with count Byte, initializing with null bytes... Byteline example( 5);// object consisting 5 null bytes created... MDSP project, Intel Lab, Moscow Institute of Physics and Technology
6 Constructors ByteLine( const ByteLine&); –Copy constructor... Byteline copy( example); // another object equal to the // previous one... ByteLine( const Byte&); –Conversion constructors Byte in ByteLine... Byteline now_it_is_bl;// object consisting 5 null bytes //created... MDSP project, Intel Lab, Moscow Institute of Physics and Technology
7 Destructor virtual ~ByteLine() { delete byte_line; } MDSP project, Intel Lab, Moscow Institute of Physics and Technology
8 Methods: get/set methods hostUInt8 getByteVal( unsigned int) const; Byte getByte( unsigned int) const; void setByte( unsigned int, const Byte&); MDSP project, Intel Lab, Moscow Institute of Physics and Technology
9 Methods: hostUInt8 getByteVal( unsigned int) const; The constant member function. Returns the value of the Byte at position pos in the ByteLine.If that position is invalid, recalls exception... // example.byteline is equal to | example.getByteVal( 1) = 10;... MDSP project, Intel Lab, Moscow Institute of Physics and Technology
10 Methods: get/setByte Byte getByte( unsigned int) const; –Returns the object of class Byte at position pos in the ByteLine. If that position is invalid, recalls exception... (example_byteline: byte2|byte1|byte0|) example_byteline.getByte( 1) = byte1;... void setByte( unsigned int, const Byte&); –Stores the object of class Byte at position pos in the ByteLine.If that position is invalid, recalls exception... (before: example_byteline: byte2|byte1|byte0|) Example.setByte( 2, newByte); (after: example_byteline: newByte|byte1|byte0|)... MDSP project, Intel Lab, Moscow Institute of Physics and Technology
11 Utility functions void addByte( const Byte&); –Adds object of Byte class to end of ByteLine... (before: example: byte2|byte1|) example.addByte( byte3); (after: example: byte3|byte2|byte1|)... void resizeByteLine( unsigned int); –Resize of ByteLine on count. New member of ByteLine is null bytes... (before: example: | |) example.resizeByteLine( 3) // result: | | |... unsigned int getSizeOfLine() const –The constant member function. Return size of Byteline MDSP project, Intel Lab, Moscow Institute of Physics and Technology
12 Overloaded operators ByteLine& operator = ( const ByteLine&); –Assign the current object of ByteLine class to another Byte operator[] ( unsigned int) const; –The constant member function.The member function returns an object of class reference. –Returns the Byte at position pos in the ByteLine. If position is invalid, recalls exception inline ByteLine operator<< ( const ByteLine& byteline, int count); –Shifts bytes in the byteline left with the count of bytes inline ByteLine operator>> ( const ByteLine& byteline, int count); –Shifts bytes in the byteline right with the count of bytes MDSP project, Intel Lab, Moscow Institute of Physics and Technology
13 Overloaded Operators: > inline ByteLine operator<< ( const ByteLine& byteline, int count); –Shifts bytes in the byteline left with the count of bytes... (before: example: | |) example << 3; (after: example: | |)... inline ByteLine operator>> ( const ByteLine& byteline, int count); –Shifts bytes in the byteline right with the count of bytes... (before: example: | |) example >> 3; (after: example: | |) MDSP project, Intel Lab, Moscow Institute of Physics and Technology
14 Friendly operators friend ostream& operator<< ( ostream&, const ByteLine&); –Outputs the ByteLine in bin form to screen friend ByteLine operator+ ( const ByteLine&, const ByteLine&); –Returns the ByteLine to be a result of addition of two objects of class reference... (example1: | |, example: | |) example = example1 + example2 (example: | | | |)... MDSP project, Intel Lab, Moscow Institute of Physics and Technology