OpenASIP 2.2
Loading...
Searching...
No Matches
SectionReader.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 SectionReader.hh
26 *
27 * Declaration of SectionReader class.
28 *
29 * @author Mikael Lepistö 2003 (tmlepist-no.spam-cs.tut.fi)
30 *
31 * @note rating: yellow
32 */
33
34#ifndef TTA_SECTIONREADER_HH
35#define TTA_SECTIONREADER_HH
36
37#include <map>
38#include <utility>
39
40#include "Section.hh"
41#include "BinaryReader.hh"
42#include "Exception.hh"
43
44namespace TPEF {
45
46 class BinaryStream;
47
48/**
49 * Abstract base class for SectionReaders.
50 *
51 * Implements user friendly interface for registration and finding
52 * concrete SectionReader instances. Defines also interface for reading
53 * sections so there is no need to know interface or even type of concrete
54 * SectionReaders.
55 */
57public:
59
60 virtual ~SectionReader();
61
62 static void readSection(
63 BinaryStream& stream, Section* section, BinaryReader* reader);
64
65 static void finalizeBinary(
66 Binary *binaryToFinalize,
67 BinaryReader* reader);
68
69protected:
71
72 /// Does actual reading part for constructing section.
73 virtual void readData(BinaryStream& stream, Section* section) const = 0;
74
75 /// Returns binary reader whose sections actual section reader reads.
76 virtual BinaryReader* parent() const = 0;
77
78 /// Returns type (TPEF) section which actual section reader reads.
79 virtual Section::SectionType type() const = 0;
80
81 virtual void finalize(Section* section) const;
82
83 static const SectionReader* findSectionReader(
84 const Section::SectionType type, const BinaryReader* bReader);
85
86 static void registerSectionReader(const SectionReader* sReader);
87
88private:
89 /// Copying is not allowed.
91
92 /// Key type for finding values in map of section readers.
93 typedef
94 std::pair<const Section::SectionType, const BinaryReader*> MapKey;
95
96 /// Map type that contains instances of registered section readers.
97 typedef std::map<MapKey, const SectionReader*> MapType;
98
99 /// Contains section readers for all kinds of sections and all kinds of
100 /// binary formats that are supported.
102};
103}
104
105#endif
unsigned long Length
SectionReader(const SectionReader &)
Copying is not allowed.
virtual BinaryReader * parent() const =0
Returns binary reader whose sections actual section reader reads.
virtual void finalize(Section *section) const
static void registerSectionReader(const SectionReader *sReader)
static const SectionReader * findSectionReader(const Section::SectionType type, const BinaryReader *bReader)
std::map< MapKey, const SectionReader * > MapType
Map type that contains instances of registered section readers.
virtual Section::SectionType type() const =0
Returns type (TPEF) section which actual section reader reads.
virtual void readData(BinaryStream &stream, Section *section) const =0
Does actual reading part for constructing section.
static MapType * prototypes_
Contains section readers for all kinds of sections and all kinds of binary formats that are supported...
std::pair< const Section::SectionType, const BinaryReader * > MapKey
Key type for finding values in map of section readers.
static void finalizeBinary(Binary *binaryToFinalize, BinaryReader *reader)
static void readSection(BinaryStream &stream, Section *section, BinaryReader *reader)
BinaryReader::Length Length