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 );
134 inline void updateTransformation ();
135 inline bool levelDown ();
136 inline void levelUp ();
137 inline void levelProgress ();
138 inline bool levelCompleted ();
139 inline void progress (
bool init=
false );
140 inline size_t getInstanceCount ()
const;
147 DbU::Unit _threshold;
148 Transformation _topTransformation;
149 unsigned int _startLevel;
150 unsigned int _stopLevel;
151 Cell::Flags _stopCellFlags;
152 size_t _instanceCount;
156 QueryStack (
const QueryStack& );
157 QueryStack& operator= (
const QueryStack& );
164 inline Cell* QueryStack::getTopCell () {
return _topCell; }
165 inline const Box& QueryStack::getTopArea ()
const {
return _topArea; }
166 inline const Transformation& QueryStack::getTopTransformation ()
const {
return _topTransformation; }
167 inline DbU::Unit QueryStack::getThreshold ()
const {
return _threshold; }
168 inline unsigned int QueryStack::getStartLevel ()
const {
return _startLevel; }
169 inline unsigned int QueryStack::getStopLevel ()
const {
return _stopLevel; }
170 inline Cell::Flags QueryStack::getStopCellFlags ()
const {
return _stopCellFlags; }
171 inline const Box& QueryStack::getArea ()
const {
return back()->_area; }
172 inline const Transformation& QueryStack::getTransformation ()
const {
return back()->_transformation; }
173 inline const Path& QueryStack::getPath ()
const {
return back()->_path; }
175 inline size_t QueryStack::getInstanceCount ()
const {
return _instanceCount; }
178 inline Instance* QueryStack::getInstance ()
180 if ( levelCompleted() )
return NULL;
181 return back()->_locator->getElement();
185 inline Cell* QueryStack::getMasterCell ()
187 if ( size() == 1 )
return _topCell;
188 if ( !getInstance() )
return NULL;
189 return getInstance()->getMasterCell();
193 inline void QueryStack::setTopCell ( Cell* cell ) { _topCell = cell; }
194 inline void QueryStack::setTopArea (
const Box& area ) { _topArea = area; }
195 inline void QueryStack::setTopTransformation (
const Transformation& transformation ) { _topTransformation = transformation; }
196 inline void QueryStack::setThreshold ( DbU::Unit threshold ) { _threshold = threshold; }
197 inline void QueryStack::setStartLevel (
unsigned int level ) { _startLevel = level; }
198 inline void QueryStack::setStopLevel (
unsigned int level ) { _stopLevel = level; }
199 inline void QueryStack::setStopCellFlags ( Cell::Flags flags ) { _stopCellFlags = flags; }
202 inline void QueryStack::init ()
205 while (not empty()) levelUp();
207 push_back(
new QueryState(NULL,_topArea,_topTransformation,Path()) );
214 inline void QueryStack::updateTransformation ()
216 QueryState* child = *(rbegin() );
217 QueryState* parent = *(rbegin()+1);
218 Instance* instance = child->_locator->getElement();
222 child->_area = parent->_area;
223 child->_transformation = instance->getTransformation ();
225 instance->getTransformation().getInvert().applyOn ( child->_area );
226 parent->_transformation.applyOn ( child->_transformation );
229 child->_path = Path ( parent->_path, instance );
234 inline bool QueryStack::levelDown ()
236 if (size() > _stopLevel)
return false;
237 if (getMasterCell()->getFlags().isset(_stopCellFlags))
return false;
240 Locator<Instance*>* locator =
241 getMasterCell()->getInstancesUnder(getArea(),getThreshold()).getLocator();
243 if ( locator->isValid() ) {
244 push_back (
new QueryState ( locator ) );
246 updateTransformation ();
258 inline void QueryStack::levelUp ()
266 inline bool QueryStack::levelCompleted ()
268 if ( !back()->_locator || !back()->_locator->isValid () )
return true;
273 inline void QueryStack::levelProgress ()
275 if (levelCompleted())
return;
277 back()->_locator->progress();
278 if (not back()->_locator->isValid())
return;
282 updateTransformation();
286 inline void QueryStack::progress (
bool init )
288 if (not init) levelProgress ();
290 if (not levelDown() and (size() > _startLevel))
294 while (not empty()) {
295 if (levelCompleted()) {
298 if (levelDown())
continue;
301 if (size() > _startLevel)
return;
313 typedef Hurricane::Mask<int> Mask;
317 , DoTerminalCells = 2
321 , DoExtensionGos = 32
322 , DoAll = DoMasterCells
334 inline unsigned int getStartLevel ()
const;
335 inline unsigned int getStopLevel ()
const;
336 inline Cell::Flags getStopCellFlags ()
const;
337 inline size_t getDepth ()
const;
339 inline const Box& getArea ()
const;
341 inline const BasicLayer* getBasicLayer ()
const;
342 inline Cell* getMasterCell ();
344 inline Path getPath ()
const;
361 , ExtensionSlice::Mask extensionMask
365 inline void setCell (
Cell* cell );
366 inline void setArea (
const Box& area );
367 inline void setThreshold (
DbU::Unit threshold );
368 inline void setTransformation (
const Transformation& transformation );
370 inline void setExtensionMask ( ExtensionSlice::Mask mode );
371 inline void setFilter ( Mask mode );
372 inline void setStartLevel (
unsigned int level );
373 inline void setStopLevel (
unsigned int level );
374 inline void setStopCellFlags ( Cell::Flags );
381 ExtensionSlice::Mask _extensionMask;
388 inline void Query::setCell (
Cell* cell ) { _stack.setTopCell(cell); }
389 inline void Query::setArea (
const Box& area ) { _stack.setTopArea(area); }
390 inline void Query::setThreshold (
DbU::Unit threshold ) { _stack.setThreshold(threshold); }
391 inline void Query::setTransformation (
const Transformation& transformation ) { _stack.setTopTransformation(transformation); }
392 inline void Query::setFilter ( Mask filter ) { _filter = filter; }
393 inline void Query::setExtensionMask ( ExtensionSlice::Mask mask ) { _extensionMask = mask; }
394 inline void Query::setStartLevel (
unsigned int level ) { _stack.setStartLevel(level); }
395 inline void Query::setStopLevel (
unsigned int level ) { _stack.setStopLevel(level); }
396 inline void Query::setStopCellFlags ( Cell::Flags flags ) { _stack.setStopCellFlags(flags); }
398 inline unsigned int Query::getStartLevel ()
const {
return _stack.getStartLevel(); }
399 inline unsigned int Query::getStopLevel ()
const {
return _stack.getStopLevel(); }
400 inline Cell::Flags Query::getStopCellFlags ()
const {
return _stack.getStopCellFlags(); }
401 inline size_t Query::getDepth ()
const {
return _stack.size(); }
402 inline const Box& Query::getArea ()
const {
return _stack.getArea(); }
404 inline Path Query::getPath ()
const {
return _stack.getPath(); }
405 inline const BasicLayer* Query::getBasicLayer ()
const {
return _basicLayer; }
406 inline Cell* Query::getMasterCell () {
return _stack.getMasterCell(); }
407 inline Instance* Query::getInstance () {
return _stack.getInstance(); }
BasicLayer description (API)
Definition: BasicLayer.h:44
Box description (API)
Definition: Box.h:31
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:311
QueryFilter
Definition: Query.h:316
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
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5