From 4c4c8d3553c0e100f3942fca81834060b22c5642 Mon Sep 17 00:00:00 2001 From: The Coriolis Project Date: Tue, 10 Jun 2008 17:04:48 +0000 Subject: [PATCH] get rid of is_a, dynamic_cast is far more powerful then #define... --- hurricane/src/hurricane/DBo.cpp | 6 +++--- hurricane/src/hurricane/HyperNet.cpp | 16 ++++++++-------- hurricane/src/hurricane/Net.cpp | 2 +- hurricane/src/hurricane/RoutingPad.cpp | 2 +- hurricane/src/hurricane/Technology.cpp | 6 +++--- hurricane/src/hurricane/UpdateSession.cpp | 6 +++--- hurricane/src/hurricane/hurricane/Collection.h | 6 +++--- hurricane/src/hurricane/hurricane/Commons.h | 3 --- 8 files changed, 22 insertions(+), 25 deletions(-) diff --git a/hurricane/src/hurricane/DBo.cpp b/hurricane/src/hurricane/DBo.cpp index 85b4dc19..a215bc1e 100644 --- a/hurricane/src/hurricane/DBo.cpp +++ b/hurricane/src/hurricane/DBo.cpp @@ -80,7 +80,7 @@ void DBo::remove(Property* property) if (_propertySet.find(property) != _propertySet.end()) { _propertySet.erase(property); property->onReleasedBy(this); - if (is_a(this) && _propertySet.empty()) destroy(); + if (dynamic_cast(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(this) && _propertySet.empty()) destroy(); + if (dynamic_cast(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(this) && _propertySet.empty()) destroy(); + if (dynamic_cast(this) && _propertySet.empty()) destroy(); } } diff --git a/hurricane/src/hurricane/HyperNet.cpp b/hurricane/src/hurricane/HyperNet.cpp index 82d8ec49..3500b525 100644 --- a/hurricane/src/hurricane/HyperNet.cpp +++ b/hurricane/src/hurricane/HyperNet.cpp @@ -252,15 +252,15 @@ HyperNet::HyperNet(const Occurrence& occurrence) { if (occurrence.isValid()) { Entity* entity = occurrence.getEntity(); - if (is_a(entity)) + if (dynamic_cast(entity)) _netOccurrence = occurrence; else { - if (is_a(entity)) { + if (dynamic_cast(entity)) { Rubber* rubber = (Rubber*)entity; _netOccurrence = Occurrence(rubber->getNet(), occurrence.getPath()); } else { - if (is_a(entity)) { + if (dynamic_cast(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(component)) { + if (!dynamic_cast(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(occurrence2.getEntity())) { + if (dynamic_cast(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(component)) { + } else if (dynamic_cast(component)) { // Will be processed below - } else if (is_a(component)) { + } else if (dynamic_cast(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(occurrence2.getEntity())) { + if (dynamic_cast(occurrence2.getEntity())) { Component* component2 = (Component*)occurrence2.getEntity(); if (IsConnex(occurrence, occurrence2)) { Occurrence net2Occurrence = diff --git a/hurricane/src/hurricane/Net.cpp b/hurricane/src/hurricane/Net.cpp index e4e1fb09..82fa1727 100644 --- a/hurricane/src/hurricane/Net.cpp +++ b/hurricane/src/hurricane/Net.cpp @@ -621,7 +621,7 @@ void Net::_preDestroy() } for_each_component(component, getComponents()) { - if (!is_a(component)) + if (!dynamic_cast(component)) component->destroy(); else ((Plug*)component)->setNet(NULL); diff --git a/hurricane/src/hurricane/RoutingPad.cpp b/hurricane/src/hurricane/RoutingPad.cpp index 90572d5d..821f847b 100644 --- a/hurricane/src/hurricane/RoutingPad.cpp +++ b/hurricane/src/hurricane/RoutingPad.cpp @@ -312,7 +312,7 @@ void RoutingPad::setExternalComponent(Component* component) Occurrence RoutingPad::getPlugOccurrence() // *************************************** { - if (is_a(_occurrence.getEntity())) + if (dynamic_cast(_occurrence.getEntity())) return _occurrence; Component* component= static_cast(_occurrence.getEntity()); Net* net=component->getNet(); diff --git a/hurricane/src/hurricane/Technology.cpp b/hurricane/src/hurricane/Technology.cpp index d3686779..77838ffd 100644 --- a/hurricane/src/hurricane/Technology.cpp +++ b/hurricane/src/hurricane/Technology.cpp @@ -123,21 +123,21 @@ BasicLayer* Technology::getBasicLayer(const Name& name) const // ********************************************************** { Layer* layer = getLayer(name); - return (layer && is_a(layer)) ? (BasicLayer*)layer : NULL; + return (layer && dynamic_cast(layer)) ? (BasicLayer*)layer : NULL; } RegularLayer* Technology::getRegularLayer(const Name& name) const // ********************************************************** { Layer* layer = getLayer(name); - return (layer && is_a(layer)) ? (RegularLayer*)layer : NULL; + return (layer && dynamic_cast(layer)) ? (RegularLayer*)layer : NULL; } ViaLayer* Technology::getViaLayer(const Name& name) const // ****************************************************************** { Layer* layer = getLayer(name); - return (layer && is_a(layer)) ? (ViaLayer*)layer : NULL; + return (layer && dynamic_cast(layer)) ? (ViaLayer*)layer : NULL; } BasicLayers Technology::getBasicLayers() const diff --git a/hurricane/src/hurricane/UpdateSession.cpp b/hurricane/src/hurricane/UpdateSession.cpp index 4dc4cdde..bcc91edc 100644 --- a/hurricane/src/hurricane/UpdateSession.cpp +++ b/hurricane/src/hurricane/UpdateSession.cpp @@ -76,7 +76,7 @@ void UpdateSession::_preDestroy() UPDATOR_STACK->pop(); for_each_dbo(owner, getOwners()) { - if (is_a(owner)) ((Go*)owner)->materialize(); + if (dynamic_cast(owner)) ((Go*)owner)->materialize(); end_for; } @@ -101,7 +101,7 @@ Record* UpdateSession::_getRecord() const void UpdateSession::onCapturedBy(DBo* owner) // ***************************************** { - if (!is_a(owner)) + if (!dynamic_cast(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(property)) + if (!dynamic_cast(property)) throw Error("Can't invalidate go : bad update session type"); } else { diff --git a/hurricane/src/hurricane/hurricane/Collection.h b/hurricane/src/hurricane/hurricane/Collection.h index a420b088..691d5a44 100644 --- a/hurricane/src/hurricane/hurricane/Collection.h +++ b/hurricane/src/hurricane/hurricane/Collection.h @@ -461,7 +461,7 @@ template class SubTypeCollection : public Collection< : Inherit(), _locator(collection.getLocator()) { - while (_locator.isValid() && !is_a(_locator.getElement())) + while (_locator.isValid() && !dynamic_cast(_locator.getElement())) _locator.progress(); } @@ -470,7 +470,7 @@ template class SubTypeCollection : public Collection< : Inherit(), _locator(genericLocator.getClone()) { - while (_locator.isValid() && !is_a(_locator.getElement())) + while (_locator.isValid() && !dynamic_cast(_locator.getElement())) _locator.progress(); } @@ -515,7 +515,7 @@ template class SubTypeCollection : public Collection< if (_locator.isValid()) { do { _locator.progress(); - } while (_locator.isValid() && !is_a(_locator.getElement())); + } while (_locator.isValid() && !dynamic_cast(_locator.getElement())); } } diff --git a/hurricane/src/hurricane/hurricane/Commons.h b/hurricane/src/hurricane/hurricane/Commons.h index 8cf0116b..3be7ad86 100644 --- a/hurricane/src/hurricane/hurricane/Commons.h +++ b/hurricane/src/hurricane/hurricane/Commons.h @@ -49,9 +49,6 @@ // | Macros Definition | // x-----------------------------------------------------------------x -#define is_a (bool)dynamic_cast - - using namespace std;