OpenASIP  2.0
ReferenceKey.icc
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 ReferenceKey.icc
26  *
27  * Inline and template functions for ReferenceKey classes.
28  *
29  * @author Pekka Jääskeläinen 2003 (pjaaskel-no.spam-cs.tut.fi)
30  * @note reviewed 17 Oct 2003 by am, rm, kl
31  *
32  * @note rating: yellow
33  */
34 
35 namespace TPEF {
36 namespace ReferenceManager {
37 ///////////////////////////////////////////////////////////////////////////////
38 // SectionIndexKey
39 ///////////////////////////////////////////////////////////////////////////////
40 
41 /**
42  * Returns the section identification code for this key.
43  *
44  * @return Section identification code.
45  */
46 inline SectionId
47 SectionIndexKey::sectionId() const {
48  return sectionId_;
49 }
50 
51 /**
52  * Returns the index this key is set to.
53  *
54  * @return Index.
55  */
56 inline SectionIndex
57 SectionIndexKey::index() const {
58  return index_;
59 }
60 
61 /**
62  * Equality operator for SectionIndexKey.
63  *
64  * @param other Another key to compare to.
65  * @return True if the keys have same data.
66  */
67 inline bool
68 SectionIndexKey::operator==(const SectionIndexKey& other) const {
69  return sectionId_ == other.sectionId_ && index_ == other.index_;
70 }
71 
72 /**
73  * Inequality operator for SectionIndexKey.
74  *
75  * @param other Another key to compare to.
76  * @return True if the keys don't have same data.
77  */
78 inline bool
79 SectionIndexKey::operator!=(const SectionIndexKey& other) const {
80  return !(*this == other);
81 }
82 
83 /**
84  * Smaller than operator for SectionIndexKey.
85  *
86  * @param other Another key to compare to.
87  * @return True if the keys don't have same data.
88  */
89 inline bool
90 SectionIndexKey::operator<(const SectionIndexKey& other) const {
91  return (sectionId_ < other.sectionId_) ||
92  (sectionId_ == other.sectionId_ &&
93  index_ < other.index_);
94 }
95 
96 ///////////////////////////////////////////////////////////////////////////////
97 // SectionOffsetKey
98 ///////////////////////////////////////////////////////////////////////////////
99 
100 /**
101  * Returns the section identification code for this key.
102  *
103  * @return Section identification code.
104  */
105 inline SectionId
106 SectionOffsetKey::sectionId() const {
107  return sectionId_;
108 }
109 
110 /**
111  * Returns the offset this key is set to.
112  *
113  * @return Offset.
114  */
115 inline SectionOffset
116 SectionOffsetKey::offset() const {
117  return offset_;
118 }
119 
120 /**
121  * Equality operator for SectionOffsetKey.
122  *
123  * @param other Another key to compare to.
124  * @return True if the keys have same data.
125  */
126 inline bool
127 SectionOffsetKey::operator==(const SectionOffsetKey& other) const {
128  return sectionId_ == other.sectionId_ && offset_ == other.offset_;
129 }
130 
131 /**
132  * Inequality operator for SectionOffsetKey.
133  *
134  * @param other Another key to compare to.
135  * @return True if the keys don't have same data.
136  */
137 inline bool
138 SectionOffsetKey::operator!=(const SectionOffsetKey& other) const {
139  return !(*this == other);
140 }
141 
142 /**
143  * Smaller than operator for SectionOffsetKey.
144  *
145  * @param other Another key to compare to.
146  * @return True if the keys don't have same data.
147  */
148 inline bool
149 SectionOffsetKey::operator<(const SectionOffsetKey& other) const {
150  return (sectionId_ < other.sectionId_) ||
151  (sectionId_ == other.sectionId_ &&
152  offset_ < other.offset_);
153 }
154 
155 ///////////////////////////////////////////////////////////////////////////////
156 // FileOffsetKey
157 ///////////////////////////////////////////////////////////////////////////////
158 
159 /**
160  * Returns the file offset this key is set to.
161  *
162  * @return File offset.
163  */
164 inline FileOffset
165 FileOffsetKey::fileOffset() const {
166  return fileOffset_;
167 }
168 
169 /**
170  * Equality operator for FileOffsetKey.
171  *
172  * @param other Another key to compare to.
173  * @return True if the keys have same data.
174  */
175 inline bool
176 FileOffsetKey::operator==(const FileOffsetKey& other) const {
177  return fileOffset_ == other.fileOffset_;
178 }
179 
180 /**
181  * Inequality operator for FileOffsetKey.
182  *
183  * @param other Another key to compare to.
184  * @return True if the keys don't have same data.
185  */
186 inline bool
187 FileOffsetKey::operator!=(const FileOffsetKey& other) const {
188  return !(*this == other);
189 }
190 
191 /**
192  * Smaller than operator for FileOffsetKey.
193  *
194  * @param other Another key to compare to.
195  * @return True if the keys don't have same data.
196  */
197 inline bool
198 FileOffsetKey::operator<(const FileOffsetKey& other) const {
199  return (fileOffset_ < other.fileOffset_);
200 }
201 
202 ///////////////////////////////////////////////////////////////////////////////
203 // SectionKey
204 ///////////////////////////////////////////////////////////////////////////////
205 
206 /**
207  * Returns the section identification code for this key.
208  *
209  * @return Section identification code.
210  */
211 inline SectionId
212 SectionKey::sectionId() const {
213  return sectionId_;
214 }
215 
216 /**
217  * Equality operator for SectionKey.
218  *
219  * @param other Another key to compare to.
220  * @return True if the keys have same data.
221  */
222 inline bool
223 SectionKey::operator==(const SectionKey& other) const {
224  return sectionId_ == other.sectionId_;
225 }
226 
227 /**
228  * Inequality operator for SectionKey.
229  *
230  * @param other Another key to compare to.
231  * @return True if the keys don't have same data.
232  */
233 inline bool
234 SectionKey::operator!=(const SectionKey& other) const {
235  return !(*this == other);
236 }
237 
238 /**
239  * Smaller than operator for SectionKey.
240  *
241  * @param other Another key to compare to.
242  * @return True if the keys don't have same data.
243  */
244 inline bool
245 SectionKey::operator<(const SectionKey& other) const {
246  return sectionId_ < other.sectionId_;
247 }
248 
249 } // namespace ReferenceManager
250 
251 }