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

#include <TPEFDataSectionWriter.hh>

Inheritance diagram for TPEF::TPEFDataSectionWriter:
Inheritance graph
Collaboration diagram for TPEF::TPEFDataSectionWriter:
Collaboration graph

Protected Member Functions

virtual ~TPEFDataSectionWriter ()
 
 TPEFDataSectionWriter (bool reg=true)
 
virtual Section::SectionType type () const
 
virtual void actualWriteData (BinaryStream &stream, const Section *sect) 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

 TPEFDataSectionWriter (const TPEFDataSectionWriter &)
 No copies. More...
 
TPEFDataSectionWriter operator= (const TPEFDataSectionWriter &)
 No copies. More...
 

Static Private Attributes

static const TPEFDataSectionWriter instance_
 Only existing instance of class. 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 data section to TPEF stream.

Definition at line 48 of file TPEFDataSectionWriter.hh.

Constructor & Destructor Documentation

◆ ~TPEFDataSectionWriter()

TPEF::TPEFDataSectionWriter::~TPEFDataSectionWriter ( )
protectedvirtual

Destructor.

Definition at line 68 of file TPEFDataSectionWriter.cc.

68  {
69 }

◆ TPEFDataSectionWriter() [1/2]

TPEF::TPEFDataSectionWriter::TPEFDataSectionWriter ( bool  reg = true)
protected

Constructor.

Definition at line 59 of file TPEFDataSectionWriter.cc.

59  : TPEFSectionWriter() {
60  if (reg) {
62  }
63 }

References TPEF::SectionWriter::registerSectionWriter().

Here is the call graph for this function:

◆ TPEFDataSectionWriter() [2/2]

TPEF::TPEFDataSectionWriter::TPEFDataSectionWriter ( const TPEFDataSectionWriter )
private

No copies.

Member Function Documentation

◆ actualWriteData()

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

Writes section's data into stream.

Parameters
streamStream where to write.
sectSection to be written.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 88 of file TPEFDataSectionWriter.cc.

90  {
91 
92  const DataSection* dSection = dynamic_cast<const DataSection*>(sect);
93 
94  assert(dSection != NULL);
95 
96  FileOffset startOffset = stream.writePosition();
97 
98  SectionOffset sectOffset = 0;
99  SectionKey sKey = SafePointer::sectionKeyFor(dSection);
100  SectionId id = sKey.sectionId();
101 
102  for (; sectOffset < dSection->length(); sectOffset++) {
103 
104  Chunk* chunk = NULL;
105 
106  try {
107  chunk = dSection->chunk(sectOffset);
108  } catch (const NotChunkable& n) {
109  bool sectionToBeWrittenIsNotChunkable = false;
110  assert(sectionToBeWrittenIsNotChunkable);
111  }
112 
113  // if referenced or first element of section
114  if (SafePointer::isReferenced(chunk)) {
116  SectionOffsetKey(id, sectOffset), chunk);
117  }
118 
119  stream.writeByte(dSection->byte(chunk));
120  }
121 
122  // needed for writing section header
124  FileOffsetKey(startOffset), dSection->chunk(0));
125 
127  dSection, stream.writePosition() - startOffset);
128 }

References TPEF::ReferenceManager::SafePointer::addObjectReference(), assert, TPEF::DataSection::byte(), TPEF::RawSection::chunk(), TPEF::ReferenceManager::SafePointer::isReferenced(), TPEF::DataSection::length(), TPEF::ReferenceManager::SectionKey::sectionId(), TPEF::ReferenceManager::SafePointer::sectionKeyFor(), TPEF::SectionSizeReplacer::setSize(), TPEF::BinaryStream::writeByte(), and TPEF::BinaryStream::writePosition().

Here is the call graph for this function:

◆ elementSize()

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

Returns the fixed size of section elements, in this case smallest amount of bytes that is needed to store one MAU of address space.

Parameters
sectionSection which is written.
Returns
Size of uninitialized data element in bytes.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 138 of file TPEFDataSectionWriter.cc.

138  {
139  return static_cast<Word>(
140  ceil(static_cast<double>(section->aSpace()->MAU()) /
141  static_cast<double>(BYTE_BITWIDTH)));
142 }

References TPEF::Section::aSpace(), BYTE_BITWIDTH, and TPEF::ASpaceElement::MAU().

Here is the call graph for this function:

◆ operator=()

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

No copies.

◆ type()

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

Returns section type which for writer is implemented.

Returns
Section type which of section that class can write.

Implements TPEF::TPEFSectionWriter.

Reimplemented in TPEF::TPEFLEDataSectionWriter.

Definition at line 77 of file TPEFDataSectionWriter.cc.

77  {
78  return Section::ST_DATA;
79 }

References TPEF::Section::ST_DATA.

Member Data Documentation

◆ instance_

const TPEFDataSectionWriter TPEF::TPEFDataSectionWriter::instance_
staticprivate

Only existing instance of class.

Definition at line 68 of file TPEFDataSectionWriter.hh.


The documentation for this class was generated from the following files:
TPEF::SectionId
HalfWord SectionId
Type for storing binary file section ids.
Definition: TPEFBaseType.hh:43
TPEF::ReferenceManager::SafePointer::isReferenced
static bool isReferenced(const SafePointable *object)
Definition: SafePointer.cc:282
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::Section::ST_DATA
@ ST_DATA
Initialized data section.
Definition: Section.hh:80
TPEF::ReferenceManager::SafePointer::sectionKeyFor
static SectionKey sectionKeyFor(const SafePointable *obj)
Definition: SafePointer.cc:408
TPEF::FileOffset
Word FileOffset
Type for storing absolute file offsets.
Definition: TPEFBaseType.hh:52
TPEF::SectionOffset
Word SectionOffset
Type for storing offsets relative to a given base offset value.
Definition: TPEFBaseType.hh:49
TPEF::SectionSizeReplacer::setSize
static void setSize(const SafePointable *obj, Word size)
Definition: SectionSizeReplacer.cc:100
BYTE_BITWIDTH
const Byte BYTE_BITWIDTH
Definition: BaseType.hh:136
NotChunkable
Definition: Exception.hh:353
TPEF::TPEFSectionWriter::TPEFSectionWriter
TPEFSectionWriter()
Definition: TPEFSectionWriter.cc:63