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

#include <TPEFResourceSectionWriter.hh>

Inheritance diagram for TPEF::TPEFResourceSectionWriter:
Inheritance graph
Collaboration diagram for TPEF::TPEFResourceSectionWriter:
Collaboration graph

Protected Member Functions

 TPEFResourceSectionWriter ()
 
virtual ~TPEFResourceSectionWriter ()
 
virtual Section::SectionType type () const
 
virtual void actualWriteData (BinaryStream &stream, const Section *section) const
 
virtual Word elementSize (const Section *section) const
 
- Protected Member Functions inherited from TPEF::TPEFSectionWriter
 TPEFSectionWriter ()
 
virtual ~TPEFSectionWriter ()
 
virtual const BinaryWriterparent () const
 
virtual void actualWriteHeader (BinaryStream &stream, const Section *sect) const
 
virtual void createKeys (const Section *sect) const
 
virtual void writeSize (BinaryStream &stream, const Section *sect) const
 
virtual void writeInfo (BinaryStream &stream, const Section *sect) const
 
virtual SectionId getSectionId () const
 
- Protected Member Functions inherited from TPEF::SectionWriter
 SectionWriter ()
 
virtual ~SectionWriter ()
 
virtual void finalize (BinaryStream &stream, Section *section) const
 

Private Member Functions

 TPEFResourceSectionWriter (const TPEFResourceSectionWriter &)
 Copying not allowed. More...
 
TPEFResourceSectionWriter operator= (const TPEFResourceSectionWriter &)
 Assignment not allowed. More...
 

Static Private Attributes

static const TPEFResourceSectionWriter instance_
 An unique instance of class. More...
 
static const Word elementSize_ = 11
 The fixed size element. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from TPEF::SectionWriter
static void writeHeader (BinaryStream &stream, const Section *sect, const BinaryWriter *writer)
 
static void writeData (BinaryStream &stream, const Section *sect, const BinaryWriter *writer)
 
static void finalizeBinary (BinaryStream &stream, const Binary *binaryToFinalize, const BinaryWriter *writer)
 
- Static Protected Member Functions inherited from TPEF::SectionWriter
static void registerSectionWriter (const SectionWriter *sWriter)
 
static SectionId getUniqueSectionId ()
 

Detailed Description

Writes TPEF Processor Resource Table section to stream.

Definition at line 46 of file TPEFResourceSectionWriter.hh.

Constructor & Destructor Documentation

◆ TPEFResourceSectionWriter() [1/2]

TPEF::TPEFResourceSectionWriter::TPEFResourceSectionWriter ( )
protected

Constructor.

Registers itself to SectionWriter.

Definition at line 62 of file TPEFResourceSectionWriter.cc.

62  :
65 }

References TPEF::SectionWriter::registerSectionWriter().

Here is the call graph for this function:

◆ ~TPEFResourceSectionWriter()

TPEF::TPEFResourceSectionWriter::~TPEFResourceSectionWriter ( )
protectedvirtual

Destructor.

Definition at line 70 of file TPEFResourceSectionWriter.cc.

70  {
71 }

◆ TPEFResourceSectionWriter() [2/2]

TPEF::TPEFResourceSectionWriter::TPEFResourceSectionWriter ( const TPEFResourceSectionWriter )
private

Copying not allowed.

Member Function Documentation

◆ actualWriteData()

void TPEF::TPEFResourceSectionWriter::actualWriteData ( BinaryStream stream,
const Section sect 
) const
protectedvirtual

Writes the data of the section in to stream.

Parameters
streamThe stream to be written to.
sectThe section to be written.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 90 of file TPEFResourceSectionWriter.cc.

92  {
93 
94  FileOffset startOffset = stream.writePosition();
95 
96  // file offset to body of section
98  FileOffsetKey(startOffset), sect->element(0));
99 
100  // set for checking multiple items
101  std::multiset<
102  std::pair<HalfWord, ResourceElement::ResourceType> > checkMultiple;
103 
104  for (Word i = 0; i < sect->elementCount(); i++) {
105  ResourceElement* elem =
106  dynamic_cast<ResourceElement*>(sect->element(i));
107 
108  assert(elem != NULL);
109 
110  // identification codes of resources must be unique among all
111  // resources of the same type
112  std::pair<HalfWord, ResourceElement::ResourceType>
113  pairToFind(elem->id(), elem->type());
114 
115  // TODO: check that OP, SR and PORT share the same id space and don't
116  // collide
117 
118  if (checkMultiple.find(pairToFind) != checkMultiple.end()) {
119  bool multipleResourcesWithSameIdAndType = false;
120  assert(multipleResourcesWithSameIdAndType);
121  } else {
122  checkMultiple.insert(pairToFind);
123  }
124 
125  stream.writeHalfWord(elem->id());
126  stream.writeByte(static_cast<Byte>(elem->type()));
127 
128  assert(elem->name() != NULL);
129 
130  SectionOffsetReplacer replacer(elem->name());
131  replacer.resolve();
132 
133  stream.writeWord(elem->info());
134  }
135  SectionSizeReplacer::setSize(sect, stream.writePosition() - startOffset);
136 }

References TPEF::ReferenceManager::SafePointer::addObjectReference(), assert, TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::ResourceElement::id(), TPEF::ResourceElement::info(), TPEF::ResourceElement::name(), TPEF::ValueReplacer::resolve(), TPEF::SectionSizeReplacer::setSize(), TPEF::ResourceElement::type(), TPEF::BinaryStream::writeByte(), TPEF::BinaryStream::writeHalfWord(), TPEF::BinaryStream::writePosition(), and TPEF::BinaryStream::writeWord().

Here is the call graph for this function:

◆ elementSize()

Word TPEF::TPEFResourceSectionWriter::elementSize ( const Section section) const
protectedvirtual

Returns the fixed size length of section elements.

Returns
The fixed size length of section elements.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 144 of file TPEFResourceSectionWriter.cc.

144  {
145  return elementSize_;
146 }

References elementSize_.

◆ operator=()

TPEFResourceSectionWriter TPEF::TPEFResourceSectionWriter::operator= ( const TPEFResourceSectionWriter )
private

Assignment not allowed.

◆ type()

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

Returns the section type this writer can write.

Returns
The section type writer can write.

Implements TPEF::TPEFSectionWriter.

Definition at line 79 of file TPEFResourceSectionWriter.cc.

79  {
80  return Section::ST_MR;
81 }

References TPEF::Section::ST_MR.

Member Data Documentation

◆ elementSize_

const Word TPEF::TPEFResourceSectionWriter::elementSize_ = 11
staticprivate

The fixed size element.

Definition at line 69 of file TPEFResourceSectionWriter.hh.

Referenced by elementSize().

◆ instance_

const TPEFResourceSectionWriter TPEF::TPEFResourceSectionWriter::instance_
staticprivate

An unique instance of class.

Definition at line 67 of file TPEFResourceSectionWriter.hh.


The documentation for this class was generated from the following files:
Byte
unsigned char Byte
Definition: BaseType.hh:116
TPEF::ReferenceManager::SafePointer::addObjectReference
static void addObjectReference(SectionIndexKey key, const SafePointable *obj)
Definition: SafePointer.cc:306
assert
#define assert(condition)
Definition: Application.hh:86
TPEF::SectionWriter::registerSectionWriter
static void registerSectionWriter(const SectionWriter *sWriter)
Definition: SectionWriter.cc:148
TPEF::FileOffset
Word FileOffset
Type for storing absolute file offsets.
Definition: TPEFBaseType.hh:52
TPEF::SectionSizeReplacer::setSize
static void setSize(const SafePointable *obj, Word size)
Definition: SectionSizeReplacer.cc:100
TPEF::TPEFResourceSectionWriter::elementSize_
static const Word elementSize_
The fixed size element.
Definition: TPEFResourceSectionWriter.hh:69
TPEF::Section::ST_MR
@ ST_MR
Machine resources section.
Definition: Section.hh:78
TPEF::TPEFSectionWriter::TPEFSectionWriter
TPEFSectionWriter()
Definition: TPEFSectionWriter.cc:63