Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class Byteline Ustyugov Dmitry MDSP November, 2009.

Similar presentations


Presentation on theme: "Class Byteline Ustyugov Dmitry MDSP November, 2009."— Presentation transcript:

1 Class Byteline Ustyugov Dmitry MDSP November, 2009

2 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 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 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 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 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 7 Destructor virtual ~ByteLine() { delete byte_line; } MDSP project, Intel Lab, Moscow Institute of Physics and Technology

8 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 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 00001010|10000000 example.getByteVal( 1) = 10;... MDSP project, Intel Lab, Moscow Institute of Physics and Technology

10 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 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: 01111000|01010101|) example.resizeByteLine( 3) // result: 01111000|01010101|00000000|...  unsigned int getSizeOfLine() const –The constant member function. Return size of Byteline MDSP project, Intel Lab, Moscow Institute of Physics and Technology

12 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 13 Overloaded Operators: >  inline ByteLine operator<< ( const ByteLine& byteline, int count); –Shifts bytes in the byteline left with the count of bytes... (before: example: 01010101|00100100|) example << 3; (after: example: 01010100|10010000|)...  inline ByteLine operator>> ( const ByteLine& byteline, int count); –Shifts bytes in the byteline right with the count of bytes... (before: example: 01010101|00100100|) example >> 3; (after: example: 00001010|10100100|) MDSP project, Intel Lab, Moscow Institute of Physics and Technology

14 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: 01010101|10001000|, example: 00100001|00001111|) example = example1 + example2 (example: 01010101|10001000|00100001|00001111|)... MDSP project, Intel Lab, Moscow Institute of Physics and Technology


Download ppt "Class Byteline Ustyugov Dmitry MDSP November, 2009."

Similar presentations


Ads by Google