OpenASIP 2.2
Loading...
Searching...
No Matches
TPEFReader.hh
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 TPEFReader.hh
26 *
27 * Declaration of TPEFReader.
28 *
29 * @author Mikael Lepistö 2003 (tmlepist-no.spam-cs.tut.fi)
30 *
31 * @note rating: yellow
32 */
33
34#ifndef TTA_TPEF_READER_HH
35#define TTA_TPEF_READER_HH
36
37#include <map>
38
39#include "BinaryReader.hh"
40#include "Exception.hh"
41#include "TPEFBaseType.hh"
42
43namespace TPEF {
44 class BinaryStream;
45 class Binary;
46 class ASpaceElement;
47 class ASpaceSection;
48 class Section;
49/**
50 * Reads binary file that is in TPEF binary format.
51 */
52class TPEFReader : public BinaryReader {
53public:
56 AddressImage address) const;
57
58 static BinaryReader* instance();
59
62
63 void addSectionSize(const Section* sect, Word length);
64
66
67protected:
70
71 TPEFReader();
72 virtual ~TPEFReader();
73
74 virtual Binary* readData(BinaryStream& stream) const;
75
76 virtual bool isMyStreamType(BinaryStream& stream) const;
77
78private:
80 BinaryStream& stream,
81 FileOffset headerOffset,
82 Byte stringTableId,
83 Byte aSpaceSectionId) const;
84
85
86 /// Prototype instance registered into BinaryReader.
88
89 /// Last or currently read binary.
90 mutable Binary *binary_;
91 /// Identification code of address space section (there is only
92 /// one at maximum).
94 /// Identification code of string table containing section name strings.
96 /// Cache of sizes in addresses of read sections.
97 mutable std::map<const Section*, Word> sectionSizes_;
98};
99}
100
101#endif
UInt32 AddressImage
Type for storing addresses to memory image.
Definition BaseType.hh:179
unsigned char Byte
Definition BaseType.hh:116
TPEFReader(const TPEFReader &)
void addSectionSize(const Section *sect, Word length)
virtual bool isMyStreamType(BinaryStream &stream) const
Binary * binary_
Last or currently read binary.
Definition TPEFReader.hh:90
std::map< const Section *, Word > sectionSizes_
Cache of sizes in addresses of read sections.
Definition TPEFReader.hh:97
SectionId aSpaceId()
ASpaceSection * aSpaceSection() const
SectionId strTableId()
SectionId aSpaceId_
Identification code of address space section (there is only one at maximum).
Definition TPEFReader.hh:93
static TPEFReader * proto_
Prototype instance registered into BinaryReader.
Definition TPEFReader.hh:87
SectionId strTableId_
Identification code of string table containing section name strings.
Definition TPEFReader.hh:95
Section * readSection(BinaryStream &stream, FileOffset headerOffset, Byte stringTableId, Byte aSpaceSectionId) const
virtual Binary * readData(BinaryStream &stream) const
Definition TPEFReader.cc:94
virtual ~TPEFReader()
Definition TPEFReader.cc:73
static BinaryReader * instance()
Section * sectionOfAddress(const ASpaceElement *aSpaceId, AddressImage address) const
TPEFReader & operator=(const TPEFReader &)
HalfWord SectionId
Type for storing binary file section ids.
Word FileOffset
Type for storing absolute file offsets.