OpenASIP  2.0
TPEFNullSectionWriter.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 TPEFNullSectionWriter.cc
26  *
27  * Definitions of TPEFNullSectionWriter class.
28  *
29  * @author Mikael Lepistö 2004 (tmlepist-no.spam-cs.tut.fi)
30  *
31  * @note rating: yellow
32  */
33 
34 #include "TPEFNullSectionWriter.hh"
35 #include "Exception.hh"
36 #include "SectionSizeReplacer.hh"
37 #include "TPEFBaseType.hh"
38 #include "ReferenceKey.hh"
39 #include "SafePointer.hh"
40 #include "BinaryStream.hh"
41 
42 namespace TPEF {
43 
44 using ReferenceManager::SafePointer;
45 using ReferenceManager::FileOffsetKey;
46 
47 const TPEFNullSectionWriter TPEFNullSectionWriter::instance_;
48 
49 /**
50  * Constructor.
51  *
52  * Registers itself to SectionWriter.
53  */
56 }
57 
58 /**
59  * Destructor.
60  */
62 }
63 
64 /**
65  * Returns which type of sections can be written out by this writer.
66  *
67  * @return The type of section that writer can write out.
68  */
71  return Section::ST_NULL;
72 }
73 
74 /**
75  * Returns the size of section elements. The null section has no elements,
76  * so the size of elements is undefined. Returns always zero.
77  *
78  * @param section Section whose element size is to be written out (not used).
79  * @return Zero.
80  */
81 Word
83  return 0;
84 }
85 
86 /**
87  * Returns the identification code of the section.
88  *
89  * Zero is the numeric code reserved for identifying null sections.
90  *
91  * @return Zero.
92  */
95  return 0;
96 }
97 
98 /**
99  * Writes the size of a null section into an output stream.
100  *
101  * The size of a null section is always zero.
102  *
103  * @param stream Output stream.
104  * @param sect Section whose size has to be written out (not used).
105  */
106 void
108  const Section*) const {
109 
110  stream.writeWord(0);
111 }
112 
113 }
TPEF::SectionId
HalfWord SectionId
Type for storing binary file section ids.
Definition: TPEFBaseType.hh:43
SectionSizeReplacer.hh
TPEF::TPEFNullSectionWriter::type
virtual Section::SectionType type() const
Definition: TPEFNullSectionWriter.cc:70
Exception.hh
TPEF::BinaryStream::writeWord
void writeWord(Word word)
Definition: BinaryStream.cc:368
TPEF::TPEFNullSectionWriter::getSectionId
virtual SectionId getSectionId() const
Definition: TPEFNullSectionWriter.cc:94
TPEF::BinaryStream
Definition: BinaryStream.hh:59
SafePointer.hh
TPEF::TPEFNullSectionWriter::TPEFNullSectionWriter
TPEFNullSectionWriter()
Definition: TPEFNullSectionWriter.cc:54
TPEFNullSectionWriter.hh
TPEF::Section
Definition: Section.hh:64
TPEF::TPEFNullSectionWriter::~TPEFNullSectionWriter
virtual ~TPEFNullSectionWriter()
Definition: TPEFNullSectionWriter.cc:61
TPEF::TPEFNullSectionWriter::instance_
static const TPEFNullSectionWriter instance_
Unique instance of a class.
Definition: TPEFNullSectionWriter.hh:65
TPEF::SectionWriter::registerSectionWriter
static void registerSectionWriter(const SectionWriter *sWriter)
Definition: SectionWriter.cc:148
BinaryStream.hh
TPEF::Section::SectionType
SectionType
Definition: Section.hh:69
TPEF::TPEFNullSectionWriter::writeSize
virtual void writeSize(BinaryStream &stream, const Section *sect) const
Definition: TPEFNullSectionWriter.cc:107
TPEF::Section::ST_NULL
@ ST_NULL
NULL Section.
Definition: Section.hh:70
TPEFBaseType.hh
ReferenceKey.hh
TPEF::TPEFNullSectionWriter::elementSize
virtual Word elementSize(const Section *section) const
Definition: TPEFNullSectionWriter.cc:82
TPEF::TPEFSectionWriter
Definition: TPEFSectionWriter.hh:49
TPEF
Definition: Assembler.hh:43