OpenASIP  2.0
ReferenceKey.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 ReferenceKey.hh
26  *
27  * Declarations of different key types used in reference managing.
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 #ifndef TTA_REFERENCEKEY_HH
35 #define TTA_REFERENCEKEY_HH
36 
37 #include "TPEFBaseType.hh"
38 
39 namespace TPEF {
40 namespace ReferenceManager {
41 
42 //////////////////////////////////////////////////////////////////////////////
43 // ReferenceKey
44 //////////////////////////////////////////////////////////////////////////////
45 
46 /**
47  * Base (interface) class for all keys that identify objects in
48  * reference manager.
49  */
50 class ReferenceKey {
51 public:
52  virtual ~ReferenceKey();
53 protected:
54  ReferenceKey();
55 };
56 
57 //////////////////////////////////////////////////////////////////////////////
58 // SectionIndexKey
59 //////////////////////////////////////////////////////////////////////////////
60 
61 /**
62  * With this type of key one can identify an object by means of a section
63  * identification code and the index of the element in the section.
64  */
65 class SectionIndexKey : public ReferenceKey {
66 public:
68  virtual ~SectionIndexKey();
69 
70  bool operator==(const SectionIndexKey& other) const;
71  bool operator!=(const SectionIndexKey& other) const;
72  bool operator<(const SectionIndexKey& other) const;
73 
74  SectionId sectionId() const;
75  SectionIndex index() const;
76 
77 private:
78  /// Section Identification code of the section that contains the element
79  /// this key points to.
81  /// Index of the element this key points to.
83 };
84 
85 //////////////////////////////////////////////////////////////////////////////
86 // SectionOffsetKey
87 //////////////////////////////////////////////////////////////////////////////
88 
89 /**
90  * With this type of keys one can identify objects by means of a section
91  * identification code and a byte offset in the section.
92  */
94 public:
96  virtual ~SectionOffsetKey();
97 
98  SectionId sectionId() const;
99  SectionOffset offset() const;
100 
101  bool operator==(const SectionOffsetKey& other) const;
102  bool operator!=(const SectionOffsetKey& other) const;
103  bool operator<(const SectionOffsetKey& other) const;
104 
105 private:
106  /// Identification code of the section that contains the element this
107  /// key points to.
109  /// Byte offset relative to section start to the element this key points
110  /// to.
112 };
113 
114 //////////////////////////////////////////////////////////////////////////////
115 // FileOffsetKey
116 //////////////////////////////////////////////////////////////////////////////
117 
118 /**
119  * With this type of key one can identify objects with its file offset.
120  */
121 class FileOffsetKey : public ReferenceKey {
122 public:
124  virtual ~FileOffsetKey();
125 
126  bool operator==(const FileOffsetKey& other) const;
127  bool operator!=(const FileOffsetKey& other) const;
128  bool operator<(const FileOffsetKey& other) const;
129 
130  FileOffset fileOffset() const;
131 
132 private:
133  /// File offset of the element this key points to.
135 };
136 
137 ///////////////////////////////////////////////////////////////////////////////
138 // SectionKey
139 ///////////////////////////////////////////////////////////////////////////////
140 
141 /**
142  * With this type of key one can identify (section) objects with an
143  * arbitrary numeric code that is unique among all objects.
144  */
145 class SectionKey : public ReferenceKey {
146 public:
147 
149  virtual ~SectionKey();
150 
151  bool operator==(const SectionKey& other) const;
152  bool operator!=(const SectionKey& other) const;
153  bool operator<(const SectionKey& other) const;
154 
155  SectionId sectionId() const;
156 
157 private:
158  /// Identification code of the section that contains the element this
159  /// key points to.
161 };
162 
163 } // namespace ReferenceManager
164 }
165 
166 #include "ReferenceKey.icc"
167 
168 #endif
169 
TPEF::SectionId
HalfWord SectionId
Type for storing binary file section ids.
Definition: TPEFBaseType.hh:43
TPEF::ReferenceManager::FileOffsetKey::fileOffset
FileOffset fileOffset() const
TPEF::ReferenceManager::SectionIndexKey::SectionIndexKey
SectionIndexKey(SectionId sectionId, SectionIndex index)
Definition: ReferenceKey.cc:67
TPEF::ReferenceManager::SectionOffsetKey::offset
SectionOffset offset() const
TPEF::ReferenceManager::SectionIndexKey::operator<
bool operator<(const SectionIndexKey &other) const
TPEF::ReferenceManager::SectionOffsetKey::SectionOffsetKey
SectionOffsetKey(SectionId sectionId, SectionOffset offset)
Definition: ReferenceKey.cc:87
TPEF::ReferenceManager::SectionKey::operator==
bool operator==(const SectionKey &other) const
TPEF::ReferenceManager::SectionIndexKey::index
SectionIndex index() const
TPEF::ReferenceManager::SectionIndexKey::operator!=
bool operator!=(const SectionIndexKey &other) const
TPEF::ReferenceManager::FileOffsetKey::FileOffsetKey
FileOffsetKey(FileOffset fileOffset)
Definition: ReferenceKey.cc:106
TPEF::ReferenceManager::FileOffsetKey::operator<
bool operator<(const FileOffsetKey &other) const
TPEF::ReferenceManager::SectionOffsetKey::sectionId_
SectionId sectionId_
Identification code of the section that contains the element this key points to.
Definition: ReferenceKey.hh:108
TPEF::ReferenceManager::ReferenceKey::~ReferenceKey
virtual ~ReferenceKey()
Definition: ReferenceKey.cc:54
TPEF::ReferenceManager::SectionKey::operator!=
bool operator!=(const SectionKey &other) const
TPEF::ReferenceManager::SectionKey::sectionId
SectionId sectionId() const
TPEF::ReferenceManager::SectionIndexKey::index_
SectionIndex index_
Index of the element this key points to.
Definition: ReferenceKey.hh:82
TPEF::ReferenceManager::SectionIndexKey::operator==
bool operator==(const SectionIndexKey &other) const
TPEF::ReferenceManager::SectionOffsetKey::offset_
SectionOffset offset_
Byte offset relative to section start to the element this key points to.
Definition: ReferenceKey.hh:111
TPEF::ReferenceManager::SectionIndexKey
Definition: ReferenceKey.hh:65
TPEF::ReferenceManager::SectionIndexKey::~SectionIndexKey
virtual ~SectionIndexKey()
Definition: ReferenceKey.cc:74
TPEF::ReferenceManager::FileOffsetKey::operator!=
bool operator!=(const FileOffsetKey &other) const
TPEF::ReferenceManager::FileOffsetKey::fileOffset_
FileOffset fileOffset_
File offset of the element this key points to.
Definition: ReferenceKey.hh:134
TPEF::ReferenceManager::SectionKey::operator<
bool operator<(const SectionKey &other) const
TPEF::ReferenceManager::SectionOffsetKey::sectionId
SectionId sectionId() const
TPEF::ReferenceManager::FileOffsetKey::~FileOffsetKey
virtual ~FileOffsetKey()
Definition: ReferenceKey.cc:113
TPEF::ReferenceManager::SectionIndexKey::sectionId
SectionId sectionId() const
TPEF::ReferenceManager::SectionOffsetKey::operator!=
bool operator!=(const SectionOffsetKey &other) const
TPEF::ReferenceManager::SectionKey::sectionId_
SectionId sectionId_
Identification code of the section that contains the element this key points to.
Definition: ReferenceKey.hh:160
TPEF::FileOffset
Word FileOffset
Type for storing absolute file offsets.
Definition: TPEFBaseType.hh:52
TPEF::ReferenceManager::ReferenceKey::ReferenceKey
ReferenceKey()
Definition: ReferenceKey.cc:48
ReferenceKey.icc
TPEF::ReferenceManager::SectionOffsetKey::operator<
bool operator<(const SectionOffsetKey &other) const
TPEF::SectionOffset
Word SectionOffset
Type for storing offsets relative to a given base offset value.
Definition: TPEFBaseType.hh:49
TPEF::ReferenceManager::SectionKey
Definition: ReferenceKey.hh:145
TPEF::ReferenceManager::FileOffsetKey
Definition: ReferenceKey.hh:121
TPEF::ReferenceManager::ReferenceKey
Definition: ReferenceKey.hh:50
TPEF::ReferenceManager::SectionIndexKey::sectionId_
SectionId sectionId_
Section Identification code of the section that contains the element this key points to.
Definition: ReferenceKey.hh:80
TPEF::ReferenceManager::SectionKey::~SectionKey
virtual ~SectionKey()
Definition: ReferenceKey.cc:132
TPEF::ReferenceManager::SectionOffsetKey::~SectionOffsetKey
virtual ~SectionOffsetKey()
Definition: ReferenceKey.cc:94
TPEF::ReferenceManager::SectionOffsetKey
Definition: ReferenceKey.hh:93
TPEF::ReferenceManager::SectionKey::SectionKey
SectionKey(SectionId sectionId)
Definition: ReferenceKey.cc:125
TPEF::ReferenceManager::SectionOffsetKey::operator==
bool operator==(const SectionOffsetKey &other) const
TPEFBaseType.hh
TPEF::SectionIndex
Word SectionIndex
Type for storing section indexes.
Definition: TPEFBaseType.hh:46
TPEF::ReferenceManager::FileOffsetKey::operator==
bool operator==(const FileOffsetKey &other) const
TPEF
Definition: Assembler.hh:43