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

#include <TPEFUDataSectionWriter.hh>

Inheritance diagram for TPEF::TPEFUDataSectionWriter:
Inheritance graph
Collaboration diagram for TPEF::TPEFUDataSectionWriter:
Collaboration graph

Protected Member Functions

 TPEFUDataSectionWriter ()
 
virtual ~TPEFUDataSectionWriter ()
 
virtual Section::SectionType type () const
 
virtual void createKeys (const Section *sect) const
 
virtual Word elementSize (const Section *section) const
 
virtual void writeSize (BinaryStream &stream, const Section *sect) 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 actualWriteData (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

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

Static Private Attributes

static const TPEFUDataSectionWriter instance_
 Unique instance of a 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 unitialized data section in to stream.

Actually implements only needed fall through methods for setting element size and section size to section header and for creating section offset keys for referred data chunks.

Definition at line 50 of file TPEFUDataSectionWriter.hh.

Constructor & Destructor Documentation

◆ TPEFUDataSectionWriter() [1/2]

TPEF::TPEFUDataSectionWriter::TPEFUDataSectionWriter ( )
protected

Constructor.

Registers itself to SectionWriter.

Definition at line 60 of file TPEFUDataSectionWriter.cc.

60  : TPEFSectionWriter() {
62 }

References TPEF::SectionWriter::registerSectionWriter().

Here is the call graph for this function:

◆ ~TPEFUDataSectionWriter()

TPEF::TPEFUDataSectionWriter::~TPEFUDataSectionWriter ( )
protectedvirtual

Destructor.

Definition at line 67 of file TPEFUDataSectionWriter.cc.

67  {
68 }

◆ TPEFUDataSectionWriter() [2/2]

TPEF::TPEFUDataSectionWriter::TPEFUDataSectionWriter ( const TPEFUDataSectionWriter )
private

Copying not allowed.

Member Function Documentation

◆ createKeys()

void TPEF::TPEFUDataSectionWriter::createKeys ( const Section sect) const
protectedvirtual

Creates keys to make able to reference UData chunks with section offsets.

Parameters
sectSection which for keys will be created.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 115 of file TPEFUDataSectionWriter.cc.

115  {
116  const UDataSection* uDSection = dynamic_cast<const UDataSection*>(sect);
117 
118  assert(uDSection != NULL);
119 
120  SectionOffset sectOffset = 0;
121  SectionKey sKey = SafePointer::sectionKeyFor(uDSection);
122  SectionId id = sKey.sectionId();
123 
124  // key for first element is always set
125  Chunk* chunk = uDSection->chunk(0);
126 
128  SectionOffsetKey(id, sectOffset), chunk);
129 
130  // go through requested chunks..
131  for (unsigned int i = 0; i < uDSection->referredChunkCount(); i++) {
132  try {
133  chunk = uDSection->referredChunk(i);
134  } catch (const NotChunkable& n) {
135  bool sectionToWriteIsNotChunkable = false;
136  assert(sectionToWriteIsNotChunkable);
137  }
138 
139  sectOffset = chunk->offset();
140 
141  // add section offset to element if really referenced element
142  if (SafePointer::isReferenced(chunk) && sectOffset != 0) {
144  SectionOffsetKey(id, sectOffset), chunk);
145  }
146  }
147 }

References TPEF::ReferenceManager::SafePointer::addObjectReference(), assert, TPEF::RawSection::chunk(), TPEF::ReferenceManager::SafePointer::isReferenced(), TPEF::Chunk::offset(), TPEF::RawSection::referredChunk(), TPEF::RawSection::referredChunkCount(), TPEF::ReferenceManager::SectionKey::sectionId(), and TPEF::ReferenceManager::SafePointer::sectionKeyFor().

Here is the call graph for this function:

◆ elementSize()

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

Returns the fixed size of section elements in bytes.

Size of element depends on address space of section.

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

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 89 of file TPEFUDataSectionWriter.cc.

89  {
90  return static_cast<Word>(
91  ceil(static_cast<double>(section->aSpace()->MAU()) /
92  BYTE_BITWIDTH));
93 }

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

Here is the call graph for this function:

◆ operator=()

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

Assignment not allowed.

◆ type()

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

Returns the type of section, that writer can write.

Returns
The type of the section, that writer can write.

Implements TPEF::TPEFSectionWriter.

Definition at line 76 of file TPEFUDataSectionWriter.cc.

76  {
77  return Section::ST_UDATA;
78 }

References TPEF::Section::ST_UDATA.

◆ writeSize()

void TPEF::TPEFUDataSectionWriter::writeSize ( BinaryStream stream,
const Section sect 
) const
protectedvirtual

Writes section's size into stream.

Parameters
streamStream to write.
sectSection which size to write.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 102 of file TPEFUDataSectionWriter.cc.

103  {
104 
105  const UDataSection* uSect = dynamic_cast<const UDataSection*>(sect);
106  stream.writeWord(uSect->length());
107 }

References TPEF::RawSection::length(), and TPEF::BinaryStream::writeWord().

Here is the call graph for this function:

Member Data Documentation

◆ instance_

const TPEFUDataSectionWriter TPEF::TPEFUDataSectionWriter::instance_
staticprivate

Unique instance of a class.

Definition at line 70 of file TPEFUDataSectionWriter.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::ReferenceManager::SafePointer::sectionKeyFor
static SectionKey sectionKeyFor(const SafePointable *obj)
Definition: SafePointer.cc:408
TPEF::Section::ST_UDATA
@ ST_UDATA
Uninitialized data section.
Definition: Section.hh:81
TPEF::SectionOffset
Word SectionOffset
Type for storing offsets relative to a given base offset value.
Definition: TPEFBaseType.hh:49
BYTE_BITWIDTH
const Byte BYTE_BITWIDTH
Definition: BaseType.hh:136
NotChunkable
Definition: Exception.hh:353
TPEF::TPEFSectionWriter::TPEFSectionWriter
TPEFSectionWriter()
Definition: TPEFSectionWriter.cc:63