Class byteline
Download
1 / 14

Class Byteline - PowerPoint PPT Presentation


  • 55 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Class Byteline' - dacey


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Class byteline

ClassByteline

Ustyugov Dmitry

MDSP

November, 2009


Class byteline1
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


Contents
Contents

  • Private section and variables

  • Constructors and destructors

  • Methods and overloaded operators

  • Overloaded operators

MDSP project, Intel Lab,

Moscow Institute of Physics and Technology


Private section and variables
Private section and variables

private:

vector<Byte> *byte_line; // pointer to vector of //Bytes

MDSP project, Intel Lab,

Moscow Institute of Physics and Technology


Constructors
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


Constructors1
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

      ...


Destructor
Destructor

MDSP project, Intel Lab,

Moscow Institute of Physics and Technology

virtual ~ByteLine()

{

delete byte_line;

}


Methods get set methods
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&);


Methods hostuint8 getbyteval unsigned int const
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


Methods get setbyte
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


Utility functions
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


Overloaded operators
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


Overloaded operators and
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


Friendly operators
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


ad