get rid of is_a, dynamic_cast is far more powerful then #define...
This commit is contained in:
parent
0cae53b843
commit
4c4c8d3553
|
@ -80,7 +80,7 @@ void DBo::remove(Property* property)
|
|||
if (_propertySet.find(property) != _propertySet.end()) {
|
||||
_propertySet.erase(property);
|
||||
property->onReleasedBy(this);
|
||||
if (is_a<Quark*>(this) && _propertySet.empty()) destroy();
|
||||
if (dynamic_cast<Quark*>(this) && _propertySet.empty()) destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ void DBo::removeProperty(const Name& name)
|
|||
if (property) {
|
||||
_propertySet.erase(property);
|
||||
property->onReleasedBy(this);
|
||||
if (is_a<Quark*>(this) && _propertySet.empty()) destroy();
|
||||
if (dynamic_cast<Quark*>(this) && _propertySet.empty()) destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ void DBo::_onDestroyed(Property* property)
|
|||
{
|
||||
if (property && (_propertySet.find(property) != _propertySet.end())) {
|
||||
_propertySet.erase(property);
|
||||
if (is_a<Quark*>(this) && _propertySet.empty()) destroy();
|
||||
if (dynamic_cast<Quark*>(this) && _propertySet.empty()) destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -252,15 +252,15 @@ HyperNet::HyperNet(const Occurrence& occurrence)
|
|||
{
|
||||
if (occurrence.isValid()) {
|
||||
Entity* entity = occurrence.getEntity();
|
||||
if (is_a<Net*>(entity))
|
||||
if (dynamic_cast<Net*>(entity))
|
||||
_netOccurrence = occurrence;
|
||||
else {
|
||||
if (is_a<Rubber*>(entity)) {
|
||||
if (dynamic_cast<Rubber*>(entity)) {
|
||||
Rubber* rubber = (Rubber*)entity;
|
||||
_netOccurrence = Occurrence(rubber->getNet(), occurrence.getPath());
|
||||
}
|
||||
else {
|
||||
if (is_a<Component*>(entity)) {
|
||||
if (dynamic_cast<Component*>(entity)) {
|
||||
Component* component = (Component*)entity;
|
||||
_netOccurrence = Occurrence(component->getNet(), occurrence.getPath());
|
||||
}
|
||||
|
@ -533,12 +533,12 @@ void HyperNet_NetOccurrences::Locator::progress()
|
|||
if (_doExtraction) {
|
||||
Cell* cell = netOccurrence.getOwnerCell();
|
||||
for_each_component(component, net->getComponents()) {
|
||||
if (!is_a<Plug*>(component)) {
|
||||
if (!dynamic_cast<Plug*>(component)) {
|
||||
//if (_allowInterruption && !((i++) % 200)) gtk_check_for_interruption();
|
||||
Occurrence occurrence = Occurrence(component, path);
|
||||
Box area = occurrence.getBoundingBox();
|
||||
for_each_occurrence(occurrence2, cell->getOccurrencesUnder(area)) {
|
||||
if (is_a<Component*>(occurrence2.getEntity())) {
|
||||
if (dynamic_cast<Component*>(occurrence2.getEntity())) {
|
||||
Component* component2 = (Component*)occurrence2.getEntity();
|
||||
if (IsConnex(occurrence, occurrence2)) {
|
||||
Occurrence net2Occurrence =
|
||||
|
@ -768,15 +768,15 @@ void HyperNet_NetOccurrencesUnder::Locator::progress()
|
|||
Box area = occurrence.getBoundingBox();
|
||||
if (! area.intersect (_area)) {
|
||||
// Outside useful area
|
||||
} else if (is_a<Plug*>(component)) {
|
||||
} else if (dynamic_cast<Plug*>(component)) {
|
||||
// Will be processed below
|
||||
} else if (is_a<Rubber*>(component)) {
|
||||
} else if (dynamic_cast<Rubber*>(component)) {
|
||||
// Don't go through the Rubbers (go only trough connecting layers)
|
||||
} else {
|
||||
//if (_allowInterruption && !((i++) % 200)) gtk_check_for_interruption();
|
||||
Box under = area.getIntersection (_area);
|
||||
for_each_occurrence(occurrence2, cell->getOccurrencesUnder(under)) {
|
||||
if (is_a<Component*>(occurrence2.getEntity())) {
|
||||
if (dynamic_cast<Component*>(occurrence2.getEntity())) {
|
||||
Component* component2 = (Component*)occurrence2.getEntity();
|
||||
if (IsConnex(occurrence, occurrence2)) {
|
||||
Occurrence net2Occurrence =
|
||||
|
|
|
@ -621,7 +621,7 @@ void Net::_preDestroy()
|
|||
}
|
||||
|
||||
for_each_component(component, getComponents()) {
|
||||
if (!is_a<Plug*>(component))
|
||||
if (!dynamic_cast<Plug*>(component))
|
||||
component->destroy();
|
||||
else
|
||||
((Plug*)component)->setNet(NULL);
|
||||
|
|
|
@ -312,7 +312,7 @@ void RoutingPad::setExternalComponent(Component* component)
|
|||
Occurrence RoutingPad::getPlugOccurrence()
|
||||
// ***************************************
|
||||
{
|
||||
if (is_a<Plug*>(_occurrence.getEntity()))
|
||||
if (dynamic_cast<Plug*>(_occurrence.getEntity()))
|
||||
return _occurrence;
|
||||
Component* component= static_cast<Component*>(_occurrence.getEntity());
|
||||
Net* net=component->getNet();
|
||||
|
|
|
@ -123,21 +123,21 @@ BasicLayer* Technology::getBasicLayer(const Name& name) const
|
|||
// **********************************************************
|
||||
{
|
||||
Layer* layer = getLayer(name);
|
||||
return (layer && is_a<BasicLayer*>(layer)) ? (BasicLayer*)layer : NULL;
|
||||
return (layer && dynamic_cast<BasicLayer*>(layer)) ? (BasicLayer*)layer : NULL;
|
||||
}
|
||||
|
||||
RegularLayer* Technology::getRegularLayer(const Name& name) const
|
||||
// **********************************************************
|
||||
{
|
||||
Layer* layer = getLayer(name);
|
||||
return (layer && is_a<RegularLayer*>(layer)) ? (RegularLayer*)layer : NULL;
|
||||
return (layer && dynamic_cast<RegularLayer*>(layer)) ? (RegularLayer*)layer : NULL;
|
||||
}
|
||||
|
||||
ViaLayer* Technology::getViaLayer(const Name& name) const
|
||||
// ******************************************************************
|
||||
{
|
||||
Layer* layer = getLayer(name);
|
||||
return (layer && is_a<ViaLayer*>(layer)) ? (ViaLayer*)layer : NULL;
|
||||
return (layer && dynamic_cast<ViaLayer*>(layer)) ? (ViaLayer*)layer : NULL;
|
||||
}
|
||||
|
||||
BasicLayers Technology::getBasicLayers() const
|
||||
|
|
|
@ -76,7 +76,7 @@ void UpdateSession::_preDestroy()
|
|||
UPDATOR_STACK->pop();
|
||||
|
||||
for_each_dbo(owner, getOwners()) {
|
||||
if (is_a<Go*>(owner)) ((Go*)owner)->materialize();
|
||||
if (dynamic_cast<Go*>(owner)) ((Go*)owner)->materialize();
|
||||
end_for;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ Record* UpdateSession::_getRecord() const
|
|||
void UpdateSession::onCapturedBy(DBo* owner)
|
||||
// *****************************************
|
||||
{
|
||||
if (!is_a<Go*>(owner))
|
||||
if (!dynamic_cast<Go*>(owner))
|
||||
throw Error("Bad update session capture : not a graphic object");
|
||||
|
||||
Inherit::onCapturedBy(owner);
|
||||
|
@ -130,7 +130,7 @@ void Go::invalidate(bool propagateFlag)
|
|||
Property* property = getProperty(UpdateSession::getPropertyName());
|
||||
|
||||
if (property) {
|
||||
if (!is_a<UpdateSession*>(property))
|
||||
if (!dynamic_cast<UpdateSession*>(property))
|
||||
throw Error("Can't invalidate go : bad update session type");
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -461,7 +461,7 @@ template<class Type, class SubType> class SubTypeCollection : public Collection<
|
|||
: Inherit(),
|
||||
_locator(collection.getLocator())
|
||||
{
|
||||
while (_locator.isValid() && !is_a<SubType>(_locator.getElement()))
|
||||
while (_locator.isValid() && !dynamic_cast<SubType>(_locator.getElement()))
|
||||
_locator.progress();
|
||||
}
|
||||
|
||||
|
@ -470,7 +470,7 @@ template<class Type, class SubType> class SubTypeCollection : public Collection<
|
|||
: Inherit(),
|
||||
_locator(genericLocator.getClone())
|
||||
{
|
||||
while (_locator.isValid() && !is_a<SubType>(_locator.getElement()))
|
||||
while (_locator.isValid() && !dynamic_cast<SubType>(_locator.getElement()))
|
||||
_locator.progress();
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ template<class Type, class SubType> class SubTypeCollection : public Collection<
|
|||
if (_locator.isValid()) {
|
||||
do {
|
||||
_locator.progress();
|
||||
} while (_locator.isValid() && !is_a<SubType>(_locator.getElement()));
|
||||
} while (_locator.isValid() && !dynamic_cast<SubType>(_locator.getElement()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,6 @@
|
|||
// | Macros Definition |
|
||||
// x-----------------------------------------------------------------x
|
||||
|
||||
#define is_a (bool)dynamic_cast
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue