From 53ba31406331a7a3b5ae7d19e8bb32f55c3841ee Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 26 Mar 2010 18:01:41 +0000 Subject: [PATCH] * ./hurricane/src/viewer: - Change: In Cyclop, now uses the GtkStyle when not under OSX and Qt is newer or equal to Qt 4.5.0. - Change: In the various Qt Model Table, do the rowHeigh bug correction. - Bug: In InspectorWidget/NetlistModel, when browsing through the records tree, the records were generated twice at each slot change. This was due to the History ComboBox sending a index change signal then the InspectorWidget setting the slot *again*. When trying to explore a Slot, but this Slot is empty (like an empty vector, for instance) do not gut the RecordModel. Because as we find out that the new Slot is empty we go back and restore the previous contents. Potentially slow if we comes from a Slot with lots of records. Now we dump the contents only if there is something to explore. * ./hurricane/src/hurricane: - Bug: In Record, the slots where stored in a list container, which was making indexed accesses very very slow. This slowdown was also affecting the destructor of Record (this is the explanation why the RecordWidget was slow, even when *leaving* the net IntrusiveSet). Now implemented in term of STL vector. - Bug: In Slot/Common, still some adjustements to make the Inspection mechanism work with all types. Correct the "IntrusiveMap<>" not working with the NetMap. Related to templates not using the same constness. - Change: In Entity/DBo/Cell, Some more adjustements on Slot/Records. --- hurricane/src/hurricane/CMakeLists.txt | 8 +- hurricane/src/hurricane/Cell.cpp | 4 +- hurricane/src/hurricane/Commons.cpp | 42 +++--- hurricane/src/hurricane/DBo.cpp | 6 +- hurricane/src/hurricane/DRCError.cpp | 4 +- hurricane/src/hurricane/DataBase.cpp | 10 +- hurricane/src/hurricane/DebugSession.cpp | 2 - hurricane/src/hurricane/Record.cpp | 19 ++- hurricane/src/hurricane/hurricane/Cell.h | 7 +- hurricane/src/hurricane/hurricane/Commons.h | 96 +++++++++---- hurricane/src/hurricane/hurricane/DBo.h | 55 +++----- hurricane/src/hurricane/hurricane/Instance.h | 2 +- .../src/hurricane/hurricane/IntrusiveMap.h | 2 +- hurricane/src/hurricane/hurricane/Record.h | 24 ++-- hurricane/src/hurricane/hurricane/Slot.h | 128 ++++++++++++++++-- hurricane/src/hurricane/hurricane/demangle.h | 2 +- hurricane/src/viewer/InspectorWidget.cpp | 69 +++++----- hurricane/src/viewer/RecordModel.cpp | 75 +++++++--- hurricane/src/viewer/SelectionModel.cpp | 8 +- hurricane/src/viewer/SelectionPopupModel.cpp | 12 +- hurricane/src/viewer/SelectionWidget.cpp | 11 +- .../viewer/hurricane/viewer/InspectorWidget.h | 7 +- .../viewer/hurricane/viewer/NetlistModel.h | 2 +- .../src/viewer/hurricane/viewer/RecordModel.h | 10 +- .../viewer/hurricane/viewer/SelectionWidget.h | 1 - 25 files changed, 389 insertions(+), 217 deletions(-) diff --git a/hurricane/src/hurricane/CMakeLists.txt b/hurricane/src/hurricane/CMakeLists.txt index a480114d..93937242 100644 --- a/hurricane/src/hurricane/CMakeLists.txt +++ b/hurricane/src/hurricane/CMakeLists.txt @@ -1,5 +1,4 @@ - include_directories ( ${HURRICANE_SOURCE_DIR}/src/hurricane ) set ( includes hurricane/Mask.h hurricane/DebugSession.h @@ -151,7 +150,6 @@ Timer.cpp ) - add_library ( hurricane ${cpps} ) - install ( TARGETS hurricane DESTINATION /lib) - -install(FILES ${includes} DESTINATION /include/hurricane) + add_library ( hurricane ${cpps} ) + install ( TARGETS hurricane DESTINATION /lib) + install ( FILES ${includes} DESTINATION /include/hurricane ) diff --git a/hurricane/src/hurricane/Cell.cpp b/hurricane/src/hurricane/Cell.cpp index 03d0b73f..e7ccd6dc 100644 --- a/hurricane/src/hurricane/Cell.cpp +++ b/hurricane/src/hurricane/Cell.cpp @@ -17,6 +17,8 @@ // not, see . // **************************************************************************************************** +//#define TEST_INTRUSIVESET + #include "hurricane/Cell.h" #include "hurricane/DataBase.h" #include "hurricane/Library.h" @@ -369,7 +371,7 @@ void Cell::_removeSlaveEntity(Entity* entity, Entity* slaveEntity) pair bounds = _slaveEntityMap.equal_range(entity); - multimap::iterator it = bounds.first; + SlaveEntityMap::iterator it = bounds.first; for(; it != bounds.second ; it++ ) { if (it->second == slaveEntity) { _slaveEntityMap.erase(it); diff --git a/hurricane/src/hurricane/Commons.cpp b/hurricane/src/hurricane/Commons.cpp index 7dae43d9..feb0d5dd 100644 --- a/hurricane/src/hurricane/Commons.cpp +++ b/hurricane/src/hurricane/Commons.cpp @@ -17,12 +17,9 @@ // not, see . // **************************************************************************************************** -#ifdef HAVE_LIBIBERTY -#include "hurricane/demangle.h" -#include "hurricane/libiberty.h" -#endif -#include "hurricane/Commons.h" +#include +#include "hurricane/Commons.h" namespace Hurricane { @@ -100,26 +97,31 @@ void ltraceout (unsigned int level, unsigned int count ) } // ------------------------------------------------------------------- -// Function : "Demangle ()". +// Function : "demangle ()". + + +#define HAVE_CXA_DEMANGLE + +#ifdef HAVE_CXA_DEMANGLE string demangle ( const char* symbol ) -{ - string mangled = "_Z"; - mangled += symbol; - -# ifdef HAVE_LIBIBERTY - char* result = cplus_demangle ( mangled.c_str(), DMGL_PARAMS|DMGL_ANSI|DMGL_TYPES ); +{ + int status; + unsigned int length = 4096; + char demangled[length]; - if ( result ) { - mangled = result; - free ( result ); - return mangled; - } -# endif - - return mangled; + abi::__cxa_demangle ( symbol, demangled, &length, &status ); + return demangled; } +#else + +string demangle ( const char* symbol ) +{ + return symbol; +} + +#endif } // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/DBo.cpp b/hurricane/src/hurricane/DBo.cpp index 7e59fcd8..daad74b6 100644 --- a/hurricane/src/hurricane/DBo.cpp +++ b/hurricane/src/hurricane/DBo.cpp @@ -38,8 +38,8 @@ // x-----------------------------------------------------------------x -#include "hurricane/DBo.h" #include "hurricane/Property.h" +#include "hurricane/DBo.h" #include "hurricane/Quark.h" #include "hurricane/Error.h" @@ -79,7 +79,7 @@ namespace Hurricane { Property* DBo::getProperty ( const Name& name ) const { - PropertySet::const_iterator iterator = _propertySet.begin(); + set::const_iterator iterator = _propertySet.begin(); while ( iterator != _propertySet.end() ) { Property* property = *iterator; if (property->getName() == name) return property; @@ -173,7 +173,7 @@ namespace Hurricane { Record* DBo::_getRecord () const { Record* record = new Record ( getString(this) ); - record->add ( getSlot("Properties", &_propertySet) ); + record->add ( getSlot("_propertySet", &_propertySet) ); return record; } diff --git a/hurricane/src/hurricane/DRCError.cpp b/hurricane/src/hurricane/DRCError.cpp index 11219070..93f79a84 100644 --- a/hurricane/src/hurricane/DRCError.cpp +++ b/hurricane/src/hurricane/DRCError.cpp @@ -18,13 +18,15 @@ // **************************************************************************************************** #include "hurricane/DRCError.h" -#include "hurricane/Cell.h" +//#include "hurricane/Cell.h" #include "hurricane/Slice.h" #include "hurricane/Error.h" namespace Hurricane { + class Cell; + // **************************************************************************************************** // DRCError implementation diff --git a/hurricane/src/hurricane/DataBase.cpp b/hurricane/src/hurricane/DataBase.cpp index 794d513a..0d50933f 100644 --- a/hurricane/src/hurricane/DataBase.cpp +++ b/hurricane/src/hurricane/DataBase.cpp @@ -20,8 +20,6 @@ #include "hurricane/DataBase.h" #include "hurricane/Technology.h" #include "hurricane/Library.h" -#include "hurricane/Cell.h" -#include "hurricane/Timer.h" #include "hurricane/Error.h" #include "hurricane/UpdateSession.h" @@ -87,10 +85,10 @@ Record* DataBase::_getRecord() const { Record* record = Inherit::_getRecord(); if (record) { - record->add(getSlot("Technology", _technology)); - record->add(getSlot("RootLibrary", _rootLibrary)); - record->add(getSlot("Precision", DbU::getPrecision())); - record->add(getSlot("Resolution", DbU::db(1))); + record->add(getSlot("_technology" , _technology )); + record->add(getSlot("_rootLibrary" , _rootLibrary )); + record->add(getSlot("DbU::precision" , DbU::getPrecision())); + record->add(getSlot("DbU::resolution", DbU::db(1) )); //record->add(getSlot("GridStep", getValueString(getGridStep()))); } return record; diff --git a/hurricane/src/hurricane/DebugSession.cpp b/hurricane/src/hurricane/DebugSession.cpp index 4179f459..5c42e460 100644 --- a/hurricane/src/hurricane/DebugSession.cpp +++ b/hurricane/src/hurricane/DebugSession.cpp @@ -47,8 +47,6 @@ #include "hurricane/DebugSession.h" - - namespace Hurricane { diff --git a/hurricane/src/hurricane/Record.cpp b/hurricane/src/hurricane/Record.cpp index 670f7dfc..6977f724 100644 --- a/hurricane/src/hurricane/Record.cpp +++ b/hurricane/src/hurricane/Record.cpp @@ -52,8 +52,8 @@ namespace Hurricane { Record::Record ( const string& name ) - : _name(name) - , _slotList() + : _name (name) + , _slots() { _allocateds++; } @@ -62,11 +62,9 @@ namespace Hurricane { Record::~Record () { //cerr << "Record::~Record() - " << _name << ": " << hex << (void*)this << dec << endl; - while (!_slotList.empty()) { - Slot* slot = *_slotList.begin(); - _slotList.remove(slot); - delete slot; - } + for ( size_t i=0 ; i<_slots.size() ; i++ ) + delete _slots[i]; + _allocateds--; } @@ -79,9 +77,8 @@ namespace Hurricane { Slot* Record::getSlot ( unsigned no ) const { - SlotList::const_iterator iterator = _slotList.begin(); - while (no-- && (iterator != _slotList.end())) ++iterator; - return (iterator == _slotList.end()) ? NULL : *iterator; + if ( no >= _slots.size() ) return NULL; + return _slots[no]; } @@ -91,7 +88,7 @@ namespace Hurricane { cerr << "[ERROR] Record::add(): Attempt to add NULL Slot." << endl; return; } - _slotList.push_back(slot); + _slots.push_back(slot); } diff --git a/hurricane/src/hurricane/hurricane/Cell.h b/hurricane/src/hurricane/hurricane/Cell.h index 8214ecdb..6f66f42b 100644 --- a/hurricane/src/hurricane/hurricane/Cell.h +++ b/hurricane/src/hurricane/hurricane/Cell.h @@ -23,8 +23,8 @@ #include "hurricane/Pathes.h" #include "hurricane/Entity.h" #include "hurricane/Cells.h" -#include "hurricane/Instance.h" #include "hurricane/DeepNet.h" +#include "hurricane/Instance.h" #include "hurricane/Pin.h" #include "hurricane/Pins.h" #include "hurricane/Slices.h" @@ -38,11 +38,12 @@ #include "hurricane/Transformation.h" #include "hurricane/Layer.h" #include "hurricane/QuadTree.h" -#include "hurricane/IntrusiveMap.h" +//#include "hurricane/IntrusiveMap.h" #include "hurricane/IntrusiveSet.h" #include "hurricane/MapCollection.h" + namespace Hurricane { class Library; @@ -168,7 +169,7 @@ class Cell : public Entity { private: bool _isPad; private: Cell* _nextOfLibraryCellMap; private: Cell* _nextOfSymbolCellSet; - private: multimap _slaveEntityMap; + private: SlaveEntityMap _slaveEntityMap; // Constructors // ************ diff --git a/hurricane/src/hurricane/hurricane/Commons.h b/hurricane/src/hurricane/hurricane/Commons.h index 24ed6cf1..a94fd64c 100644 --- a/hurricane/src/hurricane/hurricane/Commons.h +++ b/hurricane/src/hurricane/hurricane/Commons.h @@ -182,9 +182,10 @@ namespace Hurricane { // Forward declaration of "getSlot<>()" template. -template inline Hurricane::Slot* getSlot ( std::string& name, Data d ); -template inline Hurricane::Slot* getSlot ( const std::string& name, Data d ); -template inline Hurricane::Slot* getSlot ( const std::string& name, Data* d ); +template inline Hurricane::Slot* getSlot ( std::string& name, Data ); +template inline Hurricane::Slot* getSlot ( std::string& name, Data* ); +template inline Hurricane::Slot* getSlot ( const std::string& name, Data ); +template inline Hurricane::Slot* getSlot ( const std::string& name, Data* ); // ------------------------------------------------------------------- @@ -193,7 +194,9 @@ template inline Hurricane::Slot* getSlot ( const std::string& nam // Default match. template inline std::string getString ( Data data ) -{ return ""; } +{ return std::string(""); } // "const *" flavors. @@ -278,7 +281,7 @@ template<> inline std::string getString ( std::string* s ) template<> inline std::string getString ( bool b ) { return (b)?"True":"False" ; } -template<> inline std::string getString ( const char c ) +template<> inline std::string getString ( char c ) { return std::string(1,c); } template<> inline std::string getString ( int i ) @@ -314,7 +317,32 @@ template inline Hurricane::Record* getRecord ( Data data ) // ------------------------------------------------------------------- -// Inspector Support for : "const std::vector*". +// Inspector Support for : "[const] std::vector*". + + +template +inline std::string getString ( std::vector* v ) +{ + std::string name = "const std::vector:"; + return name + getString(v->size()); +} + + +template +inline Hurricane::Record* getRecord ( std::vector* v ) +{ + Hurricane::Record* record = NULL; + if ( !v->empty() ) { + record = new Hurricane::Record ( "std::vector" ); + unsigned n = 1; + typename std::vector::iterator iterator = v->begin(); + while ( iterator != v->end() ) { + record->add ( getSlot(getString(n++), *iterator) ); + ++iterator; + } + } + return record; +} template @@ -334,7 +362,7 @@ inline Hurricane::Record* getRecord ( const std::vector* v ) unsigned n = 1; typename std::vector::const_iterator iterator = v->begin(); while ( iterator != v->end() ) { - record->add ( getSlot(getString(n++), *iterator) ); + record->add ( getSlot(getString(n++), *iterator) ); ++iterator; } } @@ -363,7 +391,7 @@ inline Hurricane::Record* getRecord ( const std::list* l ) unsigned n = 1; typename std::list::const_iterator iterator = l->begin(); while ( iterator != l->end() ) { - record->add ( getSlot(getString(n++), *iterator) ); + record->add ( getSlot(getString(n++), *iterator) ); ++iterator; } } @@ -401,7 +429,7 @@ inline Hurricane::Record* getRecord ( std::list* l ) template -inline std::string getString ( const std::map* m ) +inline std::string getString ( std::map* m ) { std::string name = "std::map:"; return name + getString(m->size()); @@ -409,12 +437,12 @@ inline std::string getString ( const std::map* m ) template -inline Hurricane::Record* getRecord ( const std::map* m ) +inline Hurricane::Record* getRecord ( std::map* m ) { Hurricane::Record* record = NULL; if ( !m->empty() ) { record = new Hurricane::Record ( "std::map" ); - typename std::map::const_iterator iterator = m->begin(); + typename std::map::iterator iterator = m->begin(); while ( iterator != m->end() ) { record->add ( getSlot(getString(iterator->first), iterator->second) ); ++iterator; @@ -424,14 +452,38 @@ inline Hurricane::Record* getRecord ( const std::map* m ) } +template +inline std::string getString ( const std::map* m ) +{ + std::string name = "const std::map:"; + return name + getString(m->size()); +} + + +template +inline Hurricane::Record* getRecord ( const std::map* m ) +{ + Hurricane::Record* record = NULL; + if ( !m->empty() ) { + record = new Hurricane::Record ( "const std::map" ); + typename std::map::const_iterator iterator = m->begin(); + while ( iterator != m->end() ) { + record->add ( getSlot(getString(iterator->first), iterator->second) ); + ++iterator; + } + } + return record; +} + + // ------------------------------------------------------------------- -// Inspector Support for : "[const] std::multimap*. +// Inspector Support for : "const std::multimap*". template inline std::string getString ( const std::multimap* m ) { - std::string name = "std::multimap:"; + std::string name = "const std::multimap:"; return name + getString(m->size()); } @@ -441,10 +493,10 @@ inline Hurricane::Record* getRecord ( const std::multimap* { Hurricane::Record* record = NULL; if ( !m->empty() ) { - record = new Hurricane::Record ( "std::multimap" ); + record = new Hurricane::Record ( "const std::multimap" ); typename std::multimap::const_iterator iterator = m->begin(); while ( iterator != m->end() ) { - record->add ( getSlot(getString(iterator->first), iterator->second) ); + record->add ( getSlot(getString(iterator->first), iterator->second) ); ++iterator; } } @@ -497,32 +549,30 @@ inline Hurricane::Record* getRecord ( const std::set* s ) unsigned n = 1; typename std::set::const_iterator iterator = s->begin(); while ( iterator != s->end() ) { - record->add ( getSlot(getString(n++), *iterator) ); + record->add ( getSlot(getString(n++), *iterator) ); ++iterator; } } return record; } -// ------------------------------------------------------------------- -// Inspector Support for : "std::set*". -template -inline std::string getString ( std::set* s ) +template< typename Element, typename Compare, typename Allocator > +inline std::string getString ( std::set* s ) { std::string name = "std::set:"; return name + getString(s->size()); } -template -inline Hurricane::Record* getRecord ( std::set* s ) +template< typename Element, typename Compare, typename Allocator > +inline Hurricane::Record* getRecord ( std::set* s ) { Hurricane::Record* record = NULL; if ( !s->empty() ) { record = new Hurricane::Record ( "std::set" ); unsigned n = 1; - typename std::set::iterator iterator = s->begin(); + typename std::set::iterator iterator = s->begin(); while ( iterator != s->end() ) { record->add ( getSlot(getString(n++), *iterator) ); ++iterator; diff --git a/hurricane/src/hurricane/hurricane/DBo.h b/hurricane/src/hurricane/hurricane/DBo.h index a2746cf5..cb8941e2 100644 --- a/hurricane/src/hurricane/hurricane/DBo.h +++ b/hurricane/src/hurricane/hurricane/DBo.h @@ -42,16 +42,13 @@ #define __HURRICANE_DBO__ #include "hurricane/DBos.h" -#include "hurricane/Properties.h" #include "hurricane/Name.h" +#include "hurricane/Properties.h" namespace Hurricane { - class Property; - - // ------------------------------------------------------------------- // Class : "Hurricane::DBo". @@ -59,27 +56,25 @@ namespace Hurricane { class DBo { public: - // Types. - typedef set PropertySet; // Methods. - virtual void destroy(); - inline PropertySet& _getPropertySet (); - void _onDestroyed ( Property* property ); - Property* getProperty ( const Name& ) const; - Properties getProperties () const; - inline bool hasProperty () const; - void put ( Property* ); - void remove ( Property* ); - void removeProperty ( const Name& ); - void clearProperties (); - // Hurricane Managment. - virtual string _getTypeName () const; - virtual string _getString () const; - virtual Record* _getRecord () const; + virtual void destroy(); + inline set& _getPropertySet (); + void _onDestroyed ( Property* property ); + Property* getProperty ( const Name& ) const; + Properties getProperties () const; + inline bool hasProperty () const; + void put ( Property* ); + void remove ( Property* ); + void removeProperty ( const Name& ); + void clearProperties (); + // Hurricane Managment. + virtual string _getTypeName () const; + virtual string _getString () const; + virtual Record* _getRecord () const; private: // Internal: Attributes. - mutable PropertySet _propertySet; + mutable set _propertySet; protected: // Internal: Constructors & Destructors. @@ -95,8 +90,8 @@ namespace Hurricane { // Inline Functions. - inline DBo::PropertySet& DBo::_getPropertySet () { return _propertySet; } - inline bool DBo::hasProperty () const { return !_propertySet.empty(); } + inline set& DBo::_getPropertySet () { return _propertySet; } + inline bool DBo::hasProperty () const { return !_propertySet.empty(); } } // End of Hurricane namespace. @@ -105,18 +100,4 @@ namespace Hurricane { INSPECTOR_P_SUPPORT(Hurricane::DBo); -template<> -inline Hurricane::Slot* getSlot ( const std::string& name, const std::set* s ) -{ - return new Hurricane::SlotTemplate*>(name,s); -} - - -template<> -inline Hurricane::Slot* getSlot ( const std::string& name, std::set* s ) -{ - return new Hurricane::SlotTemplate*>(name,s); -} - - #endif // __HURRICANE_DBO__ diff --git a/hurricane/src/hurricane/hurricane/Instance.h b/hurricane/src/hurricane/hurricane/Instance.h index 09b977d2..ae6ae718 100644 --- a/hurricane/src/hurricane/hurricane/Instance.h +++ b/hurricane/src/hurricane/hurricane/Instance.h @@ -23,7 +23,7 @@ #include "hurricane/Go.h" #include "hurricane/Plug.h" #include "hurricane/SharedPath.h" -#include "hurricane/IntrusiveMap.h" +//#include "hurricane/IntrusiveMap.h" namespace Hurricane { diff --git a/hurricane/src/hurricane/hurricane/IntrusiveMap.h b/hurricane/src/hurricane/hurricane/IntrusiveMap.h index 963b1613..2bc60135 100644 --- a/hurricane/src/hurricane/hurricane/IntrusiveMap.h +++ b/hurricane/src/hurricane/hurricane/IntrusiveMap.h @@ -342,7 +342,7 @@ template class IntrusiveMap { n = 1; Element* element = _array[index]; while (element) { - record->add(getSlot(getString(index) + ":" + getString(n++), element)); + record->add(getSlot(getString(index) + ":" + getString(n++), element)); element = _getNextElement(element); } } diff --git a/hurricane/src/hurricane/hurricane/Record.h b/hurricane/src/hurricane/hurricane/Record.h index 80ee509f..574de673 100644 --- a/hurricane/src/hurricane/hurricane/Record.h +++ b/hurricane/src/hurricane/hurricane/Record.h @@ -57,25 +57,25 @@ namespace Hurricane { public: // Types. - typedef list SlotList; + typedef vector SlotVector; public: // Constructor & Destructor. - Record ( const string& name ); - virtual ~Record (); - // Methods. - static size_t getAllocateds (); - inline const string& getName () const; - Slot* getSlot ( unsigned no ) const; - void add ( Slot* slot ); - inline SlotList& _getSlotList (); + Record ( const string& name ); + virtual ~Record (); + // Methods. + static size_t getAllocateds (); + inline const string& getName () const; + Slot* getSlot ( unsigned no ) const; + void add ( Slot* slot ); + inline SlotVector& _getSlotVector (); private: // Internal: Static Attributes. static size_t _allocateds; // Internal: Attributes string _name; - SlotList _slotList; + SlotVector _slots; private: // Forbidden: Constructors @@ -85,8 +85,8 @@ namespace Hurricane { // Inline Functions. - inline const string& Record::getName () const { return _name; } - inline Record::SlotList& Record::_getSlotList () { return _slotList; } + inline const string& Record::getName () const { return _name; } + inline Record::SlotVector& Record::_getSlotVector () { return _slots; } } // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/hurricane/Slot.h b/hurricane/src/hurricane/hurricane/Slot.h index 16739d69..f0e9bddc 100644 --- a/hurricane/src/hurricane/hurricane/Slot.h +++ b/hurricane/src/hurricane/hurricane/Slot.h @@ -91,11 +91,58 @@ namespace Hurricane { // ------------------------------------------------------------------- -// Class : "SlotTemplate". +// Class : "SlotTemplate". template class SlotTemplate : public Slot { + public: + // Constructor. + SlotTemplate ( const string& name, Data data ); + SlotTemplate ( string& name, Data data ); + // Accessors. + virtual string getDataString () const; + virtual Record* getDataRecord () const; + virtual SlotTemplate* + getClone () const; + + protected: + // Internal: Attributes. + Data _data; + + private: + // Internal: Constructors. + SlotTemplate ( const SlotTemplate& ); + SlotTemplate& operator= ( const SlotTemplate& ); + }; + + +// Inline Member Functions. + template + SlotTemplate::SlotTemplate ( const string& name, Data data ) + : Slot(name), _data(data) { } + + template + SlotTemplate::SlotTemplate ( string& name, Data data ) + : Slot(name), _data(data) { } + + template + string SlotTemplate::getDataString () const { return ::getString(_data); } + + template + Record* SlotTemplate::getDataRecord () const { return ::getRecord(_data); } + + template + SlotTemplate* SlotTemplate::getClone () const + { return new SlotTemplate(_name,_data); } + + +// ------------------------------------------------------------------- +// Class : "SlotTemplate". + + template + class SlotTemplate : public Slot { + public: // Constructor. SlotTemplate ( const string& name, const Data data ); @@ -103,7 +150,7 @@ namespace Hurricane { // Accessors. virtual string getDataString () const; virtual Record* getDataRecord () const; - virtual SlotTemplate* + virtual SlotTemplate* getClone () const; protected: @@ -119,21 +166,21 @@ namespace Hurricane { // Inline Member Functions. template - SlotTemplate::SlotTemplate ( const string& name, const Data data ) - : Slot(name), _data(data) { } + SlotTemplate::SlotTemplate ( const string& name, const Data data ) + : Slot(name), _data(data) { } template - SlotTemplate::SlotTemplate ( string& name, const Data data ) - : Slot(name), _data(data) { } + SlotTemplate::SlotTemplate ( string& name, const Data data ) + : Slot(name), _data(data) { } template - string SlotTemplate::getDataString () const { return getString(_data); } + string SlotTemplate::getDataString () const { return getString(_data); } template - Record* SlotTemplate::getDataRecord () const { return getRecord(_data); } + Record* SlotTemplate::getDataRecord () const { return getRecord(_data); } template - SlotTemplate* SlotTemplate::getClone () const + SlotTemplate* SlotTemplate::getClone () const { return new SlotTemplate(_name,_data); } @@ -175,16 +222,64 @@ namespace Hurricane { : Slot(name), _data(data) {} template - string SlotTemplate::getDataString () const { return getString(_data); } + string SlotTemplate::getDataString () const { return ::getString(_data); } template - Record* SlotTemplate::getDataRecord () const { return getRecord(_data); } + Record* SlotTemplate::getDataRecord () const { return ::getRecord(_data); } template SlotTemplate* SlotTemplate::getClone () const { return new SlotTemplate(_name,_data); } +// ------------------------------------------------------------------- +// Class : "SlotTemplate". + + + template + class SlotTemplate : public Slot { + + public: + // Constructor. + SlotTemplate ( const string& name, Data* const data ); + SlotTemplate ( string& name, Data* const data ); + // Accessors. + virtual string getDataString () const; + virtual Record* getDataRecord () const; + virtual SlotTemplate* + getClone () const; + + protected: + // Internal: Attributes. + Data* const _data; + + private: + // Internal: Constructors. + SlotTemplate ( const SlotTemplate& ); + SlotTemplate& operator= ( const SlotTemplate& ); + }; + + +// Inline Member Functions. + template + SlotTemplate::SlotTemplate ( const string& name, Data* const data ) + : Slot(name), _data(data) {} + + template + SlotTemplate::SlotTemplate ( string& name, Data* const data ) + : Slot(name), _data(data) {} + + template + string SlotTemplate::getDataString () const { return ::getString(_data); } + + template + Record* SlotTemplate::getDataRecord () const { return ::getRecord(_data); } + + template + SlotTemplate* SlotTemplate::getClone () const + { return new SlotTemplate(_name,_data); } + + // ------------------------------------------------------------------- // Class : "SlotTemplate". @@ -233,13 +328,23 @@ namespace Hurricane { template inline Hurricane::Slot* getSlot( std::string& name, Data d ) { +//std::cerr << "getSlot( \"" << name << "\" )" << std::endl; return new Hurricane::SlotTemplate ( name, d ); } +template +inline Hurricane::Slot* getSlot( std::string& name, Data* d ) +{ +//std::cerr << "getSlot( \"" << name << "\" )" << std::endl; + return new Hurricane::SlotTemplate ( name, d ); +} + + template inline Hurricane::Slot* getSlot( const std::string& name, Data d ) { +//std::cerr << "getSlot( \"" << name << "\" )" << std::endl; return new Hurricane::SlotTemplate ( name, d ); } @@ -247,6 +352,7 @@ inline Hurricane::Slot* getSlot( const std::string& name, Data d ) template inline Hurricane::Slot* getSlot( const std::string& name, Data* d ) { +//std::cerr << "getSlot( \"" << name << "\" )" << std::endl; return new Hurricane::SlotTemplate ( name, d ); } diff --git a/hurricane/src/hurricane/hurricane/demangle.h b/hurricane/src/hurricane/hurricane/demangle.h index 3ec49022..2fc182ff 100644 --- a/hurricane/src/hurricane/hurricane/demangle.h +++ b/hurricane/src/hurricane/hurricane/demangle.h @@ -21,7 +21,7 @@ #if !defined (DEMANGLE_H) #define DEMANGLE_H -#include "hurricane/libiberty.h" +//#include "hurricane/libiberty.h" #ifdef __cplusplus extern "C" { diff --git a/hurricane/src/viewer/InspectorWidget.cpp b/hurricane/src/viewer/InspectorWidget.cpp index 72f57703..3a314c2c 100644 --- a/hurricane/src/viewer/InspectorWidget.cpp +++ b/hurricane/src/viewer/InspectorWidget.cpp @@ -57,7 +57,7 @@ namespace Hurricane { } - void InspectorWidget::History::push ( Slot* slot ) + void InspectorWidget::History::push ( Slot* slot, Record* record ) { if ( _depth < _slots.size()-1 ) { while ( _depth < _slots.size()-1 ) pop (); @@ -66,8 +66,9 @@ namespace Hurricane { _depth++; _slots.push_back ( slot->getClone() ); _comboBox->addItem ( QString("%1: %2").arg(_depth).arg(_slots[_slots.size()-1]->getDataString().c_str())); - _comboBox->setCurrentIndex ( _depth ); + //_comboBox->setCurrentIndex ( _depth ); + //cerr << "After History::push()" << endl; } @@ -94,8 +95,10 @@ namespace Hurricane { void InspectorWidget::History::goTo ( int depth ) { if ( ( depth < 0 ) || ( depth >= (int)_slots.size() ) ) return; - - _depth = depth; + if ( depth != _depth ) { + _depth = depth; + _comboBox->setCurrentIndex ( _depth ); + } } @@ -185,6 +188,7 @@ namespace Hurricane { QHeaderView* verticalHeader = _view->verticalHeader (); verticalHeader->setVisible ( false ); + verticalHeader->setDefaultSectionSize ( _rowHeight ); _historyComboBox = new QComboBox ( this ); _history.setComboBox ( _historyComboBox ); @@ -218,13 +222,6 @@ namespace Hurricane { } - void InspectorWidget::forceRowHeight () - { - for ( int rows=_sortModel->rowCount()-1; rows >= 0 ; rows-- ) - _view->setRowHeight ( rows, _rowHeight ); - } - - void InspectorWidget::setRootOccurrence ( Occurrence& occurrence ) { _rootOccurrence = occurrence; @@ -241,12 +238,12 @@ namespace Hurricane { void InspectorWidget::_setRootRecord ( Record* record ) { + //cerr << "InspectorWidget::_setRootRecord()." << endl; //if ( _baseModel ) _baseModel->setSlot ( NULL, 0 ); - _history.setRootRecord ( record ); - if ( !record ) _rootOccurrence = Occurrence (); + if ( record == NULL ) _rootOccurrence = Occurrence (); - if ( !_baseModel ) { + if ( _baseModel == NULL ) { _baseModel = new RecordModel ( this ); _sortModel = new QSortFilterProxyModel ( this ); _sortModel->setSourceModel ( _baseModel ); @@ -259,49 +256,53 @@ namespace Hurricane { // Only after creating the RecordModel can we connect the ComboBox. connect ( _historyComboBox, SIGNAL(currentIndexChanged(int)) - , this , SLOT(historyChanged(int)) ); - connect ( _baseModel, SIGNAL(layoutChanged()), this, SLOT(forceRowHeight()) ); + , this , SLOT (historyChanged(int)) ); } - setSlot (); + _history.setRootRecord ( record ); } - bool InspectorWidget::setSlot () + bool InspectorWidget::setSlot ( Record* record ) { bool change = true; - change = _baseModel->setSlot ( _history.getSlot(), _history.getDepth() ); -// if ( change ) { -// int rows = _sortModel->rowCount (); -// for ( rows-- ; rows >= 0 ; rows-- ) -// _view->setRowHeight ( rows, _rowHeight ); -// _view->selectRow ( 0 ); -// } + if ( (_history.getSlot() != NULL) and (record == NULL) ) + record = _history.getSlot()->getDataRecord(); + + //cerr << " Effective setSlot() ." << endl; + change = _baseModel->setSlot ( _history.getSlot(), record, _history.getDepth() ); return change; } - void InspectorWidget::pushSlot ( Slot* slot ) + void InspectorWidget::pushSlot ( Slot* slot, Record* record ) { - _history.push ( slot ); - if ( !setSlot() ) - _history.pop (); + //cerr << "InspectorWidget::pushSlot()" << endl; + + if ( slot == NULL ) return; + if ( record == NULL ) { + record = slot->getDataRecord (); + if ( record == NULL ) return; + } + + _history.push ( slot, record ); + setSlot ( record ); } void InspectorWidget::popSlot () { _history.pop (); - setSlot (); + //setSlot (); } void InspectorWidget::back () { _history.back (); - setSlot (); + //setSlot (); } @@ -313,10 +314,11 @@ namespace Hurricane { if ( keyEvent->key() == Qt::Key_Right ) { QModelIndex index = _view->currentIndex(); if ( index.isValid() ) { + //cerr << "Key Right: do to sub-slot." << endl; Slot* slot = _baseModel->getRecord()->getSlot(_sortModel->mapToSource(index).row()); - if ( slot ) - pushSlot ( slot ); + if ( slot != NULL ) + pushSlot ( slot, slot->getDataRecord() ); } } else if ( keyEvent->key() == Qt::Key_Left ) { back (); @@ -332,7 +334,6 @@ namespace Hurricane { void InspectorWidget::textFilterChanged () { _sortModel->setFilterRegExp ( _filterPatternLineEdit->text() ); - forceRowHeight (); } diff --git a/hurricane/src/viewer/RecordModel.cpp b/hurricane/src/viewer/RecordModel.cpp index 56de01d7..08a90a0d 100644 --- a/hurricane/src/viewer/RecordModel.cpp +++ b/hurricane/src/viewer/RecordModel.cpp @@ -36,9 +36,10 @@ namespace Hurricane { RecordModel::RecordModel ( QObject* parent ) : QAbstractTableModel(parent) - , _slot(NULL) - , _record(NULL) - , _depth(0) + , _slot (NULL) + , _record (NULL) + , _depth (0) + , _cache () { } @@ -49,30 +50,53 @@ namespace Hurricane { } - bool RecordModel::setSlot ( Slot* slot, size_t depth ) + bool RecordModel::setSlot ( Slot* slot, Record* record, size_t depth ) { - if ( !slot ) { - _slot = NULL; - _record = NULL; - _depth = depth; + //cerr << " Slot change" << endl; + + vector< pair >().swap ( _cache ); + + if ( _slot ) { + delete _slot; + if ( _depth ) delete _record; + } + + _slot = NULL; + _record = NULL; + _depth = depth; + + if ( slot == NULL ) { + //cerr << " NULL Slot" << endl; emit layoutChanged (); return false; } - Record* record = slot->getDataRecord (); - if ( !record ) { - delete slot; - return false; + // Now supplied by argument. + if ( record == NULL ) { + record = slot->getDataRecord (); + //cerr << " New record build" << endl; + if ( record == NULL ) { + // cerr << " Slot " << slot->getDataString() << " has NULL Record" << endl; + + delete slot; + return false; + } } - if ( _depth ) delete _record; - if ( _slot ) delete _slot; + //cerr << " New Slot [" << depth << "] " << slot->getDataString() << endl; _slot = slot; _record = record; _depth = depth; + Record::SlotVector& slotVector = _record->_getSlotVector(); + Record::SlotVector::iterator islot = slotVector.begin(); + for ( ; islot != slotVector.end() ; islot++ ) { + _cache.push_back ( make_pair(QVariant(getString((*islot)->getName()).c_str()) + ,QVariant((*islot)->getDataString().c_str())) ); + } + emit layoutChanged (); return true; @@ -84,7 +108,7 @@ namespace Hurricane { static QFont nameFont = Graphics::getFixedFont ( QFont::Bold ); static QFont valueFont = Graphics::getFixedFont ( QFont::Normal, true ); - if ( !index.isValid() ) return QVariant (); + if ( not index.isValid() ) return QVariant (); if ( role == Qt::SizeHintRole ) { switch (index.column()) { @@ -94,6 +118,7 @@ namespace Hurricane { } if ( role == Qt::FontRole ) { + //if ( index.row() == 0 ) return QVariant(); switch (index.column()) { case 0: return nameFont; case 1: return valueFont; @@ -102,11 +127,13 @@ namespace Hurricane { if ( role == Qt::DisplayRole ) { int row = index.row (); - Slot* slot = _record->getSlot ( row ); - if ( slot ) { + //Slot* slot = _record->getSlot ( row ); + if ( row < _cache.size() ) { switch ( index.column() ) { - case 0: return QVariant(slot->getName ().c_str()); - case 1: return QVariant(slot->getDataString().c_str()); + case 0: return _cache[row].first; + case 1: return _cache[row].second; + //case 0: return QVariant(slot->getName ().c_str()); + //case 1: return QVariant(slot->getDataString().c_str()); } } } @@ -118,9 +145,14 @@ namespace Hurricane { , Qt::Orientation orientation , int role ) const { - if ( ( orientation == Qt::Vertical ) || ( section > 1 ) || (role != Qt::DisplayRole) ) + if ( ( orientation == Qt::Vertical ) or ( section > 1 ) ) return QVariant(); + static QFont headerFont = Graphics::getFixedFont ( QFont::Bold, false, false, +2 ); + + if ( role == Qt::FontRole ) return headerFont; + if ( role != Qt::DisplayRole ) return QVariant(); + if ( section == 0 ) return QVariant ( tr("Object Attribute") ); @@ -130,7 +162,8 @@ namespace Hurricane { int RecordModel::rowCount ( const QModelIndex& parent ) const { - return (_record) ? _record->_getSlotList().size() : 0; + //return (_record != NULL) ? _record->_getSlotList().size() : 0; + return _cache.size(); } diff --git a/hurricane/src/viewer/SelectionModel.cpp b/hurricane/src/viewer/SelectionModel.cpp index bb62290f..afa50921 100644 --- a/hurricane/src/viewer/SelectionModel.cpp +++ b/hurricane/src/viewer/SelectionModel.cpp @@ -131,6 +131,7 @@ namespace Hurricane { if ( !index.isValid() ) return QVariant (); if ( role == Qt::SizeHintRole ) { + if ( index.row() == 0 ) return QVariant(); switch (index.column()) { case 0: return 200; default: return -1; @@ -165,9 +166,14 @@ namespace Hurricane { , Qt::Orientation orientation , int role ) const { - if ( ( orientation == Qt::Vertical ) || (role != Qt::DisplayRole) ) + if ( orientation == Qt::Vertical ) return QVariant(); + static QFont headerFont = Graphics::getFixedFont ( QFont::Bold, false, false, +2 ); + + if ( role == Qt::FontRole ) return headerFont; + if ( role != Qt::DisplayRole ) return QVariant(); + switch ( section ) { case 0: return "Path"; case 1: return "Entity"; diff --git a/hurricane/src/viewer/SelectionPopupModel.cpp b/hurricane/src/viewer/SelectionPopupModel.cpp index d368f16a..d2ce1257 100644 --- a/hurricane/src/viewer/SelectionPopupModel.cpp +++ b/hurricane/src/viewer/SelectionPopupModel.cpp @@ -118,6 +118,7 @@ namespace Hurricane { } if ( role == Qt::FontRole ) { + if ( index.row() == 0 ) return QVariant(); switch (index.column()) { default: return entityFont; } @@ -148,12 +149,17 @@ namespace Hurricane { QVariant SelectionPopupModel::headerData ( int section - , Qt::Orientation orientation - , int role ) const + , Qt::Orientation orientation + , int role ) const { - if ( ( orientation == Qt::Vertical ) || (role != Qt::DisplayRole) ) + if ( orientation == Qt::Vertical ) return QVariant(); + static QFont headerFont = Graphics::getFixedFont ( QFont::Bold, false, false, +2 ); + + if ( role == Qt::FontRole ) return headerFont; + if ( role != Qt::DisplayRole ) return QVariant(); + if ( section == 0 ) { return "Path+Entity"; } diff --git a/hurricane/src/viewer/SelectionWidget.cpp b/hurricane/src/viewer/SelectionWidget.cpp index cf6da691..6fbf3838 100644 --- a/hurricane/src/viewer/SelectionWidget.cpp +++ b/hurricane/src/viewer/SelectionWidget.cpp @@ -124,7 +124,6 @@ namespace Hurricane { connect ( _filterPatternLineEdit, SIGNAL(textChanged(const QString &)) , this , SLOT (textFilterChanged()) ); - connect ( _baseModel , SIGNAL(layoutChanged()), this , SLOT(forceRowHeight()) ); connect ( _showSelection, SIGNAL(toggled(bool)) , this , SLOT(setShowSelection(bool)) ); connect ( _cumulative , SIGNAL(toggled(bool)) , this , SLOT(setCumulativeSelection(bool)) ); connect ( clear , SIGNAL(clicked()) , _baseModel, SLOT(clear()) ); @@ -151,13 +150,6 @@ namespace Hurricane { } - void SelectionWidget::forceRowHeight () - { - for ( int rows=_sortModel->rowCount()-1; rows >= 0 ; rows-- ) - _view->setRowHeight ( rows, _rowHeight ); - } - - void SelectionWidget::setCellWidget ( CellWidget* cw ) { if ( _cellWidget ) { @@ -168,7 +160,7 @@ namespace Hurricane { _cellWidget = cw; if ( !_cellWidget ) return; - connect ( _cellWidget, SIGNAL(selectionModeChanged()), this , SLOT(changeSelectionMode()) ); + connect ( _cellWidget, SIGNAL(selectionModeChanged()), this, SLOT(changeSelectionMode()) ); connect ( _cellWidget, SIGNAL(selectionChanged(const SelectorSet&)) , this , SLOT (setSelection (const SelectorSet&)) ); @@ -232,7 +224,6 @@ namespace Hurricane { void SelectionWidget::textFilterChanged () { _sortModel->setFilterRegExp ( _filterPatternLineEdit->text() ); - forceRowHeight (); } diff --git a/hurricane/src/viewer/hurricane/viewer/InspectorWidget.h b/hurricane/src/viewer/hurricane/viewer/InspectorWidget.h index ae34b555..0920f05f 100644 --- a/hurricane/src/viewer/hurricane/viewer/InspectorWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/InspectorWidget.h @@ -57,7 +57,7 @@ namespace Hurricane { public: History (); ~History (); - void push ( Slot* slot ); + void push ( Slot*, Record* ); void pop (); void back (); void goTo ( int depth ); @@ -83,7 +83,6 @@ namespace Hurricane { void setRootRecord ( Record* ); void setRootOccurrence ( Occurrence& ); private slots: - void forceRowHeight (); void textFilterChanged (); void historyChanged ( int depth ); void forkInspector ( const QModelIndex& ); @@ -91,10 +90,10 @@ namespace Hurricane { bool eventFilter ( QObject*, QEvent* ); private: void _setRootRecord ( Record* ); - void pushSlot ( Slot* ); + void pushSlot ( Slot*, Record* record=NULL ); void popSlot (); void back (); - bool setSlot (); + bool setSlot ( Record* record=NULL ); private: RecordModel* _baseModel; diff --git a/hurricane/src/viewer/hurricane/viewer/NetlistModel.h b/hurricane/src/viewer/hurricane/viewer/NetlistModel.h index 18383976..6da00dda 100644 --- a/hurricane/src/viewer/hurricane/viewer/NetlistModel.h +++ b/hurricane/src/viewer/hurricane/viewer/NetlistModel.h @@ -15,7 +15,7 @@ // | Author : Jean-Paul CHAPUT | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | =============================================================== | -// | C++ Header : "./NetlistModel.h" | +// | C++ Header : "./NetlistModel.h" | // | *************************************************************** | // | U p d a t e s | // | | diff --git a/hurricane/src/viewer/hurricane/viewer/RecordModel.h b/hurricane/src/viewer/hurricane/viewer/RecordModel.h index 57605387..8490b295 100644 --- a/hurricane/src/viewer/hurricane/viewer/RecordModel.h +++ b/hurricane/src/viewer/hurricane/viewer/RecordModel.h @@ -53,6 +53,7 @@ #ifndef __RECORD_MODEL_H__ #define __RECORD_MODEL_H__ +#include #include #include "hurricane/Commons.h" @@ -67,7 +68,7 @@ namespace Hurricane { public: RecordModel ( QObject* parent=NULL ); ~RecordModel (); - bool setSlot ( Slot* slot, size_t depth ); + bool setSlot ( Slot* slot, Record* record, size_t depth ); int rowCount ( const QModelIndex& parent=QModelIndex() ) const; int columnCount ( const QModelIndex& parent=QModelIndex() ) const; QVariant data ( const QModelIndex& index, int role=Qt::DisplayRole ) const; @@ -76,9 +77,10 @@ namespace Hurricane { inline Slot* getSlot (); private: - Slot* _slot; - Record* _record; - size_t _depth; + Slot* _slot; + Record* _record; + size_t _depth; + std::vector< pair > _cache; }; diff --git a/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h b/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h index b78c0b03..562863f0 100644 --- a/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/SelectionWidget.h @@ -76,7 +76,6 @@ namespace Hurricane { void toggleSelection (); void toggleSelection ( Occurrence ); void toggleSelection ( const QModelIndex& ); - void forceRowHeight (); void inspect (); private slots: void textFilterChanged ();