OpenASIP  2.0
Protected Member Functions | Private Member Functions | Static Private Attributes | List of all members
TPEF::TPEFResourceSectionReader Class Reference

#include <TPEFResourceSectionReader.hh>

Inheritance diagram for TPEF::TPEFResourceSectionReader:
Inheritance graph
Collaboration diagram for TPEF::TPEFResourceSectionReader:
Collaboration graph

Protected Member Functions

 TPEFResourceSectionReader ()
 
virtual ~TPEFResourceSectionReader ()
 
virtual void readData (BinaryStream &stream, Section *section) const
 
virtual Section::SectionType type () const
 
- Protected Member Functions inherited from TPEF::TPEFSectionReader
 TPEFSectionReader ()
 
virtual BinaryReaderparent () const
 
virtual void readInfo (BinaryStream &stream, Section *sect) const
 
- Protected Member Functions inherited from TPEF::SectionReader
 SectionReader ()
 
virtual void finalize (Section *section) const
 

Private Member Functions

 TPEFResourceSectionReader (const TPEFResourceSectionReader &)
 Copying not allowed. More...
 
TPEFResourceSectionReaderoperator= (TPEFResourceSectionReader &)
 Assignment not allowed. More...
 

Static Private Attributes

static TPEFResourceSectionReader proto_
 Prototype instance to be registered. More...
 

Additional Inherited Members

- Public Types inherited from TPEF::SectionReader
typedef BinaryReader::Length Length
 
- Public Member Functions inherited from TPEF::TPEFSectionReader
virtual ~TPEFSectionReader ()
 
- Public Member Functions inherited from TPEF::SectionReader
virtual ~SectionReader ()
 
- Static Public Member Functions inherited from TPEF::SectionReader
static void readSection (BinaryStream &stream, Section *section, BinaryReader *reader)
 
static void finalizeBinary (Binary *binaryToFinalize, BinaryReader *reader)
 
- Static Protected Member Functions inherited from TPEF::TPEFSectionReader
static const Headerheader ()
 
- Static Protected Member Functions inherited from TPEF::SectionReader
static const SectionReaderfindSectionReader (const Section::SectionType type, const BinaryReader *bReader)
 
static void registerSectionReader (const SectionReader *sReader)
 

Detailed Description

Reads Processor Resource Table section from TPEF binary file.

Definition at line 47 of file TPEFResourceSectionReader.hh.

Constructor & Destructor Documentation

◆ TPEFResourceSectionReader() [1/2]

TPEF::TPEFResourceSectionReader::TPEFResourceSectionReader ( )
protected

Constructor.

Registers itself to SectionReader.

Definition at line 58 of file TPEFResourceSectionReader.cc.

58  :
61 }

References TPEF::SectionReader::registerSectionReader().

Here is the call graph for this function:

◆ ~TPEFResourceSectionReader()

TPEF::TPEFResourceSectionReader::~TPEFResourceSectionReader ( )
protectedvirtual

Destructor.

Definition at line 66 of file TPEFResourceSectionReader.cc.

66  {
67 }

◆ TPEFResourceSectionReader() [2/2]

TPEF::TPEFResourceSectionReader::TPEFResourceSectionReader ( const TPEFResourceSectionReader )
private

Copying not allowed.

Member Function Documentation

◆ operator=()

TPEFResourceSectionReader& TPEF::TPEFResourceSectionReader::operator= ( TPEFResourceSectionReader )
private

Assignment not allowed.

◆ readData()

void TPEF::TPEFResourceSectionReader::readData ( BinaryStream stream,
Section section 
) const
protectedvirtual

Reads section data from TPEF binary file.

Parameters
streamStream to be read from.
sectionSection where the information is to be stored.
Exceptions
UnreachableStreamIf reading of section fails.
KeyAlreadyExistsKey was in use when trying to register object.
EndOfFileIf end of file were reached while it shouldn't.
OutOfRangeSome of read value were out of range.
WrongSubclassSome class couldn't do what it was asked for.
UnexpectedValueIf there was unexpected value when reading.

Reimplemented from TPEF::TPEFSectionReader.

Definition at line 92 of file TPEFResourceSectionReader.cc.

93  {
94  // base classes implementation must be called with these
95  TPEFSectionReader::readData(stream, section);
96 
97  ResourceSection* resourceSection =
98  dynamic_cast<ResourceSection*>(section);
99  assert(resourceSection != NULL);
100 
101  // check that link section is defined properly
102  assert(header().linkId != 0);
103 
104  if (!section->noBits()) {
105  // store start of first element
106  SectionOffset elementStart = header().bodyOffset;
107 
108  while (elementStart + header().elementSize <=
109  header().bodyOffset + header().bodyLength) {
110 
111  ResourceElement *elem = new ResourceElement();
112 
113  // TODO: check that OP, SR and PORT share the same id space and
114  // don't collide
115 
116  elem->setId(stream.readHalfWord());
117 
118  elem->setType(
119  static_cast<ResourceElement::ResourceType>
120  (stream.readByte()));
121 
122  SectionOffsetKey
123  nameSectOffset(header().linkId, stream.readWord());
124 
125  elem->setName(CREATE_SAFEPOINTER(nameSectOffset));
126 
127  elem->setInfo(stream.readWord());
128 
129  section->addElement(elem);
130 
131  elementStart += header().elementSize;
132  stream.setReadPosition(elementStart);
133  }
134  }
135 }

References TPEF::Section::addElement(), assert, TPEF::TPEFSectionReader::Header::bodyOffset, TPEF::TPEFSectionReader::Header::elementSize, TPEF::TPEFSectionReader::header(), TPEF::Section::noBits(), TPEF::BinaryStream::readByte(), TPEF::TPEFSectionReader::readData(), TPEF::BinaryStream::readHalfWord(), TPEF::BinaryStream::readWord(), TPEF::ResourceElement::setId(), TPEF::ResourceElement::setInfo(), TPEF::ResourceElement::setName(), TPEF::BinaryStream::setReadPosition(), and TPEF::ResourceElement::setType().

Here is the call graph for this function:

◆ type()

Section::SectionType TPEF::TPEFResourceSectionReader::type ( ) const
protectedvirtual

Returns the type of section which reader can read.

Returns
The type of section which reader can read.

Implements TPEF::SectionReader.

Definition at line 75 of file TPEFResourceSectionReader.cc.

75  {
76  return Section::ST_MR;
77 }

References TPEF::Section::ST_MR.

Member Data Documentation

◆ proto_

TPEFResourceSectionReader TPEF::TPEFResourceSectionReader::proto_
staticprivate

Prototype instance to be registered.

Definition at line 63 of file TPEFResourceSectionReader.hh.


The documentation for this class was generated from the following files:
TPEF::TPEFSectionReader::TPEFSectionReader
TPEFSectionReader()
Definition: TPEFSectionReader.cc:50
TPEF::TPEFSectionReader::Header::bodyOffset
Word bodyOffset
Definition: TPEFSectionReader.hh:69
TPEF::TPEFSectionReader::Header::elementSize
Word elementSize
Definition: TPEFSectionReader.hh:68
assert
#define assert(condition)
Definition: Application.hh:86
TPEF::SectionReader::registerSectionReader
static void registerSectionReader(const SectionReader *sReader)
Definition: SectionReader.cc:145
TPEF::ResourceElement::ResourceType
ResourceType
Resource types.
Definition: ResourceElement.hh:51
TPEF::SectionOffset
Word SectionOffset
Type for storing offsets relative to a given base offset value.
Definition: TPEFBaseType.hh:49
TPEF::TPEFSectionReader::readData
virtual void readData(BinaryStream &stream, Section *section) const
Definition: TPEFSectionReader.cc:86
TPEF::Section::ST_MR
@ ST_MR
Machine resources section.
Definition: Section.hh:78
TPEF::TPEFSectionReader::header
static const Header & header()
Definition: TPEFSectionReader.cc:174