Hurricane VLSI Database


Locator.h
1// ****************************************************************************************************
2// File: ./hurricane/Locator.h
3// Authors: R. Escassut
4// Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
5//
6// This file is part of Hurricane.
7//
8// Hurricane is free software: you can redistribute it and/or modify it under the terms of the GNU
9// Lesser General Public License as published by the Free Software Foundation, either version 3 of the
10// License, or (at your option) any later version.
11//
12// Hurricane is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
13// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
14// General Public License for more details.
15//
16// You should have received a copy of the Lesser GNU General Public License along with Hurricane. If
17// not, see <http://www.gnu.org/licenses/>.
18// ****************************************************************************************************
19
20#ifndef HURRICANE_LOCATOR
21#define HURRICANE_LOCATOR
22
23#include "hurricane/Commons.h"
24
25namespace Hurricane {
26
27
28
29// ****************************************************************************************************
30// Locator declaration
31// ****************************************************************************************************
32
33template<class Type> class Locator {
34// *********************************
35
36// Constructors
37// ************
38
39 protected: Locator()
40 // *****************
41 {
42 };
43
44 private: Locator(const Locator& locator);
45 // *******************************************
46 // not implemented to forbid copy construction
47 // *******************************************
48
49// Destructor
50// **********
51
52 public: virtual ~Locator()
53 // ***********************
54 {
55 };
56
57// Operators
58// *********
59
60 private: Locator& operator=(const Locator& locator);
61 // *************************************************
62 // not implemented to forbid assignment
63 // *************************************************
64
65// Accessors
66// *********
67
68 public: virtual Type getElement() const = 0;
69 public: virtual Locator<Type>* getClone() const = 0;
70
71 public: virtual Locator<Type>* getLocator() // 21-10-2003
72 // ****************************************
73 {
74 return ( this );
75 }
76
77// Predicates
78// **********
79
80 public: virtual bool isValid() const = 0;
81
82// Updators
83// ********
84
85 public: virtual void progress() = 0;
86
87// Others
88// ******
89
90 public: virtual string _getTypeName() const
91 // **************************************
92 {
93 return _TName("Locator");
94 };
95
96 public: virtual string _getString() const
97 // **************************************
98 {
99 if (!isValid())
100 return "<" + _getTypeName() + " invalid>";
101 else
102 return "<" + _getTypeName() + " " + getString(getElement()) + ">";
103 };
104
105};
106
107
108
109// ****************************************************************************************************
110// GenericLocator declaration
111// ****************************************************************************************************
112
113template<class Type> class GenericLocator : public Locator<Type> {
114// *************************************************************
115
116// Types
117// *****
118
119 public: typedef Locator<Type> Inherit;
120
121// Attributes
122// **********
123
124 private: Locator<Type>* _locator;
125
126// Constructors
127// ************
128
129 public: GenericLocator()
130 // *********************
131 : Inherit(),
132 _locator(NULL)
133 {
134 };
135
136 public: GenericLocator(const Locator<Type>& locator)
137 // *************************************************
138 : Inherit(),
139 _locator(locator.getClone())
140 {
141 };
142
143 public: GenericLocator(const GenericLocator& genericLocator)
144 // *********************************************************
145 : Inherit(),
146 _locator(genericLocator.getClone())
147 {
148 };
149
150 public: GenericLocator(Locator<Type>* locator)
151 // *******************************************************
152 // CAUTION : locator will be deleted by the GenericLocator
153 // *******************************************************
154 : Inherit(),
155 _locator(locator)
156 {
157 };
158
159// Destructor
160// **********
161
162 public: virtual ~GenericLocator()
163 // ******************************
164 {
165 if (_locator) delete _locator;
166 };
167
168// Operators
169// *********
170
171 public: GenericLocator& operator=(const Locator<Type>& locator)
172 // ************************************************************
173 {
174 if (_locator) delete _locator;
175 _locator = locator.getClone();
176 return *this;
177 };
178
179 public: GenericLocator& operator=(const GenericLocator& genericLocator)
180 // ********************************************************************
181 {
182 if (_locator) delete _locator;
183 _locator = genericLocator.getClone();
184 return *this;
185 };
186
187 public: GenericLocator& operator=(Locator<Type>* locator)
188 // *******************************************************
189 // CAUTION : locator will be deleted by the GenericLocator
190 // *******************************************************
191 {
192 if (_locator) delete _locator;
193 _locator = locator;
194 return *this;
195 };
196
197// Accessors
198// *********
199
200 public: virtual Type getElement() const
201 // ************************************
202 {
203 return ((_locator) ? _locator->getElement() : Type());
204 };
205
206 public: virtual Locator<Type>* getClone() const
207 // ********************************************
208 {
209 return ((_locator) ? _locator->getClone() : NULL);
210 };
211
212 public: virtual Locator<Type>* getLocator() // 21-10-2003
213 // ****************************************
214 {
215 return ( _locator->getLocator () );
216 }
217
218
219// Predicates
220// **********
221
222 public: virtual bool isValid() const
223 // *********************************
224 {
225 return (_locator && _locator->isValid());
226 };
227
228// Updators
229// ********
230
231 public: virtual void progress()
232 // ****************************
233 {
234 if (_locator) _locator->progress();
235 };
236
237// Others
238// ******
239
240 public: virtual string _getTypeName() const
241 // **************************************
242 {
243 return _TName("GenericLocator");
244 };
245
246 public: virtual string _getString() const
247 // **************************************
248 {
249 if (!_locator)
250 return "<" + _getTypeName() + " unbound>";
251 else
252 return "<" + _getTypeName() + " " + getString(_locator) + ">";
253 };
254
255};
256
257
258
259// ****************************************************************************************************
260// Generic functions
261// ****************************************************************************************************
262
263
264} // End of Hurricane namespace.
265
266
267#endif // HURRICANE_LOCATOR
268
269
270// ****************************************************************************************************
271// Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
272// ****************************************************************************************************
Generic Locator auto-pointer.
Definition Locator.h:113
GenericLocator(Locator< Type > *locator)
Definition Locator.h:150
GenericLocator(const Locator< Type > &locator)
Definition Locator.h:136
GenericLocator(const GenericLocator &genericLocator)
Definition Locator.h:143
virtual Type getElement() const =0
virtual bool isValid() const =0
virtual void progress()=0
virtual Locator< Type > * getClone() const =0
Contains Almost Everything.
Definition BasicLayer.h:39


Generated by doxygen 1.13.2 on Fri Sep 27 2024 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved