35 #include "hurricane/Commons.h"
36 #include "hurricane/Box.h"
37 #include "hurricane/Transformation.h"
38 #include "hurricane/Cell.h"
39 #include "hurricane/Instance.h"
54 inline QueryState ( Locator<Instance*>* locator );
55 inline QueryState ( Locator<Instance*>* locator
57 ,
const Transformation& transformation
60 QueryState (
const QueryState& );
61 QueryState& operator= (
const QueryState& );
62 inline ~QueryState ();
64 Locator<Instance*>* _locator;
66 Transformation _transformation;
69 friend class QueryStack;
76 inline QueryState::QueryState ( Locator<Instance*>* locator )
84 inline QueryState::QueryState ( Locator<Instance*>* locator
86 ,
const Transformation& transformation
91 , _transformation(transformation)
96 inline QueryState::~QueryState ()
98 if ( _locator )
delete _locator;
106 class QueryStack :
public vector<QueryState*> {
112 inline Cell* getTopCell ();
113 inline const Box& getTopArea ()
const;
114 inline const Transformation& getTopTransformation ()
const;
115 inline unsigned int getStartLevel ()
const;
116 inline unsigned int getStopLevel ()
const;
117 inline Cell::Flags getStopCellFlags ()
const;
118 inline Cell* getMasterCell ();
119 inline Instance* getInstance ();
120 inline const Box& getArea ()
const;
121 inline DbU::Unit getThreshold ()
const;
122 inline const Transformation& getTransformation ()
const;
123 inline const Path& getPath ()
const;
126 inline void setTopCell ( Cell* cell );
127 inline void setTopArea (
const Box& area );
128 inline void setTopTransformation (
const Transformation& transformation );
129 inline void setThreshold ( DbU::Unit threshold );
130 inline void setStartLevel (
unsigned int level );
131 inline void setStopLevel (
unsigned int level );
132 inline void setStopCellFlags ( Cell::Flags );
133 inline void unsetStopCellFlags ( Cell::Flags );
135 inline void updateTransformation ();
136 inline bool levelDown ();
137 inline void levelUp ();
138 inline void levelProgress ();
139 inline bool levelCompleted ();
140 inline void progress (
bool init=
false );
141 inline size_t getInstanceCount ()
const;
148 DbU::Unit _threshold;
149 Transformation _topTransformation;
150 unsigned int _startLevel;
151 unsigned int _stopLevel;
152 Cell::Flags _stopCellFlags;
153 size_t _instanceCount;
157 QueryStack (
const QueryStack& );
158 QueryStack& operator= (
const QueryStack& );
165 inline Cell* QueryStack::getTopCell () {
return _topCell; }
166 inline const Box& QueryStack::getTopArea ()
const {
return _topArea; }
167 inline const Transformation& QueryStack::getTopTransformation ()
const {
return _topTransformation; }
168 inline DbU::Unit QueryStack::getThreshold ()
const {
return _threshold; }
169 inline unsigned int QueryStack::getStartLevel ()
const {
return _startLevel; }
170 inline unsigned int QueryStack::getStopLevel ()
const {
return _stopLevel; }
171 inline Cell::Flags QueryStack::getStopCellFlags ()
const {
return _stopCellFlags; }
172 inline const Box& QueryStack::getArea ()
const {
return back()->_area; }
173 inline const Transformation& QueryStack::getTransformation ()
const {
return back()->_transformation; }
174 inline const Path& QueryStack::getPath ()
const {
return back()->_path; }
176 inline size_t QueryStack::getInstanceCount ()
const {
return _instanceCount; }
179 inline Instance* QueryStack::getInstance ()
181 if ( levelCompleted() )
return NULL;
182 return back()->_locator->getElement();
186 inline Cell* QueryStack::getMasterCell ()
188 if ( size() == 1 )
return _topCell;
189 if ( !getInstance() )
return NULL;
190 return getInstance()->getMasterCell();
194 inline void QueryStack::setTopCell ( Cell* cell ) { _topCell = cell; }
195 inline void QueryStack::setTopArea (
const Box& area ) { _topArea = area; }
196 inline void QueryStack::setTopTransformation (
const Transformation& transformation ) { _topTransformation = transformation; }
197 inline void QueryStack::setThreshold ( DbU::Unit threshold ) { _threshold = threshold; }
198 inline void QueryStack::setStartLevel (
unsigned int level ) { _startLevel = level; }
199 inline void QueryStack::setStopLevel (
unsigned int level ) { _stopLevel = level; }
200 inline void QueryStack::setStopCellFlags ( Cell::Flags flags ) { _stopCellFlags = flags; }
201 inline void QueryStack::unsetStopCellFlags ( Cell::Flags flags ) { _stopCellFlags.reset(flags); }
204 inline void QueryStack::init ()
207 while (not empty()) levelUp();
209 push_back(
new QueryState(NULL,_topArea,_topTransformation,Path()) );
216 inline void QueryStack::updateTransformation ()
218 QueryState* child = *(rbegin() );
219 QueryState* parent = *(rbegin()+1);
220 Instance* instance = child->_locator->getElement();
224 child->_area = parent->_area;
225 child->_transformation = instance->getTransformation ();
227 instance->getTransformation().getInvert().applyOn ( child->_area );
228 parent->_transformation.applyOn ( child->_transformation );
231 child->_path = Path ( parent->_path, instance );
236 inline bool QueryStack::levelDown ()
238 if (size() > _stopLevel)
return false;
239 if (getMasterCell()->getFlags().isset(_stopCellFlags))
return false;
242 Locator<Instance*>* locator =
243 getMasterCell()->getInstancesUnder(getArea(),getThreshold()).getLocator();
245 if ( locator->isValid() ) {
246 push_back (
new QueryState ( locator ) );
248 updateTransformation ();
260 inline void QueryStack::levelUp ()
268 inline bool QueryStack::levelCompleted ()
270 if ( !back()->_locator || !back()->_locator->isValid () )
return true;
275 inline void QueryStack::levelProgress ()
277 if (levelCompleted())
return;
279 back()->_locator->progress();
280 if (not back()->_locator->isValid())
return;
284 updateTransformation();
288 inline void QueryStack::progress (
bool init )
290 if (not init) levelProgress ();
292 if (not levelDown() and (size() > _startLevel))
296 while (not empty()) {
297 if (levelCompleted()) {
300 if (levelDown())
continue;
303 if (size() > _startLevel)
return;
315 typedef Hurricane::Mask<uint64_t> Mask;
319 , DoTerminalCells = 2
323 , DoExtensionGos = 32
324 , DoAll = DoMasterCells
336 inline unsigned int getStartLevel ()
const;
337 inline unsigned int getStopLevel ()
const;
338 inline Cell::Flags getStopCellFlags ()
const;
339 inline size_t getDepth ()
const;
341 inline const Box& getTopArea ()
const;
342 inline const Box& getArea ()
const;
344 inline const BasicLayer* getBasicLayer ()
const;
345 inline Cell* getMasterCell ();
347 inline Path getPath ()
const;
364 , ExtensionSlice::Mask extensionMask
368 inline void setCell (
Cell* cell );
369 inline void setArea (
const Box& area );
370 inline void setThreshold (
DbU::Unit threshold );
371 inline void setTransformation (
const Transformation& transformation );
373 inline void setExtensionMask ( ExtensionSlice::Mask mode );
374 inline void setFilter ( Mask mode );
375 inline void setStartLevel (
unsigned int level );
376 inline void setStopLevel (
unsigned int level );
377 inline void setStopCellFlags ( Cell::Flags );
378 inline void unsetStopCellFlags ( Cell::Flags );
385 ExtensionSlice::Mask _extensionMask;
392 inline void Query::setCell (
Cell* cell ) { _stack.setTopCell(cell); }
393 inline void Query::setArea (
const Box& area ) { _stack.setTopArea(area); }
394 inline void Query::setThreshold (
DbU::Unit threshold ) { _stack.setThreshold(threshold); }
395 inline void Query::setTransformation (
const Transformation& transformation ) { _stack.setTopTransformation(transformation); }
396 inline void Query::setFilter ( Mask filter ) { _filter = filter; }
397 inline void Query::setExtensionMask ( ExtensionSlice::Mask mask ) { _extensionMask = mask; }
398 inline void Query::setStartLevel (
unsigned int level ) { _stack.setStartLevel(level); }
399 inline void Query::setStopLevel (
unsigned int level ) { _stack.setStopLevel(level); }
400 inline void Query::setStopCellFlags ( Cell::Flags flags ) { _stack.setStopCellFlags(flags); }
401 inline void Query::unsetStopCellFlags ( Cell::Flags flags ) { _stack.unsetStopCellFlags(flags); }
403 inline unsigned int Query::getStartLevel ()
const {
return _stack.getStartLevel(); }
404 inline unsigned int Query::getStopLevel ()
const {
return _stack.getStopLevel(); }
405 inline Cell::Flags Query::getStopCellFlags ()
const {
return _stack.getStopCellFlags(); }
406 inline size_t Query::getDepth ()
const {
return _stack.size(); }
407 inline const Box& Query::getTopArea ()
const {
return _stack.getTopArea(); }
408 inline const Box& Query::getArea ()
const {
return _stack.getArea(); }
410 inline Path Query::getPath ()
const {
return _stack.getPath(); }
411 inline const BasicLayer* Query::getBasicLayer ()
const {
return _basicLayer; }
412 inline Cell* Query::getMasterCell () {
return _stack.getMasterCell(); }
413 inline Instance* Query::getInstance () {
return _stack.getInstance(); }
420 INSPECTOR_PR_SUPPORT(Hurricane::Query::Mask);
BasicLayer description (API)
Definition: BasicLayer.h:42
Box description (API)
Definition: Box.h:29
The model (API).
Definition: Cell.h:64
std::int64_t Unit
Definition: DbU.h:67
Go description (API)
Definition: Go.h:34
Instance description (API)
Definition: Instance.h:35
Path description (API)
Definition: Path.h:35
Query description (API)
Definition: Query.h:313
QueryFilter
Definition: Query.h:318
virtual void markerCallback(Marker *)
virtual bool hasMarkerCallback() const
virtual void goCallback(Go *)=0
virtual bool hasRubberCallback() const
void setQuery(Cell *cell, const Box &area, const Transformation &transformation, const BasicLayer *basicLayer, ExtensionSlice::Mask extensionMask, Mask filter, DbU::Unit threshold=0)
virtual void extensionGoCallback(Go *)=0
virtual bool hasMasterCellCallback() const
virtual void masterCellCallback()=0
virtual bool hasExtensionGoCallback() const
virtual void setBasicLayer(const BasicLayer *basicLayer)
virtual void rubberCallback(Rubber *)
virtual bool hasGoCallback() const
Rubber description (API)
Definition: Rubber.h:36
Contains Almost Everything.
Definition: BasicLayer.h:39