1 / 14

Class Byteline

Class Byteline. Ustyugov Dmitry MDSP November, 2009. 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. Contents. Private section and variables

dacey
Download Presentation

Class Byteline

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ClassByteline Ustyugov Dmitry MDSP November, 2009

  2. ClassByteline • 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> *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 classwith 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 MDSP project, Intel Lab, Moscow Institute of Physics and Technology • 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 ...

  7. Destructor MDSP project, Intel Lab, Moscow Institute of Physics and Technology virtual ~ByteLine() { delete byte_line; }

  8. Methods: get/set methods MDSP project, Intel Lab, Moscow Institute of Physics and Technology hostUInt8 getByteVal( unsigned int) const; Byte getByte( unsigned int) const; void setByte( unsigned int, const Byte&);

  9. Methods: hostUInt8 getByteVal( unsigned int) const; • The constant member function. Returns the value ofthe Byte at position pos in the ByteLine.If thatposition 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. Methods: get/setByte • Byte getByte( unsigned int) const; • Returns theobject 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 inthe 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: 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. 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 ofclass 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: << and >> • 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. 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

More Related