OpenASIP  2.0
TPEFUDataSectionReader.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file TPEFUDataSectionReader.cc
26  *
27  * Definition of TPEFUDataSectionReader class.
28  *
29  * @author Mikael Lepistö 2003 (tmlepist-no.spam-cs.tut.fi)
30  *
31  * @note rating: yellow
32  */
33 
35 #include "SectionReader.hh"
36 #include "BaseType.hh"
37 #include "SafePointer.hh"
38 
39 #include "UDataSection.hh"
40 
41 namespace TPEF {
42 
43 using ReferenceManager::SafePointer;
44 using ReferenceManager::SectionIndexKey;
45 using std::string;
46 
47 TPEFUDataSectionReader TPEFUDataSectionReader::proto_;
48 
49 /**
50  * Constructor.
51  *
52  * Registers itself to SectionReader.
53  */
56 }
57 
58 /**
59  * Destructor.
60  */
62 }
63 
64 /**
65  * Returns the type of section it is meant to read.
66  *
67  * @return The type of section it can read.
68  */
71  return Section::ST_UDATA;
72 }
73 
74 /**
75  * Reads section data from TPEF binary file.
76  *
77  * @param stream Stream to be read from.
78  * @param section Section where the information is to be stored.
79  * @exception UnreachableStream If reading of section fails.
80  * @exception KeyAlreadyExists Key was in use when trying to register object.
81  * @exception EndOfFile If end of file were reached while it shouldn't.
82  * @exception OutOfRange Some of read values were out of range.
83  * @exception WrongSubclass Some class couldn't do what it was asked for.
84  * @exception UnexpectedValue If there was unexpected value when reading.
85  */
86 void
88  // base classes implementation must be called with these TPEF readers
89  TPEFSectionReader::readData(stream, section);
90 
91  UDataSection* uDataSection = dynamic_cast<UDataSection*>(section);
92  assert(uDataSection != NULL);
93 
94  // check that link section is defined properly
95  assert(header().linkId == 0);
96 
97  dynamic_cast<TPEFReader*>(
98  parent())->addSectionSize(section, header().bodyLength);
99 
100  uDataSection->setDataLength(header().bodyLength);
101 }
102 }
BaseType.hh
TPEF::RawSection::setDataLength
virtual void setDataLength(Word length)
Definition: Section.cc:253
TPEF::TPEFUDataSectionReader::TPEFUDataSectionReader
TPEFUDataSectionReader()
Definition: TPEFUDataSectionReader.cc:54
TPEF::TPEFUDataSectionReader::~TPEFUDataSectionReader
virtual ~TPEFUDataSectionReader()
Definition: TPEFUDataSectionReader.cc:61
TPEF::BinaryStream
Definition: BinaryStream.hh:59
SafePointer.hh
TPEFUDataSectionReader.hh
TPEF::Section
Definition: Section.hh:64
TPEF::TPEFUDataSectionReader::readData
virtual void readData(BinaryStream &stream, Section *section) const
Definition: TPEFUDataSectionReader.cc:87
assert
#define assert(condition)
Definition: Application.hh:86
TPEF::TPEFUDataSectionReader::proto_
static TPEFUDataSectionReader proto_
Prototype instance of TPEFUDataSectionReader to be registered to SectionReader.
Definition: TPEFUDataSectionReader.hh:58
TPEF::TPEFUDataSectionReader::type
virtual Section::SectionType type() const
Definition: TPEFUDataSectionReader.cc:70
TPEF::UDataSection
Definition: UDataSection.hh:47
SectionReader.hh
TPEF::SectionReader::registerSectionReader
static void registerSectionReader(const SectionReader *sReader)
Definition: SectionReader.cc:145
TPEF::TPEFSectionReader
Definition: TPEFSectionReader.hh:48
TPEF::Section::ST_UDATA
@ ST_UDATA
Uninitialized data section.
Definition: Section.hh:81
TPEF::TPEFSectionReader::parent
virtual BinaryReader * parent() const
Definition: TPEFSectionReader.cc:65
TPEF::TPEFSectionReader::readData
virtual void readData(BinaryStream &stream, Section *section) const
Definition: TPEFSectionReader.cc:86
TPEF::TPEFReader
Definition: TPEFReader.hh:52
UDataSection.hh
TPEF::Section::SectionType
SectionType
Definition: Section.hh:69
TPEF::TPEFSectionReader::header
static const Header & header()
Definition: TPEFSectionReader.cc:174
TPEF::TPEFSectionReader::Header::bodyLength
Word bodyLength
Definition: TPEFSectionReader.hh:70
TPEF
Definition: Assembler.hh:43