diff --git a/Makefile b/Makefile index 5f491ea1..92fbcec1 100644 --- a/Makefile +++ b/Makefile @@ -55,8 +55,8 @@ check_dir: install: check_dir - @./bootstrap/ccb.py $(DEVTOOLSET_OPTION) --project=coriolis --make="$(SMP_FLAGS) install" - @./bootstrap/ccb.py $(DEVTOOLSET_OPTION) --project=coriolis --make="-j1 install" --doc + @./bootstrap/ccb.py $(DEVTOOLSET_OPTION) --project=support --project=coriolis --make="$(SMP_FLAGS) install" + @./bootstrap/ccb.py $(DEVTOOLSET_OPTION) --project=support --project=coriolis --make="-j1 install" --doc @echo ""; \ echo "============================================================================"; \ echo "Coriolis has been successfully built"; \ diff --git a/README.rst b/README.rst index 91cef49b..3227ae9f 100644 --- a/README.rst +++ b/README.rst @@ -47,13 +47,16 @@ To build Coriolis, ensure the following prerequisites are met: * bison & flex. * Qt 4 or 5. * libxml2. +* RapidJSON * A C++11 compliant compiler. The build system relies on a fixed directory tree from the root of the user currently building it. Thus first step is to get a clone of the repository in the right place. Proceed as follow: :: - ego@home:~$ mkdir -p ~/coriolis-2.x/src + ego@home:~$ mkdir -p ~/coriolis-2.x/src/support + ego@home:~$ cd ~/coriolis-2.x/src/support + ego@home:~$ git clone http://github.com/miloyip/rapidjson ego@home:~$ cd ~/coriolis-2.x/src ego@home:src$ git clone https://www-soc.lip6.fr/git/coriolis.git ego@home:src$ cd coriolis diff --git a/bootstrap/build.conf b/bootstrap/build.conf index 8447c0e8..388ae4c4 100644 --- a/bootstrap/build.conf +++ b/bootstrap/build.conf @@ -6,7 +6,12 @@ projectdir = 'coriolis-2.x' projects = [ - { 'name' : "coriolis" + { 'name' : "support" + , 'tools' : [ "rapidjson" + ] + , 'repository': 'No_repository_for_support' + } + , { 'name' : "coriolis" , 'tools' : [ "bootstrap" , "vlsisapd" , "hurricane" diff --git a/bootstrap/builder/Builder.py b/bootstrap/builder/Builder.py index fc8031c9..b2ff8c1b 100644 --- a/bootstrap/builder/Builder.py +++ b/bootstrap/builder/Builder.py @@ -150,8 +150,9 @@ class Builder: def _build ( self, tool ): - toolSourceDir = os.path.join ( self.sourceDir, tool.getToolDir() ) - toolBuildDir = os.path.join ( self.buildDir , tool.name ) + toolSourceDir = os.path.join ( self.sourceDir, tool.getToolDir() ) + toolBuildDir = os.path.join ( self.buildDir , tool.name ) + cmakeInstallDir = os.path.join ( self.installDir, "share", "cmake", "Modules" ) # Supplied directly in the CMakeLists.txt. #cmakeModules = os.path.join ( self.installDir, "share", "cmake", "Modules" ) @@ -170,8 +171,10 @@ class Builder: if self._qt5: command += [ "-D", "WITH_QT5:STRING=TRUE" ] if self._openmp: command += [ "-D", "WITH_OPENMP:STRING=TRUE" ] - command += [ "-D", "CMAKE_BUILD_TYPE:STRING=%s" % self.buildMode - , "-D", "BUILD_SHARED_LIBS:STRING=%s" % self.enableShared + command += [ "-D", "CMAKE_BUILD_TYPE:STRING=%s" % self.buildMode + , "-D", "BUILD_SHARED_LIBS:STRING=%s" % self.enableShared + , "-D", "CMAKE_INSTALL_PREFIX:STRING=%s" % self.installDir + , "-D", "CMAKE_INSTALL_DIR:STRING=%s" % cmakeInstallDir #, "-D", "CMAKE_MODULE_PATH:STRING=%s" % cmakeModules , toolSourceDir ] @@ -191,6 +194,7 @@ class Builder: , "-D", "CHECK_DETERMINISM:STRING=%s" % self._checkDeterminism , "-D", "CMAKE_VERBOSE_MAKEFILE:STRING=%s" % self._verboseMakefile , "-D", "CMAKE_INSTALL_PREFIX:STRING=%s" % self.installDir + , "-D", "CMAKE_INSTALL_DIR:STRING=%s" % cmakeInstallDir ] if self.libSuffix: command += [ "-D", "LIB_SUFFIX:STRING=%s" % self.libSuffix ] diff --git a/crlcore/etc/cmos/alliance.conf b/crlcore/etc/cmos/alliance.conf index 05c99819..5e937d65 100644 --- a/crlcore/etc/cmos/alliance.conf +++ b/crlcore/etc/cmos/alliance.conf @@ -11,6 +11,7 @@ cellsTop = allianceTop+'/cells/' allianceConfig = \ ( ( 'CATALOG' , 'CATAL') , ( 'WORKING_LIBRARY' , '.') +# , ( 'SYSTEM_LIBRARY' , ( (cellsTop+'ramlib' , AddMode.Append), ) ) , ( 'SYSTEM_LIBRARY' , ( (cellsTop+'sxlib' , AddMode.Append) , (cellsTop+'dp_sxlib', AddMode.Append) , (cellsTop+'ramlib' , AddMode.Append) diff --git a/crlcore/src/LibraryManager/CellsModel.cpp b/crlcore/src/LibraryManager/CellsModel.cpp index 12410cb4..5e82a0fb 100644 --- a/crlcore/src/LibraryManager/CellsModel.cpp +++ b/crlcore/src/LibraryManager/CellsModel.cpp @@ -226,6 +226,7 @@ namespace CRL { Catalog* catalog = AllianceFramework::get()->getCatalog(); CellLoaders* loaders = CellLoaders::get(); + getCellsDatas().clear(); forEach ( Cell*, icell, library->getLibrary()->getCells() ) { CellDatas* datas = new CellDatas(*icell); getCellsDatas().push_back( datas ); @@ -245,6 +246,7 @@ namespace CRL { CellDatas* key = new CellDatas( cellName ); auto idatas = lower_bound( getCellsDatas().begin(), getCellsDatas().end(), key, LessCellDatas ); + if ( (idatas == getCellsDatas().end()) or ((*idatas)->getName() != cellName ) ) { getCellsDatas().push_back( key ); diff --git a/crlcore/src/LibraryManager/CellsWidget.cpp b/crlcore/src/LibraryManager/CellsWidget.cpp index b181039b..d95fef05 100644 --- a/crlcore/src/LibraryManager/CellsWidget.cpp +++ b/crlcore/src/LibraryManager/CellsWidget.cpp @@ -86,6 +86,10 @@ namespace CRL { } + void CellsWidget::updateLibrary () + { _baseModel->updateLibrary(); } + + void CellsWidget::updateSelected () { if (_selected.isValid()) _baseModel->emitDataChanged(_selected); } diff --git a/crlcore/src/LibraryManager/LibraryManager.cpp b/crlcore/src/LibraryManager/LibraryManager.cpp index e95c7cb0..a37c8e06 100644 --- a/crlcore/src/LibraryManager/LibraryManager.cpp +++ b/crlcore/src/LibraryManager/LibraryManager.cpp @@ -139,5 +139,8 @@ namespace CRL { } + void LibraryManager::updateLibrary ( Cell* ) + { _cellsWidget->updateLibrary(); } + } // CRL namespace. diff --git a/crlcore/src/LibraryManager/crlcore/CellsModel.h b/crlcore/src/LibraryManager/crlcore/CellsModel.h index 56324b3a..c8fe59c4 100644 --- a/crlcore/src/LibraryManager/crlcore/CellsModel.h +++ b/crlcore/src/LibraryManager/crlcore/CellsModel.h @@ -60,7 +60,9 @@ namespace CRL { }; - inline const AllianceLibrary* CellsModel::getLibrary () const { return (const AllianceLibrary*)_ilibrary->first; } + inline const AllianceLibrary* CellsModel::getLibrary () const + { return (_ilibrary != _libraries.end()) ? (const AllianceLibrary*)_ilibrary->first : NULL; } + inline const std::vector& CellsModel::getCellsDatas () const { return _ilibrary->second; } inline std::vector& CellsModel::getCellsDatas () { return _ilibrary->second; } diff --git a/crlcore/src/LibraryManager/crlcore/CellsWidget.h b/crlcore/src/LibraryManager/crlcore/CellsWidget.h index 2719e236..243f9909 100644 --- a/crlcore/src/LibraryManager/crlcore/CellsWidget.h +++ b/crlcore/src/LibraryManager/crlcore/CellsWidget.h @@ -47,6 +47,7 @@ namespace CRL { void selectedCell ( CellDatas* ); public slots: void updateSelected (); + void updateLibrary (); void selectCurrent ( const QModelIndex& index, const QModelIndex& ); void setLibrary ( const AllianceLibrary* ); private: diff --git a/crlcore/src/LibraryManager/crlcore/LibraryManager.h b/crlcore/src/LibraryManager/crlcore/LibraryManager.h index 50cfbfc5..4dd2ec6b 100644 --- a/crlcore/src/LibraryManager/crlcore/LibraryManager.h +++ b/crlcore/src/LibraryManager/crlcore/LibraryManager.h @@ -50,10 +50,11 @@ namespace CRL { LibraryManager ( QWidget* parent=NULL ); inline void setCellViewer ( CellViewer* ); inline CellViewer* getCellViewer () const; - public slots: + public slots: void toggleShow (); void setLibrary ( const AllianceLibrary* library ); CellViewer* openCell ( Cell*, unsigned int flags ); + void updateLibrary ( Cell* ); private: LibrariesWidget* _librariesWidget; CellsWidget* _cellsWidget; diff --git a/crlcore/src/ccore/AllianceFramework.cpp b/crlcore/src/ccore/AllianceFramework.cpp index 01b83216..d11f8010 100644 --- a/crlcore/src/ccore/AllianceFramework.cpp +++ b/crlcore/src/ccore/AllianceFramework.cpp @@ -15,9 +15,10 @@ #include #include "vlsisapd/utilities/Path.h" +#include "hurricane/Initializer.h" #include "hurricane/Warning.h" -#include "hurricane/Technology.h" #include "hurricane/DataBase.h" +#include "hurricane/Technology.h" #include "hurricane/Library.h" #include "hurricane/Cell.h" #include "hurricane/Instance.h" @@ -35,10 +36,14 @@ namespace CRL { using namespace std::placeholders; + using Hurricane::Initializer; + using Hurricane::JsonTypes; + using Hurricane::JsonArray; using Hurricane::Warning; using Hurricane::tab; using Hurricane::Graphics; using Hurricane::ForEachIterator; + using Hurricane::getCollection; using Hurricane::Instance; using Hurricane::PrivateProperty; @@ -53,6 +58,8 @@ namespace CRL { static Name getPropertyName (); virtual Name getName () const; inline AllianceFramework* getFramework () const; + virtual bool hasJson () const; + virtual void toJson ( JsonWriter*, const DBo* ) const; virtual string _getTypeName () const; virtual Record* _getRecord () const; private: @@ -60,10 +67,19 @@ namespace CRL { AllianceFramework* _framework; private: inline AllianceFrameworkProperty ( AllianceFramework* ); + public: + class JsonProperty : public JsonObject { + public: + static void initialize (); + JsonProperty ( unsigned long flags ); + virtual string getTypeName () const; + virtual JsonProperty* clone ( unsigned long ) const; + virtual void toData ( JsonStack& ); + }; }; - Name AllianceFrameworkProperty::_name = "AllianceFramework"; + Name AllianceFrameworkProperty::_name = "AllianceFrameworkProperty"; inline AllianceFrameworkProperty::AllianceFrameworkProperty ( AllianceFramework* af ) @@ -107,6 +123,56 @@ namespace CRL { } + bool AllianceFrameworkProperty::hasJson () const + { return true; } + + + void AllianceFrameworkProperty::toJson ( JsonWriter* w, const DBo* ) const + { + w->startObject(); + std::string tname = getString(getPropertyName()); + jsonWrite( w, "@typename" , tname ); + jsonWrite( w, "_framework", _framework ); + w->endObject(); + } + + + Initializer jsonFrameworkPropertyInit ( 20 ); + + + AllianceFrameworkProperty::JsonProperty::JsonProperty ( unsigned long flags ) + : JsonObject(flags) + { + add( "_framework", typeid(AllianceFramework*) ); + } + + + string AllianceFrameworkProperty::JsonProperty::getTypeName () const + { return getString(AllianceFrameworkProperty::getPropertyName()); } + + + void AllianceFrameworkProperty::JsonProperty::initialize () + { JsonTypes::registerType( new JsonProperty (JsonWriter::RegisterMode) ); } + + + AllianceFrameworkProperty::JsonProperty* AllianceFrameworkProperty::JsonProperty::clone ( unsigned long flags ) const + { return new JsonProperty ( flags ); } + + + void AllianceFrameworkProperty::JsonProperty::toData ( JsonStack& stack ) + { + check( stack, "AllianceFrameworkProperty::JsonProperty::toData" ); + + DBo* dbo = stack.back_dbo(); + AllianceFramework* framework = get(stack,"_framework"); + AllianceFrameworkProperty* property + = AllianceFrameworkProperty::create(framework); + if (dbo) dbo->put( property ); + + update( stack, property ); + } + + // ------------------------------------------------------------------- // Class : "CRL::AllianceFramework". @@ -173,7 +239,7 @@ namespace CRL { void AllianceFramework::_bindLibraries () { DataBase* db = DataBase::getDB (); - unsigned int flags = InSearchPath; + unsigned int flags = AppendLibrary; SearchPath& LIBRARIES = _environment.getLIBRARIES (); Library* rootLibrary = db->getRootLibrary (); @@ -239,7 +305,7 @@ namespace CRL { } - AllianceLibrary* AllianceFramework::getAllianceLibrary ( const Name &libName, unsigned int& flags ) + AllianceLibrary* AllianceFramework::getAllianceLibrary ( const Name &libName, unsigned int flags ) { for ( size_t ilib=0 ; ilib<_libraries.size() ; ++ilib ) { if ( _libraries[ilib]->getLibrary()->getName() == libName ) @@ -331,7 +397,7 @@ namespace CRL { } - AllianceLibrary* AllianceFramework::createLibrary ( const string& path, unsigned int& flags, string libName ) + AllianceLibrary* AllianceFramework::createLibrary ( const string& path, unsigned int flags, string libName ) { if ( libName.empty() ) libName = SearchPath::extractLibName(path); @@ -339,7 +405,7 @@ namespace CRL { string dupLibName = libName; for ( size_t duplicate=1 ; true ; ++duplicate ) { - AllianceLibrary* library = getAllianceLibrary ( dupLibName, flags ); + AllianceLibrary* library = getAllianceLibrary ( dupLibName, flags & ~CreateLibrary ); if (library == NULL) break; ostringstream oss; @@ -355,31 +421,38 @@ namespace CRL { // } SearchPath& LIBRARIES = _environment.getLIBRARIES (); - if ( not (flags & InSearchPath) ) LIBRARIES.prepend ( path, dupLibName ); - else LIBRARIES.select ( path ); + if ( not (flags & AppendLibrary) ) LIBRARIES.prepend ( path, dupLibName ); + else LIBRARIES.select ( path ); - AllianceLibrary* library = new AllianceLibrary ( path, Library::create(getParentLibrary(),dupLibName) ); + Library* hlibrary = getParentLibrary()->getLibrary( dupLibName ); + if (not hlibrary) + hlibrary = Library::create( getParentLibrary(), dupLibName ); + + AllianceLibrary* alibrary = new AllianceLibrary ( path, hlibrary ); AllianceLibraries::iterator ilib = _libraries.begin(); - for ( size_t i=0 ; igetLibrary()) ) flags |= HasCatalog; + if ( _catalog.loadFromFile(catalog,alibrary->getLibrary()) ) flags |= HasCatalog; ParserFormatSlot& parser = _parsers.getParserSlot ( path, Catalog::State::Physical, _environment ); - if ( not parser.loadByLib() ) return library; + if ( not parser.loadByLib() ) return alibrary; // Load the whole library. - if ( ! _readLocate(dupLibName,Catalog::State::State::Logical,true) ) return library; + if ( ! _readLocate(dupLibName,Catalog::State::State::Logical,true) ) return alibrary; // Call the parser function. - (parser.getParsLib())( _environment.getLIBRARIES().getSelected() , library->getLibrary() , _catalog ); + (parser.getParsLib())( _environment.getLIBRARIES().getSelected() , alibrary->getLibrary() , _catalog ); - return library; + return alibrary; } @@ -673,4 +746,53 @@ namespace CRL { } + void AllianceFramework::toJson ( JsonWriter* w ) const + { + w->startObject(); + jsonWrite( w, "@typename" , _getTypeName() ); + jsonWrite( w, "_environment", &_environment ); + jsonWrite( w, "+libraries" , getCollection(getAllianceLibraries()) ); + // Environement & Catalog... + w->endObject(); + } + + +// ------------------------------------------------------------------- +// Class : "CRL::JsonAllianceFramework". + + Initializer jsonFrameworkInit ( 20 ); + + + JsonAllianceFramework::JsonAllianceFramework (unsigned long flags ) + : JsonObject(flags) + { + // Environement & Catalog... + add( "_environment", typeid(Environment*) ); + add( "+libraries" , typeid(JsonArray) ); + } + + + string JsonAllianceFramework::getTypeName () const + { return "AllianceFramework"; } + + + void JsonAllianceFramework::initialize () + { JsonTypes::registerType( new JsonAllianceFramework (JsonWriter::RegisterMode) ); } + + + JsonAllianceFramework* JsonAllianceFramework::clone ( unsigned long flags ) const + { return new JsonAllianceFramework ( flags ); } + + + void JsonAllianceFramework::toData ( JsonStack& stack ) + { + check( stack, "JsonAllianceFramework::toData" ); + + // It's a singleton. Do not create it... + AllianceFramework* framework = AllianceFramework::get(); + + update( stack, framework ); + } + + } // End of CRL namespace. diff --git a/crlcore/src/ccore/AllianceLibrary.cpp b/crlcore/src/ccore/AllianceLibrary.cpp index 2e468d3f..7d5f3e8e 100644 --- a/crlcore/src/ccore/AllianceLibrary.cpp +++ b/crlcore/src/ccore/AllianceLibrary.cpp @@ -1,67 +1,38 @@ - // -*- C++ -*- // -// This file is part of the Coriolis Project. -// Copyright (C) Laboratoire LIP6 - Departement ASIM -// Universite Pierre et Marie Curie +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2008-2015, All Rights Reserved // -// Main contributors : -// Christophe Alexandre -// Sophie Belloeil -// Hugo Clément -// Jean-Paul Chaput -// Damien Dupuis -// Christian Masson -// Marek Sroka -// -// The Coriolis Project is free software; you can redistribute it -// and/or modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// The Coriolis Project is distributed in the hope that it will be -// useful, but WITHOUT ANY WARRANTY; without even the implied warranty -// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with the Coriolis Project; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA -// -// License-Tag -// Authors-Tag -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | C O R I O L I S | // | Alliance / Hurricane Interface | // | | -// | Author : Rémy Escassut | -// | E-mail : Remy.Escassut@silvaco.com | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | -// | C++ Header : "./AllianceLibrary.cpp" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x - - - - -# include "hurricane/Library.h" - -# include "crlcore/Utilities.h" -# include "crlcore/AllianceLibrary.h" +// | C++ Module : "./AllianceLibrary.cpp" | +// +-----------------------------------------------------------------+ +#include "hurricane/Warning.h" +#include "hurricane/SharedPath.h" +#include "hurricane/Library.h" +#include "hurricane/DataBase.h" +#include "crlcore/Utilities.h" +#include "crlcore/AllianceLibrary.h" +#include "crlcore/AllianceFramework.h" namespace CRL { + using namespace std; + using Hurricane::Initializer; + using Hurricane::JsonTypes; + using Hurricane::Warning; + using Hurricane::Name; + using Hurricane::SharedPath; + using Hurricane::DataBase; + // ------------------------------------------------------------------- // Class : "AllianceDirectory". @@ -113,6 +84,89 @@ namespace CRL { } + void AllianceLibrary::toJson ( JsonWriter* w ) const + { + w->startObject(); + jsonWrite( w, "@typename", _getTypeName() ); + jsonWrite( w, "_path" , _path ); + jsonWrite( w, "_library" , _library->getHierarchicalName() ); + w->endObject(); + } + + +// ------------------------------------------------------------------- +// Class : "JsonAllianceLibrary". + + Initializer jsonAllianceLibraryInit ( 0 ); + + + void JsonAllianceLibrary::initialize () + { JsonTypes::registerType( new JsonAllianceLibrary (JsonWriter::RegisterMode) ); } + + + JsonAllianceLibrary::JsonAllianceLibrary ( unsigned long flags ) + : JsonObject(flags) + { + add( "_path" , typeid(string) ); + add( "_library", typeid(string) ); + } + + string JsonAllianceLibrary::getTypeName () const + { return "AllianceLibrary"; } + + + JsonAllianceLibrary* JsonAllianceLibrary::clone ( unsigned long flags ) const + { return new JsonAllianceLibrary ( flags ); } + + + void JsonAllianceLibrary::toData ( JsonStack& stack ) + { + check( stack, "JsonAllianceLibrary::toData" ); + + string libDbPath = get( stack,"_library" ); + string libOsPath = get( stack,"_path" ); + + AllianceFramework* af = AllianceFramework::get(); + Library* library = DataBase::getDB()->getLibrary( libDbPath + , DataBase::CreateLib|DataBase::WarnCreateLib ); + AllianceLibrary* aLibrary = NULL; + + if (library) { + aLibrary = af->getAllianceLibrary( library ); + } + if (not aLibrary) { + char separator = SharedPath::getNameSeparator(); + size_t dot = libDbPath.rfind( separator ); + Name libName = libDbPath.substr(dot+1); + aLibrary = af->getAllianceLibrary( libName, AllianceFramework::AppendLibrary ); + + if (not aLibrary) { + aLibrary = af->getAllianceLibrary( libOsPath + , AllianceFramework::CreateLibrary + | AllianceFramework::AppendLibrary ); + } + if (not library) library = aLibrary->getLibrary(); + } + + if (aLibrary->getLibrary() != library) { + cerr << Warning( "JsonAllianceLibrary::toData(): Underlying Hurricane Library discrepency for \"%s\".\n" + " (may be caused by a change in search path order)" + , getString(library->getName()).c_str() + ) << endl; + } + if (aLibrary->getPath() != Name(libOsPath)) { + cerr << Warning( "JsonAllianceLibrary::toData(): Underlying OS path discrepency for \"%s\":\n" + " - Blob: %s\n" + " - System: %s" + , getString(library->getName()).c_str() + , libOsPath.c_str() + , getString(aLibrary->getPath()).c_str() + ) << endl; + } + + update( stack, aLibrary ); + } + } // End of CRL namespace. diff --git a/crlcore/src/ccore/Catalog.cpp b/crlcore/src/ccore/Catalog.cpp index 8f691bd8..dae1542b 100644 --- a/crlcore/src/ccore/Catalog.cpp +++ b/crlcore/src/ccore/Catalog.cpp @@ -17,15 +17,25 @@ # include using namespace std; +#include "hurricane/Initializer.h" +#include "hurricane/SharedPath.h" #include "hurricane/Collection.h" +#include "hurricane/DataBase.h" #include "hurricane/Library.h" #include "hurricane/Name.h" #include "crlcore/Utilities.h" #include "crlcore/Catalog.h" +#include "crlcore/AllianceFramework.h" namespace CRL { + using Hurricane::inltrace; + using Hurricane::tab; + using Hurricane::Initializer; + using Hurricane::JsonTypes; + using Hurricane::SharedPath; + using Hurricane::DataBase; const char* MissingStateProperty = "%s:\n\n Missing Catalog State Property in cell \"%s\".\n"; @@ -89,6 +99,81 @@ namespace CRL { return record; } + + void Catalog::State::toJson ( JsonWriter* w ) const + { + w->startObject(); + jsonWrite( w, "@typename", _getTypeName() ); + jsonWrite( w, "_flags" , _getString() ); + jsonWrite( w, "_depth" , _depth ); + + string cellName = ""; + if (_cell) cellName = getString( _cell->getHierarchicalName() ); + jsonWrite( w, "_cell", cellName ); + w->endObject(); + } + + + Initializer jsonCatalogStateInit ( 20 ); + + + Catalog::State::JsonState::JsonState ( unsigned long flags ) + : JsonObject(flags) + { + add( "_flags", typeid(string) ); + add( "_depth", typeid(int64_t) ); + add( "_cell" , typeid(string) ); + } + + + string Catalog::State::JsonState::getTypeName () const + { return "Catalog::State"; } + + + void Catalog::State::JsonState::initialize () + { JsonTypes::registerType( new JsonState (JsonWriter::RegisterMode) ); } + + + Catalog::State::JsonState* Catalog::State::JsonState::clone ( unsigned long flags ) const + { return new JsonState ( flags ); } + + + void Catalog::State::JsonState::toData ( JsonStack& stack ) + { + check( stack, "Catalog::State::JsonState::toData" ); + + string cellPath = get ( stack, "_cell" ); + string sflags = get ( stack, "_flags" ); + unsigned int depth = get( stack, "_depth" ); + + char separator = SharedPath::getNameSeparator(); + size_t dot = cellPath.rfind( separator ); + string cellName = cellPath.substr(dot+1); + string libraryName = cellPath.substr(0,dot); + + Library* library = DataBase::getDB()->getLibrary( libraryName + , DataBase::CreateLib|DataBase::WarnCreateLib ); + Cell* cell = library->getCell( cellName ); + + Catalog* catalog = AllianceFramework::get()->getCatalog(); + Catalog::State* state = catalog->getState( cellName ); + + if (not state) state = catalog->getState( cellName, true ); + if (state->getCell () != cell ) state->setCell ( cell ); + if (state->getLibrary() != library) state->setLibrary( library ); + + state->setDepth( depth ); + state->setFlattenLeaf( (sflags[0] == 'C') ); + state->setFeed( (sflags[1] == 'F') ); + state->setPad( (sflags[2] == 'P') ); + state->setGds( (sflags[3] == 'G') ); + state->setDelete( (sflags[4] == 'D') ); + state->setInMemory( (sflags[5] == 'm') ); + + update( stack, state ); + } + + // ------------------------------------------------------------------- // Class : "Catalog". @@ -248,8 +333,7 @@ namespace CRL { // ------------------------------------------------------------------- // Class : "CatalogProperty" - - Name CatalogProperty::_name = "Alliance Catalog State"; + Name CatalogProperty::_name = "Catalog::State::Property"; CatalogProperty* CatalogProperty::create ( Catalog::State* state ) @@ -306,6 +390,76 @@ namespace CRL { } + bool CatalogProperty::hasJson () const + { return true; } + + + void CatalogProperty::toJson ( JsonWriter* w, const DBo* ) const + { + w->startObject(); + std::string tname = getString(getPropertyName()); + jsonWrite( w, "@typename", tname ); + jsonWrite( w, "_state" , _state ); + w->endObject(); + } + + +// ------------------------------------------------------------------- +// Class : "JsonCatalogProperty" + + Initializer jsonCatalogPropertyInit ( 20 ); + + + JsonCatalogProperty::JsonCatalogProperty ( unsigned long flags ) + : JsonObject(flags) + { + add( "_state", typeid(Catalog::State*) ); + } + + + string JsonCatalogProperty::getTypeName () const + { return getString(CatalogProperty::getPropertyName()); } + + + void JsonCatalogProperty::initialize () + { JsonTypes::registerType( new JsonCatalogProperty (JsonWriter::RegisterMode) ); } + + + JsonCatalogProperty* JsonCatalogProperty::clone ( unsigned long flags ) const + { return new JsonCatalogProperty ( flags ); } + + + void JsonCatalogProperty::toData ( JsonStack& stack ) + { + check( stack, "JsonCatalogProperty::toData" ); + + DBo* dbo = stack.back_dbo(); + Catalog::State* state = get( stack, "_state" ); + CatalogProperty* property = NULL; + + ltrace(51) << "topDBo:" << dbo << endl; + + Cell* cell = dynamic_cast( dbo ); + if (cell) { + Property* base = cell->getProperty( CatalogProperty::getPropertyName() ); + if (base) { + property = static_cast( base ); + if (property->getState() != state) { + cerr << Error( "JsonCatalogProperty::toData(): State object incoherency on Cell \"%s\"." + , getString(cell->getName()).c_str() + ) << endl; + } + } else { + property = CatalogProperty::create( state ); + cell->put( property ); + } + } + // NULL Cell means we are parsing the Catalog. + + update( stack, property ); + } + + // ------------------------------------------------------------------- // Class : "CatalogExtension" diff --git a/crlcore/src/ccore/Environment.cpp b/crlcore/src/ccore/Environment.cpp index 9bc6bcc6..016ad3ff 100644 --- a/crlcore/src/ccore/Environment.cpp +++ b/crlcore/src/ccore/Environment.cpp @@ -22,6 +22,7 @@ #include "crlcore/Utilities.h" #include "crlcore/XmlParser.h" #include "crlcore/Environment.h" +#include "crlcore/AllianceFramework.h" namespace { @@ -505,6 +506,12 @@ namespace { namespace CRL { + using Hurricane::Initializer; + using Hurricane::JsonTypes; + + +// ------------------------------------------------------------------- +// Class : "Environment". Environment::Environment () : _CORIOLIS_TOP (CORIOLIS_TOP) @@ -753,4 +760,83 @@ namespace CRL { } + void Environment::toJson ( JsonWriter* w ) const + { + w->startObject(); + jsonWrite( w, "@typename" , _getTypeName() ); + jsonWrite( w, "_CORIOLIS_TOP", _CORIOLIS_TOP ); + jsonWrite( w, "_displayStyle", _displayStyle ); + jsonWrite( w, "_SCALE_X" , _SCALE_X ); + jsonWrite( w, "_IN_LO" , _IN_LO ); + jsonWrite( w, "_IN_PH" , _IN_PH ); + jsonWrite( w, "_OUT_LO" , _OUT_LO ); + jsonWrite( w, "_OUT_PH" , _OUT_PH ); + jsonWrite( w, "_POWER" , _POWER ); + jsonWrite( w, "_GROUND" , _GROUND ); + jsonWrite( w, "_CLOCK" , _CLOCK ); + jsonWrite( w, "_BLOCKAGE" , _BLOCKAGE ); + jsonWrite( w, "_pad" , _pad ); + jsonWrite( w, "_CATALOG" , _CATALOG ); + w->endObject(); + } + + +// ------------------------------------------------------------------- +// Class : "JsonEnvironment". + + Initializer jsonEnvironmentInit ( 0 ); + + + void JsonEnvironment::initialize () + { JsonTypes::registerType( new JsonEnvironment (JsonWriter::RegisterMode) ); } + + + JsonEnvironment::JsonEnvironment ( unsigned long flags ) + : JsonObject(flags) + { + add( "_CORIOLIS_TOP", typeid(string) ); + add( "_displayStyle", typeid(string) ); + add( "_SCALE_X" , typeid(int64_t) ); + add( "_IN_LO" , typeid(string) ); + add( "_IN_PH" , typeid(string) ); + add( "_OUT_LO" , typeid(string) ); + add( "_OUT_PH" , typeid(string) ); + add( "_POWER" , typeid(string) ); + add( "_GROUND" , typeid(string) ); + add( "_BLOCKAGE" , typeid(string) ); + add( "_pad" , typeid(string) ); + add( "_CATALOG" , typeid(string) ); + add( "_CLOCK" , typeid(string) ); + } + + string JsonEnvironment::getTypeName () const + { return "Environment"; } + + + JsonEnvironment* JsonEnvironment::clone ( unsigned long flags ) const + { return new JsonEnvironment ( flags ); } + + + void JsonEnvironment::toData ( JsonStack& stack ) + { + check( stack, "JsonEnvironment::toData" ); + + Environment* environement = AllianceFramework::get()->getEnvironment(); + environement->setDisplayStyle( get (stack,"_displayStyle").c_str() ); + environement->setSCALE_X ( get(stack,"_SCALE_X" ) ); + environement->setIN_LO ( get (stack,"_IN_LO" ).c_str() ); + environement->setIN_PH ( get (stack,"_IN_PH" ).c_str() ); + environement->setOUT_LO ( get (stack,"_OUT_LO" ).c_str() ); + environement->setOUT_PH ( get (stack,"_OUT_PH" ).c_str() ); + environement->setPOWER ( get (stack,"_POWER" ).c_str() ); + environement->setGROUND ( get (stack,"_GROUND" ).c_str() ); + environement->setCLOCK ( get (stack,"_CLOCK" ).c_str() ); + environement->setBLOCKAGE ( get (stack,"_BLOCKAGE" ).c_str() ); + environement->setPad ( get (stack,"_pad" ).c_str() ); + environement->setCATALOG ( get (stack,"_CATALOG" ).c_str() ); + + update( stack, environement ); + } + + } // End of CRL namespace. diff --git a/crlcore/src/ccore/crlcore/AllianceFramework.h b/crlcore/src/ccore/crlcore/AllianceFramework.h index e41b43f1..be5ca85f 100644 --- a/crlcore/src/ccore/crlcore/AllianceFramework.h +++ b/crlcore/src/ccore/crlcore/AllianceFramework.h @@ -1,4 +1,3 @@ - // -*- C++ -*- // // This file is part of the Coriolis Software. @@ -18,17 +17,19 @@ #ifndef CRL_ALLIANCE_FRAMEWORK_H #define CRL_ALLIANCE_FRAMEWORK_H -#include -#include -#include "hurricane/Cell.h" -#include "crlcore/Environment.h" -#include "crlcore/AllianceLibrary.h" -#include "crlcore/Catalog.h" -#include "crlcore/ParsersDrivers.h" +#include +#include +#include "hurricane/Cell.h" +#include "crlcore/Environment.h" +#include "crlcore/AllianceLibrary.h" +#include "crlcore/Catalog.h" +#include "crlcore/ParsersDrivers.h" namespace CRL { + using Hurricane::JsonObject; + using Hurricane::JsonStack; using Hurricane::Cell; using Hurricane::Net; class RoutingGauge; @@ -37,8 +38,13 @@ namespace CRL { class AllianceFramework { public: - enum InstancesCountFlags { Recursive=0x1, IgnoreFeeds=0x2 }; - enum LibraryFlags { CreateLibrary=0x1, InSearchPath=0x2, HasCatalog=0x4 }; + enum InstancesCountFlags { Recursive = (1<<0) + , IgnoreFeeds = (1<<1) + }; + enum LibraryFlags { CreateLibrary = (1<<0) + , AppendLibrary = (1<<1) + , HasCatalog = (1<<2) + }; public: // Constructors. static AllianceFramework* create (); @@ -72,9 +78,9 @@ namespace CRL { inline Library* getParentLibrary (); Library* getLibrary ( unsigned int index ); AllianceLibrary* getAllianceLibrary ( unsigned int index ); - AllianceLibrary* getAllianceLibrary ( const Name& libName, unsigned int& flags ); + AllianceLibrary* getAllianceLibrary ( const Name& libName, unsigned int flags ); AllianceLibrary* getAllianceLibrary ( Library* ); - AllianceLibrary* createLibrary ( const string& path, unsigned int& flags, string libName="" ); + AllianceLibrary* createLibrary ( const string& path, unsigned int flags, string libName="" ); inline const AllianceLibraries& getAllianceLibraries () const; void saveLibrary ( Library* ); void saveLibrary ( AllianceLibrary* ); @@ -95,6 +101,7 @@ namespace CRL { unsigned int loadLibraryCells ( const Name& ); static size_t getInstancesCount ( Cell*, unsigned int flags ); // Hurricane Managment. + void toJson ( JsonWriter* ) const; inline string _getTypeName () const; string _getString () const; Record* _getRecord () const; @@ -159,6 +166,16 @@ namespace CRL { inline string AllianceFramework::_getTypeName () const { return "AllianceFramework"; } + class JsonAllianceFramework : public JsonObject { + public: + static void initialize (); + JsonAllianceFramework( unsigned long ); + virtual string getTypeName () const; + virtual JsonAllianceFramework* clone ( unsigned long ) const; + virtual void toData ( JsonStack& ); + }; + + } // CRL namespace. diff --git a/crlcore/src/ccore/crlcore/AllianceLibrary.h b/crlcore/src/ccore/crlcore/AllianceLibrary.h index 64e8cd70..2bce1864 100644 --- a/crlcore/src/ccore/crlcore/AllianceLibrary.h +++ b/crlcore/src/ccore/crlcore/AllianceLibrary.h @@ -30,7 +30,8 @@ namespace Hurricane { namespace CRL { using std::vector; - + using Hurricane::JsonObject; + using Hurricane::JsonStack; using Hurricane::Name; using Hurricane::Library; using Hurricane::Record; @@ -53,6 +54,7 @@ namespace CRL { inline const Name& getPath () const; inline Library* getLibrary () const; // Hurricane management. + void toJson ( JsonWriter* ) const; inline std::string _getTypeName () const; std::string _getString () const; Record* _getRecord () const; @@ -74,6 +76,19 @@ namespace CRL { inline std::string AllianceLibrary::_getTypeName () const { return _TName("AllianceLibrary"); } +// ------------------------------------------------------------------- +// Class : "JsonAllianceLibrary". + + class JsonAllianceLibrary : public JsonObject { + public: + static void initialize (); + JsonAllianceLibrary ( unsigned long flags ); + virtual std::string getTypeName () const; + virtual JsonAllianceLibrary* clone ( unsigned long flags ) const; + virtual void toData ( JsonStack& ); + }; + + } // CRL namespace. diff --git a/crlcore/src/ccore/crlcore/Catalog.h b/crlcore/src/ccore/crlcore/Catalog.h index 0b272450..820c54a8 100644 --- a/crlcore/src/ccore/crlcore/Catalog.h +++ b/crlcore/src/ccore/crlcore/Catalog.h @@ -34,6 +34,8 @@ namespace CRL { using std::string; using std::map; + using Hurricane::JsonObject; + using Hurricane::JsonStack; using Hurricane::_TName; using Hurricane::Name; using Hurricane::Record; @@ -106,6 +108,7 @@ namespace CRL { inline bool setDelete ( bool value ); inline bool setPhysical ( bool value ); inline bool setLogical ( bool value ); + inline bool setInMemory ( bool value ); // Accessors. inline Cell* getCell () const; inline Library* getLibrary () const; @@ -116,6 +119,7 @@ namespace CRL { inline Library* setLibrary ( Library* library ); inline void setDepth ( unsigned int depth ); // Hurricane Management. + void toJson ( JsonWriter* w ) const; inline string _getTypeName () const; string _getString () const; Record* _getRecord () const; @@ -126,7 +130,18 @@ namespace CRL { unsigned int _depth; Cell* _cell; Library* _library; - }; + + // Json Property. + public: + class JsonState : public JsonObject { + public: + static void initialize (); + JsonState ( unsigned long flags ); + virtual string getTypeName () const; + virtual JsonState* clone ( unsigned long ) const; + virtual void toData ( JsonStack& ); + }; + }; private: // Attributes. @@ -142,7 +157,6 @@ namespace CRL { // ------------------------------------------------------------------- // Class : "CRL::CatalogProperty". - class CatalogProperty : public PrivateProperty { public: @@ -154,6 +168,8 @@ namespace CRL { inline Catalog::State* getState () const; inline void setState ( Catalog::State* state ); virtual void onReleasedBy ( DBo* owner ); + virtual bool hasJson () const; + virtual void toJson ( JsonWriter* w, const DBo* ) const; virtual string _getTypeName () const; virtual string _getString () const; virtual Record* _getRecord () const; @@ -168,6 +184,19 @@ namespace CRL { }; +// ------------------------------------------------------------------- +// Class : "CRL::JsonCatalogProperty". + + class JsonCatalogProperty : public JsonObject { + public: + static void initialize (); + JsonCatalogProperty ( unsigned long ); + virtual string getTypeName () const; + virtual JsonCatalogProperty* clone ( unsigned long ) const; + virtual void toData ( JsonStack& ); + }; + + // ------------------------------------------------------------------- // Inline Functions. @@ -193,6 +222,7 @@ namespace CRL { inline bool Catalog::State::setDelete ( bool value ) { return setFlags(Delete ,value); } inline bool Catalog::State::setPhysical ( bool value ) { return setFlags(Physical ,value); } inline bool Catalog::State::setLogical ( bool value ) { return setFlags(Logical ,value); } + inline bool Catalog::State::setInMemory ( bool value ) { return setFlags(InMemory ,value); } inline Library* Catalog::State::setLibrary ( Library* library ) { return _library = library; } inline void Catalog::State::setDepth ( unsigned int depth ) { _depth = depth; } inline Cell* Catalog::State::getCell () const { return _cell; } diff --git a/crlcore/src/ccore/crlcore/Environment.h b/crlcore/src/ccore/crlcore/Environment.h index facceecd..0824bedf 100644 --- a/crlcore/src/ccore/crlcore/Environment.h +++ b/crlcore/src/ccore/crlcore/Environment.h @@ -19,11 +19,18 @@ #include #include -#include +#include "hurricane/Commons.h" +#include "crlcore/SearchPath.h" namespace CRL { + using Hurricane::JsonObject; + using Hurricane::JsonStack; + + +// ------------------------------------------------------------------- +// Class : "Environment". class Environment { public: @@ -76,6 +83,7 @@ namespace CRL { void addSYSTEM_LIBRARY ( const char* value, const char* libName, unsigned int mode=Append ); // Methods. std::string getPrint () const; + void toJson ( JsonWriter* ) const; inline std::string _getTypeName () const; std::string _getString () const; Record* _getRecord () const; @@ -134,6 +142,19 @@ namespace CRL { inline std::string Environment::_getTypeName () const { return "Environment"; } +// ------------------------------------------------------------------- +// Class : "JsonEnvironment". + + class JsonEnvironment : public JsonObject { + public: + static void initialize (); + JsonEnvironment ( unsigned long flags ); + virtual std::string getTypeName () const; + virtual JsonEnvironment* clone ( unsigned long flags ) const; + virtual void toData ( JsonStack& ); + }; + + } // CRL namespace. diff --git a/documentation/UsersGuide/UsersGuide.html b/documentation/UsersGuide/UsersGuide.html index affefcb6..de7cb191 100644 --- a/documentation/UsersGuide/UsersGuide.html +++ b/documentation/UsersGuide/UsersGuide.html @@ -41,79 +41,80 @@
  • Release 1.0.1963
  • Release 1.0.2049
  • Release v2.0.1
  • -
  • Release v2.1
  • +
  • Release v2.1
  • +
  • Release v2.2
  • -
  • Installation
      -
    • Fixed Directory Tree
    • -
    • Building Coriolis
        -
      • Building the Devel Branch
      • -
      • Additionnal Requirement under MacOS
      • +
      • Installation
      • -
      • Documentation
          -
        • General Software Architecture
        • +
        • Documentation
        • -
        • Coriolis Configuration & Initialisation
            -
          • First Stage: Symbolic Technology Selection
          • -
          • Second Stage: Technology Configuration Loading
          • -
          • Configuration Helpers
              -
            • Alliance Helper
            • -
            • Tools Configuration Helpers
            • +
            • Coriolis Configuration & Initialisation
            • -
            • CGT - The Graphical Interface
            • -
            • Viewer & Tools
                -
              • Stratus Netlist Capture
              • -
              • The Hurricane Data-Base
              • -
              • Synthetizing and loading a design
                  -
                • Synthesis under Yosys
                • -
                • Synthesis under Alliance
                • +
                • CGT - The Graphical Interface
                • +
                • Viewer & Tools
                  -

                  Synthetizing and loading a design

                  +

                  Synthetizing and loading a design

                  Coriolis supports several file formats. It can load all file format from the Alliance toolchain (.ap for layout, behavioural and structural vhdl .vbe and .vst), BLIF netlist format as well as benchmark formats from the ISPD contests.

                  It can be compiled with LEF/DEF support, although it requires acceptance of the SI2 license and may not be compiled in your version of the software.

                  -

                  Synthesis under Yosys

                  +

                  Synthesis under Yosys

                  You can create a BLIF file from the Yosys synthetizer, which can be imported under Coriolis. Most libraries are specified as a .lib liberty file and a .lef LEF file. Yosys opens most .lib files with minor modifications, but LEF support in Coriolis relies on SI2. @@ -901,13 +919,13 @@ If Coriolis hasn't been compiled against it, the library is given in Yosys and import it (as Blif without the extension) under Coriolis to perform place&route.

                  -

                  Synthesis under Alliance

                  +

                  Synthesis under Alliance

                  Alliance is an older toolchain but has been extensively used for years. Coriolis can import and write Alliance designs and libraries directly.

                  -

                  Etesian -- Placer

                  +

                  Etesian -- Placer

                  The Etesian placer is a state of the art (as of 2015) analytical placer. It is within 5% of other placers' solutions, but is normally a bit worse than ePlace. This Coriolis tool is actually an encapsulation of Coloquinte which is the placer.

                  @@ -947,7 +965,7 @@ Timing and routability analysis are not included either, and the returned placem may be unroutable.


                  -

                  Etesian Configuration Parameters

                  +

                  Etesian Configuration Parameters

                  @@ -1018,7 +1036,7 @@ More refreshing slows the placer.

                  -

                  Knik -- Global Router

                  +

                  Knik -- Global Router

                  The quality of Knik global routing solutions are equivalent to those of FGR 1.0. For an in-depth description of Knik algorithms, you may download the thesis of D. Dupuis avalaible from here~: Knik Thesis.

                  @@ -1033,7 +1051,7 @@ a global routing solution can be saved to disk and reloaded for later u
                  -

                  Kite -- Detailed Router

                  +

                  Kite -- Detailed Router

                  Kite no longer suffers from the limitations of Nero. It can route big designs as its runtime and memory footprint is almost linear (with respect to the number of gates). It has successfully routed design of more than 150K gates. @@ -1084,7 +1102,7 @@ that step.

                  Kite (on GCells) until the routing is finalized. Special layers appears to that effect in the The Layers&Go Tab.

                  -

                  Kite Configuration Parameters

                  +

                  Kite Configuration Parameters

                  As Knik is only called through Kite, it's parameters also have the kite. prefix.

                  The Katabatic parameters control the layer assignment step.

                  @@ -1208,7 +1226,7 @@ topological modification
                  -

                  Executing Python Scripts in Cgt

                  +

                  Executing Python Scripts in Cgt

                  Python/Stratus scripts can be executed either in text or graphical mode.

                  Note

                  @@ -1228,7 +1246,7 @@ initializations and before any other argument is processed.

                  For more explanation on Python scripts see Python Interface to Coriolis.

                  -

                  Printing & Snapshots

                  +

                  Printing & Snapshots

                  Printing or saving into a pdf is fairly simple, just uses the File -> Print menu or the CTRL+P shortcut to open the dialog box.

                  The print functionality uses exactly the same rendering mechanism as for the @@ -1271,7 +1289,7 @@ or similar.

                  Saving into an image is subject to the same remarks as for pdf.

                  @@ -1408,7 +1426,7 @@ in which this model is instanciated).
                  -

                  Cgt Command Line Options

                  +

                  Cgt Command Line Options

                  Appart from the obvious --text options, all can be used for text and graphical mode.

                  @@ -1493,7 +1511,7 @@ routed design :

                  @@ -1566,7 +1584,7 @@ To generate one set this flag to True
                  -

                  The Controller

                  +

                  The Controller

                  The Controller window is composed of seven tabs:

                  1. The Look Tab to select the display style.
                  2. @@ -1581,14 +1599,14 @@ the current selection.
                  3. The Settings Tab access all the tool's configuration settings.
                  -

                  The Look Tab

                  +

                  The Look Tab

                  You can select how the layout will be displayed. There is a special one Printer.Coriolis specifically designed for Printing & Snapshots. You should select it prior to calling the print or snapshot dialog boxes.

                  Controller Basic Snapshot

                  -

                  The Filter Tab

                  +

                  The Filter Tab

                  The filter tab let you select what hierarchical levels of your design will be displayed. Hierarchy level are numbered top-down: the level 0 correspond to the top-level cell, the level one to the instances of the top-level Cell and @@ -1611,7 +1629,7 @@ They have been made very visibles as big violet lines...

                  Controller Basic Snapshot

                  -

                  The Layers&Go Tab

                  +

                  The Layers&Go Tab

                  Control the individual display of all layers and Gos.

                  • Layers correspond to a true physical layer. From a Hurricane point of @@ -1629,7 +1647,7 @@ to easily locate congested areas.
                  • Controller Basic Snapshot

                  -

                  The Netlist Tab

                  +

                  The Netlist Tab

                  The Netlist tab shows the list of nets... By default the tab is not synched with the displayed Cell. To see the nets you must check the Sync Netlist checkbox. You can narrow the set of displayed nets by @@ -1642,7 +1660,7 @@ is highlited in the Viewer.

                  Controller Basic Snapshot

                  -

                  The Selection Tab

                  +

                  The Selection Tab

                  The Selection tab list all the components currently selecteds. They can be filtered thanks to the filter pattern.

                  Used in conjunction with the Netlist Sync Selection you will all see @@ -1655,7 +1673,7 @@ the t key...

                  Controller Basic Snapshot

                  -

                  The Inspector Tab

                  +

                  The Inspector Tab

                  This tab is very useful, but mostly for Coriolis developpers. It allows to browse through the live DataBase. The Inspector provide three entry points:

                    @@ -1681,13 +1699,13 @@ is deleted, you will crash the application...

                    Controller Basic Snapshot

                  -

                  The Settings Tab

                  +

                  The Settings Tab

                  Here comes the description of the Settings tab.

                  Controller Basic Snapshot

                  -

                  Python Interface for Hurricane / Coriolis

                  +

                  Python Interface for Hurricane / Coriolis

                  The (almost) complete interface of Hurricane is exported as a Python module and some part of the other components of Coriolis (each one in a separate module). The interface has been made to mirror as closely as possible the @@ -1766,13 +1784,13 @@ lauched through cgt.

                  -

                  Plugins

                  +

                  Plugins

                  Plugins are Python scripts specially crafted to integrate with cgt. Their entry point is a ScriptMain() method as described in Python Interface to Coriolis. They can be called by user scripts through this method.

                  -

                  Chip Placement

                  +

                  Chip Placement

                  Automatically perform the placement of a complete chip. This plugin, as well as the other P&R tools expect a specific top-level hierarchy for the design. The top-level hierarchy must contains the instances of all the I/O pads and @@ -1947,7 +1965,7 @@ only four rails (2* power, 2* -

                  Clock Tree

                  +

                  Clock Tree

                  Insert a clock tree into a block. The clock tree uses the H strategy. The clock net is splitted into sub-nets, one for each branch of the tree.

                  @@ -2039,14 +2057,14 @@ into retirement very soon
                  -

                  Recursive-Save (RSave)

                  +

                  Recursive-Save (RSave)

                  Perform a recursive top down save of all the models from the top cell loaded in cgt. Force a write of any non-terminal model. This plugin is used by the clock tree plugin after the netlist clock sub-nets creation.

                  -

                  A Simple Example: AM2901

                  +

                  A Simple Example: AM2901

                  To illustrate the capabilities of Coriolis tools and Python scripting, a small example, derived from the Alliance AM2901 is supplied.

                  This example contains only the synthetized netlists and the doChip.py script diff --git a/documentation/UsersGuide/UsersGuide.pdf b/documentation/UsersGuide/UsersGuide.pdf index ee6f7d6a..597958aa 100644 Binary files a/documentation/UsersGuide/UsersGuide.pdf and b/documentation/UsersGuide/UsersGuide.pdf differ diff --git a/documentation/UsersGuide/UsersGuide.rst b/documentation/UsersGuide/UsersGuide.rst index 74e0adfa..21cda965 100644 --- a/documentation/UsersGuide/UsersGuide.rst +++ b/documentation/UsersGuide/UsersGuide.rst @@ -129,6 +129,7 @@ .. _hMETIS: http://glaros.dtc.umn.edu/gkhome/views/metis .. _Knik Thesis: http://www-soc.lip6.fr/en/users/damiendupuis/PhD/ .. _Coin Or Home: http://www.coin-or.org/index.html +.. _RapidJSON: http://miloyip.github.io/rapidjson/ .. _coriolis2-1.0.2049-1.slsoc6.i686.rpm: http://asim.lip6.fr/pub/coriolis/2.0/coriolis2-1.0.2049-1.slsoc6.i686.rpm .. _coriolis2-1.0.2049-1.slsoc6.x86_64.rpm: http://asim.lip6.fr/pub/coriolis/2.0/coriolis2-1.0.2049-1.slsoc6.x86_64.rpm @@ -317,8 +318,8 @@ Release v2.0.1 achieve a speedup factor greater than 20... -**Release v2.1** -~~~~~~~~~~~~~~~~ +Release v2.1 +~~~~~~~~~~~~ #. Replace the old simulated annealing placer |Mauka| by the analytical placer |Etesian| and its legalization and detailed placement tools. @@ -332,7 +333,14 @@ Release v2.0.1 .. When shifting to the left, the right-half part of the screen gets .. badly redrawn. Uses |CTRL_L| to refresh. It will be corrected as soon .. as possible. - + + +**Release v2.2** +~~~~~~~~~~~~~~~~ + +#. Added JSON import/export of the whole Hurricane DataBase. Two save mode + are supported: *Cell* mode (standalone) or *Blob* mode, which dump the + whole design down and including the standard cells. |newpage| @@ -352,9 +360,11 @@ Main building prerequisites: * cmake * C++11-capable compiler +* RapidJSON_ * python2.7 * boost * libxml2 +* bzip2 * yacc & lex * Qt 4 or Qt 5 @@ -437,22 +447,29 @@ automatically created either by |ccb| or the build system. Building Coriolis ~~~~~~~~~~~~~~~~~ -The first step is to create the source directory and pull the |git| repository: :: +First step is to install the prerequisites. Currently, only RapidJSON_: :: + + dummy@lepka:~$ mkdir -p ~/coriolis-2.x/src/support + dummy@lepka:~$ git clone http://github.com/miloyip/rapidjson + +The second step is to create the source directory and pull the |git| repository: :: dummy@lepka:~$ mkdir -p ~/coriolis-2.x/src dummy@lepka:~$ cd ~/coriolis-2.x/src dummy@lepka:~$ git clone https://www-soc.lip6.fr/git/coriolis.git -Second and final step, build & install: :: +Third and final step, build & install: :: - dummy@lepka:src$ ./bootstrap/ccp.py --project=coriolis \ + dummy@lepka:src$ ./bootstrap/ccp.py --project=support \ + --project=coriolis \ --make="-j4 install" - dummy@lepka:src$ ./bootstrap/ccb.py --project=coriolis \ + dummy@lepka:src$ ./bootstrap/ccb.py --project=support \ + --project=coriolis \ --doc --make="-j1 install" -We need two steps because the documentation do not support to be generated with -a parallel build. So we compile & install in a first step in ``-j4`` (or whatever) -then we generate the documentation in ``-j1`` +We need to separate to perform a separate installation of the documentation because it +do not support to be generated with a parallel build. So we compile & install in a first +stage in ``-j4`` (or whatever) then we generate the documentation in ``-j1`` Under |RHEL6| or clones, you must build using the |devtoolset2|: :: diff --git a/etesian/src/EtesianEngine.cpp b/etesian/src/EtesianEngine.cpp index d59eacbb..e08d649c 100644 --- a/etesian/src/EtesianEngine.cpp +++ b/etesian/src/EtesianEngine.cpp @@ -478,6 +478,7 @@ namespace Etesian { //masterCell->setAbutmentBox( topAb ); //instance->setTransformation( Transformation() ); // (0,0,ID). //instance->setPlacementStatus( Instance::PlacementStatus::PLACED ); + occurrence.makeInvalid(); instance->slaveAbutmentBox(); } } diff --git a/hurricane/CMakeLists.txt b/hurricane/CMakeLists.txt index 313f3881..bafa6a4a 100644 --- a/hurricane/CMakeLists.txt +++ b/hurricane/CMakeLists.txt @@ -18,6 +18,7 @@ setup_qt() find_package(LibXml2 REQUIRED) + find_package(BZip2 REQUIRED) find_package(BISON REQUIRED) find_package(FLEX REQUIRED) find_package(PythonLibs REQUIRED) diff --git a/hurricane/doc/hurricane/Initializer.dox b/hurricane/doc/hurricane/Initializer.dox new file mode 100644 index 00000000..e1ec285d --- /dev/null +++ b/hurricane/doc/hurricane/Initializer.dox @@ -0,0 +1,29 @@ + // -*- C++ -*- + + + namespace Hurricane { + + /*! \class Initializer + * \brief Register a static initialization function. + * + * \section secInitializerMechanism Initializer Mechanism + * + * In C++, there is currently no way to guarantee the order into + * which the static initialization (variables) in various modules + * will be done. + * + * The Initializer template class provide a way to perform a static + * initialization across multiple modules in an ordered fashion, + * thus solving potential dependency problems between initialisation. + */ + + //! \function Initializer::Initializer ( unsigned int order ); + //! Register a static initializer for the template type \c T. + //! Initializer is a object that must be kept in a \c static + //! variable in a compilation unit (i.e. a \c .cpp file). + //! + //! The template type \c T (a class) must provide a static function + //! named \c initialize, with exactly the following signature: + //! void T::initialize(). + + } diff --git a/hurricane/doc/hurricane/JsonObject.dox b/hurricane/doc/hurricane/JsonObject.dox new file mode 100644 index 00000000..6d33cce9 --- /dev/null +++ b/hurricane/doc/hurricane/JsonObject.dox @@ -0,0 +1,198 @@ + // -*- C++ -*- + + + namespace Hurricane { + + //! \addtogroup JsonSupport + //! \{ + + + /*! \class JsonObject + * \brief Support for JSON export. + * + */ + + //! \function JsonObject::JsonObject ( unsigned long flags ); + //! \param flags Flags sets by derived classes. + //! + //! Base object to be used by all JSON parsers. Provides + //! helpers functions. Store three separated lists of + //! requirements/attributes needes to build the object. + //! - \c stackeds : thoses are \b not attributes of the + //! current object, but other objects that are expected + //! to be already in the stack. They are needed to build the + //! current object. Their key must start with a \c '.' + //! character. + //! - \c attributes : the simple attributes of the object. + //! Their key must start with a \c '_'. + //! - \c collections : any container, collection or whatever + //! set of other objects part of the current object. + //! Their key must start with a \c '+' character. + //! + //! For adding a requirement/attribute, see JsonObject::add(). + + //! \function string JsonObject::getTypeName () const; + //! \Return The typename of the concrete object, that is, the value + //! of the \c @typename key of the JSON object. + + //! \function string JsonObject::getStackName () const; + //! \Return The key with which the DataBase object will be pushed on + //! the parser stack. + //! + //! If the current object is associated to an attribute (that + //! is, a key in JSON), then the \c name attribute of the JsonObject + //! should have been set, and it will be returned here. + //! + //! If the \c name attribute has not been set (for example, + //! because we are in an array). Then the typename (JsonObject::getTypeName()), + //! prefixed by a \c '.' character will be returned. + //! + //! If the JsonObject is, for instance, a JsonBox (typename: \c "Box") : + //! - If \c name is set to \c "_abutmentBox", the box will be stacked + //! with that key. + //! - If \c name is \b not set, then the key will be \c ".Box". + + //! \function JsonObject* JsonObject::setFlags ( unsigned long mask ); + //! \param mask Flag(s) to be raised. + //! \return The current object. + + //! \function JsonObject* JsonObject::resetFlags ( unsigned long mask ); + //! \param mask Flag(s) to be lowered. + //! \return The current object. + + //! \function bool JsonObject::issetFlags ( unsigned long mask ) const; + //! \param mask The combination of flags to be checked. + //! \return \true if \b all the flags given in \c mask are sets. + + //! \function bool JsonObject::check ( JsonStack& stack, string fname ) const; + //! \param stack Where the objects already parsed are stored. + //! \param fname The function name on behalf of which the check is + //! performed. + //! \return \true if the check is successful. + //! + //! Check that the \c stack actually contains all the objects (i.e. attributes) + //! needed to build the current object. The list of \e attributes is built + //! using the JsonObject::add() function. If an attribute is missing, a warning + //! is issued, but the parser will try to continue. + + //! \function bool JsonObject::has ( const string& key ) const; + //! \param key The key name to search for. + //! \return \true if the object possess such a key. + + //! \function void JsonObject::add ( const string& key, type_index tid ); + //! \param key The requirement/attribute to add. + //! \param tid The type index of the attribute. + //! + //! Adds a new requirement or attribute to the object. The first character + //! of the key tells which kind it is: + //! - \c '.' : a requirement (not part of the object) that must be present + //! in the stack. + //! - \c '_' : a simple attribute of the object. + //! - \c '+' : belongs to a collection or container. + //! + //! A more detailed description could be found in JsonObject::JsonObject(). + + //! \function void JsonObject::remove ( const string& key ); + //! \param key The key of the requirement/attribute to remove. + //! + //! Removes an attribute from the current object. + + //! \function T JsonObject::get ( JsonStack& stack, const string& key ) const; + //! \param stack The object stack of the parser. + //! \param key The key of the requested object. + //! \return The first object associated with \c key, starting from the top + //! of the stack. + //! + //! Retrieve requirements or attributes from the parser stack. + //! - If no element with a corresponding key is found, an empty element + //! of type \c T is returned (by calling the default \c T constructor). + //! - If an element matching the key is found, \b but it's type do not + //! match \c T, an exception from \c any_cast<> will be thrown. + + //! \function void JsonObject::copyAttrs ( const JsonObject* other, bool reset=false ); + //! \param other The object from which to copy attributes. + //! \param reset Whether to keep or erase the original attributes of the object. + //! + //! Copy the attributes from \c other into the current object. \b Only the + //! \b attributes are copied. Neither the requirements, nor the collections. + //! By default, the attributes are added to the existing one of the object, + //! but if \c reset is \true, the original ones will be suppresseds. + + //! \function void JsonObject::clear (); + //! Removes all requirements/attributes/collections of the object. + //! Also unbind it from any generated DataBase object. + + //! \function string JsonObject::getName () const; + //! \Return The name of the whole object as attribute. + //! + //! During the parsing of the JSON structure, excepted when in an array, + //! an object is associated with a key. This is the string returned by + //! this function. It is called \c getName() instead of \c getKey() to + //! avoid confusing with the attributes keys. + + //! \function void JsonObject::setName ( const string& name ); + //! \param name Set the key associated to this object. + //! + //! See JsonObject::getName() for the meaning of the name (key). + + //! \function T& JsonObject::getObject () const; + //! \Return The associated DataBase object. + //! + //! Once all the attributes have been gathered, the creation of the + //! DataBase object is triggered by calling JsonObject::toData(). + //! We keep track of that DataBase object by storing it (or a pointer + //! to it) in an \c boost::any field of the JsonObject. + + //! \function void JsonObject::setObject ( T ); + //! \param T The DataBase object. + //! + //! Associate the constructed DataBase object \c T to the JSON + //! object (for later access). + + //! \function bool JsonObject::isBound () const; + //! \Return \true if a DataBase object is associated to the JSON object + //! (see JsonObject::setObject()). + + //! \function JsonObject* JsonObject::clone ( unsigned long flags ) const; + //! \Return a new \b empty object of the same dynamic type + //! as the source one. + //! + //! This is not a true clone operation in the sense that the datas + //! of the original object are not copied. The cloning is about the + //! type, and is the result of a call to the \c new operator. + //! + //! \Important This method must be overloaded in each concrete derived class. + + //! \function void JsonObject::toData ( JsonStack& stack ); + //! \param The parser object stack. + //! + //! \Important This method must be overloaded in each concrete derived class. + //! + //! Creates the DataBase object. The requirements and attributes + //! must be on top of the stack, they are popped, the DataBase object + //! is created from them and the result is then pushed back. + + //! \function unsigned int JsonObject::presetId ( JsonStack& stack ); + //! \param The parser object stack. + //! \Return the next id that has been set. + //! + //! \Remark This is a helper for JsonStack::toData(). + //! + //! In blob mode, the DataBase must be restored as is, + //! including the \c ids of all the Entities (see Entity). + //! This function read from the stack the \c _id attribute + //! and sets it so that the next Entity created will use it. + + //! \function void JsonObject::update ( JsonStack& stack, T hobject ); + //! \param The parser object stack. + //! \param hobject the newly created DataBase object. + //! + //! \Remark This is a helper for JsonStack::toData(). + //! + //! Pop the attributes from the stack. Push the newly created + //! object and bind it to the JsonObject. + + + //! \} + + } diff --git a/hurricane/doc/hurricane/JsonSupport.dox b/hurricane/doc/hurricane/JsonSupport.dox new file mode 100644 index 00000000..fab4e470 --- /dev/null +++ b/hurricane/doc/hurricane/JsonSupport.dox @@ -0,0 +1,241 @@ + // -*- C++ -*- + + + namespace Hurricane { + + /*! \defgroup JsonSupport JSON Support + * \brief JSON Import/Export of the DataBase + * + * \section secJsonSupportIntro Introduction + * + * One key feature of the Hurricane DataBase is it's hierarchical + * managment. But unfortunatly the simple approach of saving a design + * Cell by Cell, hierarchical level by hierarchical level makes it + * very difficult to save the trans-hierarchical informations (mainly + * is the occurrences) + * + * One solution is to save the design and all it's levels, down and + * including the standard cells. With all the levels saved, we then + * can add the occurrences and all the attached trans-hierarchical + * informations. We call that comprehensive saving of a design, + * a design blob. + * + * Instead of creating one more ad-hoc format, we just dump the + * DataBase objects in a mirror like way in JSON format. + * + * As it is a textual format, the generated files are larges. + * So the files are compressed through \c gzip. + * + * + * \section secJsonSemantic JSON Additional Semantic + * + * To ease the work of the parser, some semantic has been added + * to the JSON objects representing a Hurricane DataBase. + * -# The first key/value pair must have the key \c "@typename" + * and give the kind of JsonObject associated. The value is + * the string returned by \c JsonObject::getTypeName(). + * -# Attributes keys must start by a \c '_' character. + * (yes, I know, the C++ convention has changed and it should + * be put at the end). + * -# Collections or containers must be put \e after all the + * scalar attributes and their keys must start by a \c '+' + * character. + * +\code{.json} +{ + "@typename": "Cell", + "_id": 3, + "_library": "RootLibrary.AllianceFramework.sxlib", + "_name": "o3_x2", + "_abutmentBox": { + "@typename": "Box", + "_xMin": 0, + "_yMin": 0, + "_xMax": 72000, + "_yMax": 120000 + }, + "+instanceMap": [], + "+netMap": [ + ], +} + +\endcode + * + * \section secJsonDriver JSON Driver Support + * + * The driver is implemented through overloads (template and + * non-template) of the \c jsonWriter() function. For the + * template overload to work, even for non-Hurricane classes, + * it is defined outside the Hurricane namespace. + * + * For POD types, four overloads of \c jsonWriter() are defined: + * +\code +void jsonWrite ( JsonWriter* w, const int* v ); +void jsonWrite ( JsonWriter* w, int v ); +void jsonWrite ( JsonWriter* w, const std::string& key, const int* value ) +void jsonWrite ( JsonWriter* w, const std::string& key, int value ) +\endcode + * + * The first two writes the object (here: \c int) "as is" while + * the two later writes a pair key/object. + * + * For other class/object that needs to be writen in the JSON file, + * they must provide a \c toJson() function. It doesn't even need + * to be virtual. For Point: + * +\code +void Point::toJson ( JsonWriter* w ) const +{ + w->startObject(); + jsonWrite( w, "@typename", "Point" ); + jsonWrite( w, "_x", getX() ); + jsonWrite( w, "_y", getY() ); + w->endObject(); +} +\endcode + * + * This function allows three templates of \c jsonWrite() to be + * used with an object of class Point: + * +\code +template +void jsonWrite ( JsonWriter* w, const C* object ); + +template +void jsonWrite ( JsonWriter* w, const std::string& key, C* object ); + +template +void jsonWrite ( JsonWriter* w, const std::string& key, const C* object ); +\endcode + * + * Note that through those three overloads we only provides + * support for pointers to object. The driving mechanism is + * designed in such a way that passing arguments by value is + * not supported for non-POD types. Trying to do so will + * result in an unsupported message inside the generated + * JSON file. + * + * + * \subsection secJsonDriverDBo DBos Special Case + * + * For DBo objects, a complete parallel hierarchy of JsonObjects + * mimicking the one of DBos has been implemented. The \c toJson() + * function is implemented in the DBo base object, and the + * derived classes must implement the following virtual functions: + * +\code +class DBo { + public: + virtual void _toJson ( JsonWriter* ) const; + virtual void _toJsonCollections ( JsonWriter* ) const; + virtual void _toJsonSignature ( JsonWriter* ) const; + void toJson ( JsonWriter* ) const; + void toJsonSignature ( JsonWriter* ) const; +\endcode + * + * The JSON driver functions is splitted in two parts: + * - \c _toJson() must drive the scalar attributes. + * - \c _toJsonCollections() must drive the various collections + * or containers. + * This is to ensure that all the scalars attributes are put + * before the collections, event through inheritance. + * + * The additionnal \c toJsonSignature() method provide the + * signature for an Entity which is used by an occurrence. + * The signature of an occurrence is needed when we create + * a JSON for a Cell only. In that case we cannot directly save + * the transhierarchical informations, so we need a way to + * characterize the deep Entity (which is not part of the + * saved Cell). Most of the time, the signature is the scalar + * attributes of the occurrenced object, it is far from foolproof, + * but it will do for now. + * + * + * \section secJsonParser JSON Parser Support + * + * To enable JSON parsing support for an object, say Point, + * an associated \c JsonPoint class must be created. This + * class must be derived (directly or not) from JsonObject. + * It must implement one static functions and four methods, + * as shown below. + * +\code +class JsonPoint : public JsonObject { + public: + static void initialize (); + JsonPoint (unsigned long flags); + virtual string getTypeName(); + virtual JsonPoint* clone (unsigned long flags); + virtual void toData (JsonStack&); +}; +\endcode + * + * The \c initialize() static function must be present in + * concrete class only. It is used to register the Json + * object into the parser during the static initialization + * of the program. + * +\code +#include "hurricane/Initializer.h" +#include "hurricane/Point.h" + +Initializer jsonPointInit ( 0 ); + +void JsonPoint::initialize () +{ JsonTypes::registerType( new JsonPoint (JsonWriter::RegisterMode) ); } + +\endcode + * + * The constructor has to declare requirements, attributes, + * and collections needed to build the DataBase object. + * Note the the requirements are not part of the objects + * but only needed to build it. + * +\code{.cpp} +JsonPoint::JsonPoint ( unsigned long flags ) + : JsonObject(flags) +{ + add( "_x", typeid(int64_t) ); + add( "_y", typeid(int64_t) ); +} +\endcode + * + * The \c getTypeName() virtual function must return the + * typename used for the \c "@typename" key in the JSON + * file. Most of the time it's the same name as the + * object itself, but not always. + * +\code{.cpp} +string JsonPoint::getTypeName () const +{ return "Point"; } +\endcode + * + * The \c clone() virtual function must return a brand new + * Json object of the same type. The datas of the orignal + * object \b must not be copied. The cloning is about the + * class type, not the contents. + * +\code +JsonPoint* JsonPoint::clone ( unsigned long flags ) const +{ return new JsonPoint ( flags ); } +\endcode + * + * The \c toData() virtual function actually gather the + * attributes to recreate the DataBase object. It needs + * the parser stack to pull the attributes and to push + * the created object. + * +\code{.cpp} +void JsonPoint::toData ( JsonStack& stack ) +{ + check( stack, "JsonPoint::toData" ); + Point point ( DbU::fromDb(get(stack,"_x")) + , DbU::fromDb(get(stack,"_y")) ); + update( stack, point ); +} +\endcode + */ + + + } // Hurricane namespace. diff --git a/hurricane/doc/hurricane/StandardSharedProperty.dox b/hurricane/doc/hurricane/StandardSharedProperty.dox index 69d27df7..c8c9b0f6 100644 --- a/hurricane/doc/hurricane/StandardSharedProperty.dox +++ b/hurricane/doc/hurricane/StandardSharedProperty.dox @@ -13,7 +13,4 @@ * relation between a name and a value. */ - // \} - - } // End of Hurricane namespace. diff --git a/hurricane/doc/hurricane/doxyfile b/hurricane/doc/hurricane/doxyfile index 61fbbc2b..579ec8f5 100644 --- a/hurricane/doc/hurricane/doxyfile +++ b/hurricane/doc/hurricane/doxyfile @@ -586,6 +586,11 @@ WARN_LOGFILE = doxygen.warn.log # with spaces. INPUT = Generalities.dox \ + JsonSupport.dox \ + Initializer.dox \ + ../../src/hurricane/hurricane/Initializer.h \ + JsonObject.dox \ + ../../src/hurricane/hurricane/JsonReader.h \ Hurricane.dox \ ../../src/hurricane/hurricane/Commons.h \ Commons.dox \ diff --git a/hurricane/src/hurricane/Box.cpp b/hurricane/src/hurricane/Box.cpp index bad9ce79..73534019 100644 --- a/hurricane/src/hurricane/Box.cpp +++ b/hurricane/src/hurricane/Box.cpp @@ -17,8 +17,8 @@ // not, see . // **************************************************************************************************** -#include "hurricane/Error.h" #include "hurricane/Box.h" +#include "hurricane/Error.h" namespace Hurricane { @@ -365,6 +365,13 @@ void Box::toJson(JsonWriter* w) const w->endObject(); } + +Initializer jsonBoxInit ( 0 ); + +void JsonBox::initialize() +// ************************** +{ JsonTypes::registerType( new JsonBox (JsonWriter::RegisterMode) ); } + JsonBox::JsonBox(unsigned long flags) // ********************************** : JsonObject(flags) diff --git a/hurricane/src/hurricane/CMakeLists.txt b/hurricane/src/hurricane/CMakeLists.txt index 55b6b7bc..ba8e5501 100644 --- a/hurricane/src/hurricane/CMakeLists.txt +++ b/hurricane/src/hurricane/CMakeLists.txt @@ -2,11 +2,15 @@ include_directories ( ${HURRICANE_SOURCE_DIR}/src/hurricane ${CONFIGURATION_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} + ${BZIP2_INCLUDE_DIR} ) set ( includes hurricane/Mask.h hurricane/Flags.h + hurricane/Initializer.h hurricane/DebugSession.h hurricane/Backtrace.h + hurricane/FileReadGzStream.h + hurricane/FileWriteGzStream.h hurricane/JsonWriter.h hurricane/JsonReader.h hurricane/Signature.h @@ -98,9 +102,12 @@ ) set ( cpps Record.cpp Slot.cpp + Initializer.cpp Commons.cpp Flags.cpp Backtrace.cpp + FileReadGzStream.cpp + FileWriteGzStream.cpp JsonWriter.cpp JsonReader.cpp Signature.cpp @@ -176,7 +183,7 @@ ) add_library ( hurricane ${cpps} ) - target_link_libraries ( hurricane ${Boost_LIBRARIES} ) + target_link_libraries ( hurricane ${Boost_LIBRARIES} ${BZIP2_LIBRARIES} ) set_target_properties ( hurricane PROPERTIES VERSION 1.0 SOVERSION 1 ) install ( TARGETS hurricane DESTINATION lib${LIB_SUFFIX} ) install ( FILES ${includes} DESTINATION include/coriolis2/hurricane ) diff --git a/hurricane/src/hurricane/Cell.cpp b/hurricane/src/hurricane/Cell.cpp index dbabfe17..8551a8b9 100644 --- a/hurricane/src/hurricane/Cell.cpp +++ b/hurricane/src/hurricane/Cell.cpp @@ -21,8 +21,8 @@ #include "hurricane/Warning.h" #include "hurricane/SharedName.h" -#include "hurricane/Cell.h" #include "hurricane/DataBase.h" +#include "hurricane/Cell.h" #include "hurricane/Library.h" #include "hurricane/Instance.h" #include "hurricane/Net.h" @@ -43,6 +43,10 @@ namespace Hurricane { +// **************************************************************************************************** +// UniquifyRelation implementation +// **************************************************************************************************** + const Name Cell::UniquifyRelation::_name = "Cell::UniquifyRelation"; @@ -99,6 +103,18 @@ namespace Hurricane { } + string Cell::UniquifyRelation::getTrunkName ( Name name ) + { + string trunk = getString(name); + size_t suffix = trunk.rfind( "_u" ); + + if (suffix != string::npos) + trunk = trunk.substr( 0, suffix ); + + return trunk; + } + + Record* Cell::UniquifyRelation::_getRecord () const { Record* record = Relation::_getRecord(); @@ -109,6 +125,158 @@ namespace Hurricane { } + bool Cell::UniquifyRelation::hasJson () const + { return true; } + + + void Cell::UniquifyRelation::toJson ( JsonWriter* w, const DBo* owner ) const + { + w->startObject(); + std::string tname = getString( staticGetName() ); + if (getMasterOwner() == owner) { + jsonWrite( w, "@typename" , tname ); + jsonWrite( w, "_refcount" , getOwners().getSize() ); + jsonWrite( w, "_duplicates", _duplicates ); + } else { + tname.insert( 0, "&" ); + jsonWrite( w, "@typename", tname ); + + Cell* masterOwner = dynamic_cast( getMasterOwner() ); + if (masterOwner) { + jsonWrite( w, "_masterOwner", masterOwner->getHierarchicalName() ); + } else { + cerr << Error( "UniquifyRelation::toJson(): Master owner is not a Cell (%s)." + , getString(owner).c_str() + ) << endl; + jsonWrite( w, "_masterOwner", "" ); + } + } + w->endObject(); + } + + +// **************************************************************************************************** +// UniquifyRelation::JsonProperty implementation +// **************************************************************************************************** + + + Initializer jsonUniquifyRelationInit ( 10 ); + + + Cell::UniquifyRelation::JsonProperty::JsonProperty ( unsigned long flags ) + : JsonObject(flags) + { + add( "_refcount" , typeid(int64_t) ); + add( "_duplicates", typeid(int64_t) ); + } + + + string Cell::UniquifyRelation::JsonProperty::getTypeName () const + { return getString(Cell::UniquifyRelation::staticGetName()); } + + + void Cell::UniquifyRelation::JsonProperty::initialize () + { JsonTypes::registerType( new Cell::UniquifyRelation::JsonProperty (JsonWriter::RegisterMode) ); } + + + Cell::UniquifyRelation::JsonProperty* Cell::UniquifyRelation::JsonProperty::clone ( unsigned long flags ) const + { return new Cell::UniquifyRelation::JsonProperty ( flags ); } + + + void Cell::UniquifyRelation::JsonProperty::toData ( JsonStack& stack ) + { + check( stack, "Cell::UniquifyRelation::JsonProperty::toData" ); + + DBo* dbo = stack.back_dbo(); + unsigned int refcount = get( stack, "_refcount" ); + unsigned int duplicates = get( stack, "_duplicates" ); + UniquifyRelation* relation = NULL; + Cell* cell = dynamic_cast( dbo ); + + ltrace(51) << "topDBo:" << dbo << endl; + + if (cell) { + relation = UniquifyRelation::get( cell ); + if (not relation) { + string tag = cell->getHierarchicalName()+"::"+getString(UniquifyRelation::staticGetName()); + relation = dynamic_cast( SharedProperty::getOrphaned( tag ) ); + + if (not relation) { + relation = Cell::UniquifyRelation::create( cell ); + SharedProperty::addOrphaned( tag, relation ); + } + SharedProperty::refOrphaned( tag ); + SharedProperty::countOrphaned( tag, refcount ); + cell->put( relation ); + } + relation->_setMasterOwner( cell ); + relation->_setDuplicates ( duplicates ); + } + + update( stack, relation ); + } + + +// **************************************************************************************************** +// UniquifyRelation::JsonPropertyRef implementation +// **************************************************************************************************** + + + Initializer jsonUniquifyRelationRefInit ( 10 ); + + + Cell::UniquifyRelation::JsonPropertyRef::JsonPropertyRef ( unsigned long flags ) + : JsonObject(flags) + { + add( "_masterOwner", typeid(string) ); + } + + + string Cell::UniquifyRelation::JsonPropertyRef::getTypeName () const + { return string("&")+getString(Cell::UniquifyRelation::staticGetName()); } + + + void Cell::UniquifyRelation::JsonPropertyRef::initialize () + { JsonTypes::registerType( new Cell::UniquifyRelation::JsonPropertyRef (JsonWriter::RegisterMode) ); } + + + Cell::UniquifyRelation::JsonPropertyRef* Cell::UniquifyRelation::JsonPropertyRef::clone ( unsigned long flags ) const + { return new Cell::UniquifyRelation::JsonPropertyRef ( flags ); } + + + void Cell::UniquifyRelation::JsonPropertyRef::toData ( JsonStack& stack ) + { + check( stack, "Cell::UniquifyRelation::JsonPropertyRef::toData" ); + + DBo* dbo = stack.back_dbo(); + string masterName = get( stack, "_masterOwner" ); + UniquifyRelation* relation = NULL; + Cell* cell = dynamic_cast( dbo ); + string tag = masterName+"::"+getString(UniquifyRelation::staticGetName()); + + if (cell) { + if (not relation) { + relation = dynamic_cast( SharedProperty::getOrphaned( tag ) ); + if (not relation) { + relation = Cell::UniquifyRelation::create( cell ); + SharedProperty::addOrphaned( tag, relation ); + } + } + + if (relation) { + cell->put( relation ); + SharedProperty::refOrphaned( tag ); + } + } + + update( stack, relation ); + } + + +// **************************************************************************************************** +// Cell Slice related implementation +// **************************************************************************************************** + void Cell::_insertSlice ( ExtensionSlice* slice ) { ExtensionSliceMap::iterator islice = _extensionSlices.find ( slice->getName() ); @@ -177,14 +345,14 @@ Cell::Cell(Library* library, const Name& name) _observers(), _flags(Flags::Terminal) { - if (!_library) - throw Error("Can't create " + _TName("Cell") + " : null library"); + if (!_library) + throw Error("Can't create " + _TName("Cell") + " : null library"); - if (name.isEmpty()) - throw Error("Can't create " + _TName("Cell") + " : empty name"); + if (name.isEmpty()) + throw Error("Can't create " + _TName("Cell") + " : empty name"); - if (_library->getCell(_name)) - throw Error("Can't create " + _TName("Cell") + " " + getString(_name) + " : already exists"); + if (_library->getCell(_name)) + throw Error("Can't create " + _TName("Cell") + " " + getString(_name) + " : already exists"); } Cell* Cell::create(Library* library, const Name& name) @@ -895,9 +1063,11 @@ void Cell::_toJson(JsonWriter* writer) const void Cell::_toJsonCollections(JsonWriter* writer) const // ***************************************** { + writer->setFlags( JsonWriter::CellObject ); jsonWrite( writer, "+instanceMap", getInstances() ); jsonWrite( writer, "+netMap" , getNets() ); Inherit::_toJsonCollections( writer ); + writer->resetFlags( JsonWriter::CellObject ); } // **************************************************************************************************** @@ -1217,6 +1387,10 @@ void Cell::MarkerSet::_setNextElement(Marker* marker, Marker* nextMarker) const // JsonCell implementation // **************************************************************************************************** + +Initializer jsonCellInitialize ( 10 ); + + JsonCell::JsonCell(unsigned long flags) // ************************************ : JsonEntity(flags) @@ -1233,6 +1407,10 @@ string JsonCell::getTypeName() const // ********************************* { return "Cell"; } +void JsonCell::initialize() +// ************************* +{ JsonTypes::registerType( new JsonCell (JsonWriter::RegisterMode) ); } + JsonCell* JsonCell::clone(unsigned long flags) const // ************************************************* { return new JsonCell ( flags ); } @@ -1243,8 +1421,9 @@ void JsonCell::toData(JsonStack& stack) check( stack, "JsonCell::toData" ); presetId( stack ); - Cell* cell = Cell::create( DataBase::getDB()->getLibrary( get(stack,"_library") ) - , get(stack,"_name") ); + Library* library = DataBase::getDB()->getLibrary( get(stack,"_library") + , DataBase::CreateLib|DataBase::WarnCreateLib ); + Cell* cell = Cell::create( library, get(stack,"_name") ); cell->setAbutmentBox( stack.as("_abutmentBox") ); update( stack, cell ); diff --git a/hurricane/src/hurricane/Contact.cpp b/hurricane/src/hurricane/Contact.cpp index 4ec194a5..65b80799 100644 --- a/hurricane/src/hurricane/Contact.cpp +++ b/hurricane/src/hurricane/Contact.cpp @@ -541,6 +541,13 @@ string Contact_Hooks::Locator::_getString() const // JsonContact implementation // **************************************************************************************************** +Initializer jsonContactInit ( 0 ); + + +void JsonContact::initialize() +// **************************** +{ JsonTypes::registerType( new JsonContact (JsonWriter::RegisterMode) ); } + JsonContact::JsonContact(unsigned long flags) // ****************************************** : JsonComponent(flags) diff --git a/hurricane/src/hurricane/DBo.cpp b/hurricane/src/hurricane/DBo.cpp index 300434eb..fceb46c0 100644 --- a/hurricane/src/hurricane/DBo.cpp +++ b/hurricane/src/hurricane/DBo.cpp @@ -29,8 +29,9 @@ // +-----------------------------------------------------------------+ -#include "hurricane/Property.h" #include "hurricane/DBo.h" +#include "hurricane/Initializer.h" +#include "hurricane/Property.h" #include "hurricane/Quark.h" #include "hurricane/Error.h" @@ -160,6 +161,9 @@ namespace Hurricane { { writer->key( "+propertySet" ); writer->startArray(); + for ( Property* property : getProperties() ) { + if (property->hasJson()) property->toJson( writer, this ); + } writer->endArray(); } @@ -212,7 +216,7 @@ namespace Hurricane { // Class : "Hurricane::JsonDBo". JsonDBo::JsonDBo ( unsigned int flags ) - : JsonObject(flags) + : JsonObject(flags | JsonWriter::DBoObject) { } diff --git a/hurricane/src/hurricane/DataBase.cpp b/hurricane/src/hurricane/DataBase.cpp index d3b8b2d9..165f9c49 100644 --- a/hurricane/src/hurricane/DataBase.cpp +++ b/hurricane/src/hurricane/DataBase.cpp @@ -17,12 +17,91 @@ // not, see . // **************************************************************************************************** -#include "hurricane/DataBase.h" +#include "hurricane/Initializer.h" +#include "hurricane/Warning.h" +#include "hurricane/Error.h" #include "hurricane/SharedPath.h" +#include "hurricane/UpdateSession.h" +#include "hurricane/DataBase.h" #include "hurricane/Technology.h" #include "hurricane/Library.h" -#include "hurricane/Error.h" -#include "hurricane/UpdateSession.h" + + +namespace { + + using namespace std; + using namespace Hurricane; + + + class CellDepths { + public: + typedef map CellMap; + typedef multimap DepthMap; + public: + CellDepths ( Library* ); + inline const DepthMap& getDepths () const; + private: + void _gatherCells ( Library* ); + void _computeDepths (); + int _computeDepth ( pair& ); + private: + CellMap _cellMap; + DepthMap _depthMap; + }; + + + inline const CellDepths::DepthMap& CellDepths::getDepths () const { return _depthMap; } + + + CellDepths::CellDepths ( Library* library ) + : _cellMap () + , _depthMap() + { + _gatherCells ( library ); + _computeDepths(); + } + + + void CellDepths::_gatherCells ( Library* library ) + { + for ( Cell* cell : library->getCells() ) _cellMap.insert( make_pair(cell,-1) ); + + for ( Library* childLibrary : library->getLibraries() ) + _gatherCells( childLibrary ); + } + + + int CellDepths::_computeDepth ( pair& cellDepth ) + { + if (cellDepth.second != -1) return cellDepth.second; + + int depth = 0; + + if (not cellDepth.first->isTerminal()) { + for ( Instance* instance : cellDepth.first->getInstances() ) { + Cell* masterCell = instance->getMasterCell(); + pair& masterDepth = *(_cellMap.find( masterCell )); + depth = std::max( depth, _computeDepth(masterDepth)+1 ); + } + } + + cellDepth.second = depth; + return cellDepth.second; + } + + + void CellDepths::_computeDepths () + { + _depthMap.clear(); + + for ( auto cellDepth : _cellMap ) { + _computeDepth( cellDepth ); + _depthMap.insert( make_pair(cellDepth.second,cellDepth.first) ); + } + } + + +} // Anonymous namespace. namespace Hurricane { @@ -34,6 +113,7 @@ namespace Hurricane { DataBase* DataBase::_db = NULL; + DataBase::DataBase() // ***************** : Inherit(), @@ -57,9 +137,10 @@ DataBase* DataBase::create() void DataBase::_postCreate() // ************************* { - Inherit::_postCreate(); + Init::runOnce(); + Inherit::_postCreate(); - _db = this; + _db = this; } void DataBase::_preDestroy() @@ -101,11 +182,11 @@ DataBase* DataBase::getDB() return _db; } -Library* DataBase::getLibrary(string rpath) const -// ********************************************** +Library* DataBase::getLibrary(string rpath, unsigned int flags) +// ************************************************************ { - Library* current = getRootLibrary(); - if (not current) return NULL; + Library* parent = getRootLibrary(); + if ( not parent and (not (flags & CreateLib)) ) return NULL; char separator = SharedPath::getNameSeparator(); Name childName; @@ -113,33 +194,54 @@ Library* DataBase::getLibrary(string rpath) const if (dot != string::npos) { childName = rpath.substr( 0, dot ); rpath = rpath.substr( dot+1 ); - } else + } else { childName = rpath; + rpath.clear(); + } - if (childName != current->getName()) + if (not parent) { + parent = Library::create( this, childName ); + if (flags & WarnCreateLib) { + cerr << Warning( "DataBase::getLibrary(): Creating Root library \"%s\"." + , getString(childName).c_str() + ) << endl; + } + } + if (childName != parent->getName()) return NULL; - while ( dot != string::npos ) { + while ( (dot != string::npos) and parent ) { dot = rpath.find( separator ); if (dot != string::npos) { childName = rpath.substr( 0, dot ); rpath = rpath.substr( dot+1 ); - } else + } else { childName = rpath; + rpath.clear(); + } - current = current->getLibrary( childName ); + Library* child = parent->getLibrary( childName ); + if ( not child and (flags & CreateLib) ) { + child = Library::create( parent, childName ); + if (flags & WarnCreateLib) { + cerr << Warning( "DataBase::getLibrary(): Creating library \"%s\" (parent:\"%s\")." + , getString(childName).c_str() + , getString(parent->getName()).c_str() + ) << endl; + } + } + parent = child; } - return current; + return parent; } -Cell* DataBase::getCell(string rpath) const -// **************************************** +Cell* DataBase::getCell(string rpath, unsigned int flags) +// ****************************************************** { - char separator = SharedPath::getNameSeparator(); size_t dot = rpath.rfind( separator ); string cellName = rpath.substr(dot+1); - Library* library = getLibrary( rpath.substr(0,dot) ); + Library* library = getLibrary( rpath.substr(0,dot), flags ); Cell* cell = NULL; if (library) @@ -151,6 +253,61 @@ Cell* DataBase::getCell(string rpath) const } +void DataBase::_toJson(JsonWriter* w) const +// **************************************** +{ + Inherit::_toJson( w ); + + jsonWrite( w, "_rootLibrary" , _rootLibrary ); + + w->key( "+cellsOrderedByDepth" ); + w->startArray(); + CellDepths cells = CellDepths( _rootLibrary ); + for ( auto depthCell : cells.getDepths() ) { + depthCell.second->toJson( w ); + } + w->endArray(); +} + + +// **************************************************************************************************** +// JsonDataBase implementation +// **************************************************************************************************** + + +Initializer jsonDataBaseInit ( 0 ); + + +JsonDataBase::JsonDataBase(unsigned long flags) +// ******************************************** + : JsonDBo(flags) +{ + add( "_rootLibrary", typeid(Library*) ); +} + +string JsonDataBase::getTypeName() const +// ********************************* +{ return "DataBase"; } + +void JsonDataBase::initialize() +// ***************************** +{ JsonTypes::registerType( new JsonDataBase (JsonWriter::RegisterMode) ); } + +JsonDataBase* JsonDataBase::clone(unsigned long flags) const +// ************************************************* +{ return new JsonDataBase ( flags ); } + +void JsonDataBase::toData(JsonStack& stack) +// *************************************** +{ + check( stack, "JsonDataBase::toData" ); + + DataBase* db = DataBase::getDB(); + + update( stack, db ); +} + + } // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/DeepNet.cpp b/hurricane/src/hurricane/DeepNet.cpp index 21854632..97b44029 100644 --- a/hurricane/src/hurricane/DeepNet.cpp +++ b/hurricane/src/hurricane/DeepNet.cpp @@ -132,6 +132,12 @@ namespace Hurricane { // ------------------------------------------------------------------- // Class : "JsonDeepNet". + Initializer jsonDeepNetInit ( 0 ); + + void JsonDeepNet::initialize () + { JsonTypes::registerType( new JsonDeepNet (JsonWriter::RegisterMode) ); } + + JsonDeepNet::JsonDeepNet ( unsigned long flags ) : JsonNet(flags) { diff --git a/hurricane/src/hurricane/DesignBlob.cpp b/hurricane/src/hurricane/DesignBlob.cpp index 2db3868b..1185fa13 100644 --- a/hurricane/src/hurricane/DesignBlob.cpp +++ b/hurricane/src/hurricane/DesignBlob.cpp @@ -15,9 +15,8 @@ #include -#include "hurricane/DesignBlob.h" #include "hurricane/DataBase.h" -#include "hurricane/Library.h" +#include "hurricane/Cell.h" #include "hurricane/DesignBlob.h" @@ -35,7 +34,7 @@ namespace Hurricane { w->startObject(); jsonWrite( w, "@typename", _getTypeName() ); jsonWrite( w, "_topCell" , getTopCell()->getHierarchicalName() ); - jsonWrite( w, "_library" , DataBase::getDB()->getRootLibrary() ); + jsonWrite( w, "_database", DataBase::getDB() ); w->endObject(); } @@ -43,13 +42,20 @@ namespace Hurricane { // ------------------------------------------------------------------- // Class : "JsonDesignBlob". + Initializer jsonDesignBlobInit ( 0 ); + + + void JsonDesignBlob::initialize () + { JsonTypes::registerType( new JsonDesignBlob (JsonWriter::RegisterMode) ); } + + JsonDesignBlob::JsonDesignBlob ( unsigned long flags ) : JsonObject(flags) { ltrace(51) << "JsonDesignblob::JsonDesignblob()" << endl; - add( "_library", typeid(Library*) ); - add( "_topCell", typeid(string) ); + add( "_topCell" , typeid(string) ); + add( "_database", typeid(DataBase*) ); } @@ -65,7 +71,8 @@ namespace Hurricane { { check( stack, "JsonDesignBlob::toData" ); - DesignBlob* designBlob = new DesignBlob ( DataBase::getDB()->getCell(get(stack,"_topCell")) ); + DesignBlob* designBlob = new DesignBlob + ( DataBase::getDB()->getCell( get(stack,"_topCell"), DataBase::NoFlags ) ); update( stack, designBlob ); } diff --git a/hurricane/src/hurricane/FileReadGzStream.cpp b/hurricane/src/hurricane/FileReadGzStream.cpp new file mode 100644 index 00000000..c7a857dd --- /dev/null +++ b/hurricane/src/hurricane/FileReadGzStream.cpp @@ -0,0 +1,83 @@ +// -*- mode: C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2016-2015, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./FileReadGzStream.h" | +// +-----------------------------------------------------------------+ + + +#include +#include "hurricane/Error.h" +#include "hurricane/FileReadGzStream.h" + + +namespace Hurricane { + + +// ------------------------------------------------------------------- +// Class : "FileReadGzStream". + + FileReadGzStream::FileReadGzStream ( std::FILE* fp + , char* buffer + , size_t bufferSize + ) + : fp_ (fp) + , bzfp_ (NULL) + , buffer_ (buffer) + , bufferSize_(bufferSize) + , bufferLast_(0) + , current_ (buffer_) + , readCount_ (0) + , count_ (0) + , eof_ (false) + , bzerror_ (BZ_OK) + { + assert(fp_ != 0); + assert(bufferSize >= 4); + + bzfp_ = BZ2_bzReadOpen( &bzerror_, fp_, 0, 0, NULL, 0 ); + if (bzerror_ != BZ_OK) { + cerr << Error( "FileReadGzStream::FileReadGzstream(): Unable to initialize bzip2 stream." ) << endl; + eof_ = true; + } + + Read(); + } + + + void FileReadGzStream::Read () + { + if (current_ < bufferLast_) + ++current_; + else if (not eof_) { + count_ += readCount_; + readCount_ = BZ2_bzRead( &bzerror_, bzfp_, buffer_, bufferSize_ ); + bufferLast_ = buffer_ + readCount_ - 1; + current_ = buffer_; + + if (readCount_ < bufferSize_) { + buffer_[readCount_] = '\0'; + ++bufferLast_; + eof_ = true; + } + + if (bzerror_ != BZ_OK) { + eof_ = true; + if (bzerror_ != BZ_STREAM_END) { + cerr << Error( "FileReadGzStream::Read(): Unexpected termination of bzip2 stream." ) << endl; + } + BZ2_bzReadClose ( &bzerror_, bzfp_ ); + } + } + } + + +} // Hurricane namespace. diff --git a/hurricane/src/hurricane/FileWriteGzStream.cpp b/hurricane/src/hurricane/FileWriteGzStream.cpp new file mode 100644 index 00000000..cc3f4efe --- /dev/null +++ b/hurricane/src/hurricane/FileWriteGzStream.cpp @@ -0,0 +1,79 @@ +// -*- mode: C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2016-2015, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./FileWriteGzStream.h" | +// +-----------------------------------------------------------------+ + + +#include +#include "hurricane/Error.h" +#include "hurricane/FileWriteGzStream.h" + + +namespace Hurricane { + + +// ------------------------------------------------------------------- +// Class : "FileWriteGzStream". + + FileWriteGzStream::FileWriteGzStream ( std::FILE* fp + , char* buffer + , size_t bufferSize + ) + : fp_ (fp) + , bzfp_ (NULL) + , buffer_ (buffer) + , bufferEnd_(buffer + bufferSize), current_(buffer_) + , bzerror_ (BZ_OK) + { + assert(fp_ != 0); + + bzfp_ = BZ2_bzWriteOpen( &bzerror_, fp_, 9, 0, 0 ); + if (bzerror_ != BZ_OK) { + cerr << Error( "FileWriteGzStream::FileWriteGzstream(): Unable to initialize bzip2 stream." ) << endl; + } + } + + + FileWriteGzStream::~FileWriteGzStream () + { + if (not bzfp_) return; + + unsigned int bytesin = 0; + unsigned int bytesout = 0; + + BZ2_bzWriteClose( &bzerror_, bzfp_, 0, &bytesin, &bytesout ); + if (bzerror_ != BZ_OK) { + cerr << Error( "FileWriteGzStream::~FileWritegzstream(): I/O error while closing stream." ) << endl; + } + } + + + void FileWriteGzStream::Flush () + { + if (current_ != buffer_) { + BZ2_bzWrite( &bzerror_,bzfp_, buffer_, static_cast(current_ - buffer_) ); + if (bzerror_ != BZ_OK) { + unsigned int bytesin = 0; + unsigned int bytesout = 0; + + BZ2_bzWriteClose( &bzerror_, bzfp_, 0, &bytesin, &bytesout ); + if (bzerror_ != BZ_OK) { + cerr << Error( "FileWriteGzStream::Write(): I/O error in bzip2 stream." ) << endl; + } + } + current_ = buffer_; + } + } + + +} // Hurricane namespace. diff --git a/hurricane/src/hurricane/Horizontal.cpp b/hurricane/src/hurricane/Horizontal.cpp index 67d478df..a0254040 100644 --- a/hurricane/src/hurricane/Horizontal.cpp +++ b/hurricane/src/hurricane/Horizontal.cpp @@ -208,6 +208,13 @@ Record* Horizontal::_getRecord() const // JsonHorizontal implementation // **************************************************************************************************** +Initializer jsonHorizontalInit ( 0 ); + + +void JsonHorizontal::initialize() +// ******************************* +{ JsonTypes::registerType( new JsonHorizontal (JsonWriter::RegisterMode) ); } + JsonHorizontal::JsonHorizontal(unsigned long flags) // ************************************************ : JsonSegment(flags) diff --git a/hurricane/src/hurricane/Initializer.cpp b/hurricane/src/hurricane/Initializer.cpp new file mode 100644 index 00000000..fdda77af --- /dev/null +++ b/hurricane/src/hurricane/Initializer.cpp @@ -0,0 +1,78 @@ +// -*- C++ -*- +// +// Copyright (c) BULL S.A. 2015-2015, All Rights Reserved +// +// This file is part of Hurricane. +// +// Hurricane is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// Hurricane is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- +// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU +// General Public License for more details. +// +// You should have received a copy of the Lesser GNU General Public +// License along with Hurricane. If not, see +// . +// +// +-----------------------------------------------------------------+ +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Authors : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Module : "./Initializer.cpp" | +// +-----------------------------------------------------------------+ + + +#include +#include "hurricane/Initializer.h" + + +namespace Hurricane { + + using namespace std; + + +// ------------------------------------------------------------------- +// Class : "Init". + + bool Init::_run = false; + Init::InitializerMap* Init::_initializers = NULL; + + + void Init::destroy () + { + if (_initializers) delete _initializers; + _initializers = NULL; + _run = false; + } + + + Init::InitializerMap& Init::initializers () + { + if (not _initializers) _initializers = new InitializerMap(); + return *_initializers; + } + + + void Init::addInitializer ( unsigned int order,initializer_t initFunction ) + { initializers().insert( make_pair(order,initFunction) ); } + + + bool Init::runOnce () + { + if (_run) return false; + + for ( auto init : initializers() ) init.second(); + _run = true; + + return true; + } + + +} // Hurricane namespace. diff --git a/hurricane/src/hurricane/Instance.cpp b/hurricane/src/hurricane/Instance.cpp index 260ed11b..564963bd 100644 --- a/hurricane/src/hurricane/Instance.cpp +++ b/hurricane/src/hurricane/Instance.cpp @@ -498,9 +498,10 @@ void Instance::uniquify() if (not _getSharedPathMap().isEmpty()) { cerr << Warning( "Instance::uniquify(): While uniquifying model %s of instance %s, SharedPathMap is not empty.\n" - " (Entity's Occurrences will still uses the original master Cell)" + " (%u Entity's Occurrences will still uses the original master Cell)" , getString(_masterCell->getName()).c_str() , getString(getName()).c_str() + , _getSharedPathMap()._getSize() ) << endl; } @@ -754,6 +755,12 @@ Record* Instance::PlacementStatus::_getRecord() const // JsonInstance implementation // **************************************************************************************************** +Initializer jsonInstanceInit ( 0 ); + +void JsonInstance::initialize() +// ***************************** +{ JsonTypes::registerType( new JsonInstance (JsonWriter::RegisterMode) ); } + JsonInstance::JsonInstance(unsigned long flags) // ******************************************** : JsonEntity(flags) @@ -782,7 +789,7 @@ void JsonInstance::toData(JsonStack& stack) Instance* instance = Instance::create ( get(stack,".Cell") , get(stack,"_name") - , DataBase::getDB()->getCell( get(stack,"_masterCell") ) + , DataBase::getDB()->getCell( get(stack,"_masterCell"), DataBase::NoFlags ) , get(stack,"_transformation") , Instance::PlacementStatus(get(stack,"_placementStatus") ) ); diff --git a/hurricane/src/hurricane/JsonReader.cpp b/hurricane/src/hurricane/JsonReader.cpp index beb50f92..cac0da23 100644 --- a/hurricane/src/hurricane/JsonReader.cpp +++ b/hurricane/src/hurricane/JsonReader.cpp @@ -32,6 +32,8 @@ #include "rapidjson/filereadstream.h" #include "rapidjson/reader.h" // Needed for registering. May be deleted later. +#include "hurricane/Initializer.h" +#include "hurricane/FileReadGzStream.h" #include "hurricane/DebugSession.h" #include "hurricane/Warning.h" #include "hurricane/JsonReader.h" @@ -112,14 +114,14 @@ namespace { JsonReader ( const JsonReader& ); JsonReader& operator= ( const JsonReader& ) const; private: - unsigned long _flags; - size_t _bufferSize; - char* _buffer; - FILE* _file; - FileReadStream* _stream; - JsonStack _stack; - Reader _reader; - HurricaneHandler _handler; + unsigned long _flags; + size_t _bufferSize; + char* _buffer; + FILE* _file; + FileReadGzStream* _stream; + JsonStack _stack; + Reader _reader; + HurricaneHandler _handler; }; @@ -150,7 +152,8 @@ namespace { bool HurricaneHandler::Null () { if (isDummy()) return true; - stack().push_back( _key, NULL ); + stack().push_back( _key, (DBo*)NULL ); + _key.clear(); return true; } @@ -159,6 +162,7 @@ namespace { { if (isDummy()) return true; stack().push_back( _key, v ); + _key.clear(); return true; } @@ -167,6 +171,7 @@ namespace { { if (isDummy()) return true; stack().push_back( _key, v ); + _key.clear(); return true; } @@ -175,6 +180,7 @@ namespace { { if (isDummy()) return true; stack().push_back( _key, v ); + _key.clear(); return true; } @@ -183,6 +189,7 @@ namespace { { if (isDummy()) return true; stack().push_back( _key, v ); + _key.clear(); return true; } @@ -191,6 +198,7 @@ namespace { { if (isDummy()) return true; stack().push_back( _key, v ); + _key.clear(); return true; } @@ -199,6 +207,7 @@ namespace { { if (isDummy()) return true; stack().push_back( _key, v ); + _key.clear(); return true; } @@ -211,6 +220,7 @@ namespace { if (_key != "@typename") { cerr << Warning("JsonReader::parse(): First field is not @typename, skipping object." ) << endl; + _key.clear(); return true; } @@ -239,10 +249,12 @@ namespace { } ltrace(51) << "HurricaneHandler::String() [key/typename] \"" << value << "\"." << endl; + _key.clear(); return true; } stack().push_back( _key, value ); + _key.clear(); return true; } @@ -276,8 +288,9 @@ namespace { ltracein(50); _state |= TypenameKey; - _objectName = (_key == ".Array") ? "" : _key; + _objectName = _key; _objects.push_back( new JsonDummy() ); + _key.clear(); ltrace(51) << "_objects.push_back(NULL), size():" << _objects.size() << "." << endl; ltracein(50); @@ -302,11 +315,12 @@ namespace { } } - //if (_objects.size() > 1) { - ltrace(51) << "_objects.pop_back(), size():" << _objects.size() << "." << endl; - delete _objects.back(); - _objects.pop_back(); - //} + ltrace(51) << "_objects.pop_back(), size():" << _objects.size() << "." << endl; + if (_objects.back()->issetFlags(JsonWriter::DBoObject)) + stack().pop_back_dbo(); + + delete _objects.back(); + _objects.pop_back(); ltraceout(50); return true; @@ -323,20 +337,16 @@ namespace { cerr << Warning("JsonReader::parse(): Array attributes must start by \'+\' %s.", _key.c_str() ) << endl; return true; } + _key.clear(); - _key = ".Array"; return true; } + bool HurricaneHandler::EndArray ( SizeType ) { ltraceout(50); ltrace(50) << "HurricaneHandler::EndArray()" << endl; - ltracein(50); - - _key.clear(); - - ltraceout(50); return true; } @@ -382,9 +392,9 @@ namespace { { close(); - DebugSession::open( 50 ); + //DebugSession::open( 50 ); - fileName += ".json"; + fileName += ".json.bz2"; _file = fopen( fileName.c_str(), "r" ); ltrace(50) << "_file:" << _file << ", _buffer:" << (void*)_buffer << endl; @@ -393,7 +403,7 @@ namespace { , fileName.c_str() ); } - _stream = new FileReadStream ( _file, _buffer, _bufferSize ); + _stream = new FileReadGzStream ( _file, _buffer, _bufferSize ); if (issetFlags(JsonWriter::DesignBlobMode)) Entity::enableForcedIdMode(); @@ -402,8 +412,10 @@ namespace { if (issetFlags(JsonWriter::DesignBlobMode)) Entity::disableForcedIdMode(); - DebugSession::close(); + //DebugSession::close(); close(); + + SharedProperty::clearOrphaneds(); } @@ -588,6 +600,8 @@ namespace Hurricane { // ------------------------------------------------------------------- // Class : "JsonTypes". + Initializer jsonTypesInitialize ( 10 ); + JsonTypes* JsonTypes::_jsonTypes = NULL; @@ -635,29 +649,7 @@ namespace Hurricane { void JsonTypes::initialize () - { - if (_jsonTypes) return; - - _jsonTypes = new JsonTypes (); - _jsonTypes->_registerType( new JsonPoint (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonBox (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonTransformation(JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonLibrary (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonCell (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonNet (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonDeepNet (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonPlugRef (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonRoutingPad (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonContact (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonVertical (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonHorizontal (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonPad (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonInstance (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonPlug (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonOccurrence (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonSignature (JsonWriter::RegisterMode) ); - _jsonTypes->_registerType( new JsonDesignBlob (JsonWriter::RegisterMode) ); - } + { if (not _jsonTypes) _jsonTypes = new JsonTypes (); } // ------------------------------------------------------------------- diff --git a/hurricane/src/hurricane/JsonWriter.cpp b/hurricane/src/hurricane/JsonWriter.cpp index a00e28e0..6e57b1dc 100644 --- a/hurricane/src/hurricane/JsonWriter.cpp +++ b/hurricane/src/hurricane/JsonWriter.cpp @@ -29,14 +29,16 @@ // +-----------------------------------------------------------------+ -#include "rapidjson/filewritestream.h" +//#include "rapidjson/filewritestream.h" #include "rapidjson/prettywriter.h" #include "hurricane/Commons.h" +#include "hurricane/FileWriteGzStream.h" //namespace Hurricane { - typedef rapidjson::PrettyWriter JsonOfstream; +//typedef rapidjson::PrettyWriter JsonOfstream; + typedef rapidjson::PrettyWriter JsonOfstream; #define _WRITER reinterpret_cast(_writer) @@ -53,7 +55,8 @@ , _writer (NULL) { _file = fopen( fileName.c_str(), "w" ); - _stream = new rapidjson::FileWriteStream ( _file, _buffer, _bufferSize ); + //_stream = new rapidjson::FileWriteGzStream ( _file, _buffer, _bufferSize ); + _stream = new Hurricane::FileWriteGzStream ( _file, _buffer, _bufferSize ); _writer = new JsonOfstream ( *_stream ); _WRITER->SetIndent( ' ', 2 ); } diff --git a/hurricane/src/hurricane/Library.cpp b/hurricane/src/hurricane/Library.cpp index 329c104b..1d7c342a 100644 --- a/hurricane/src/hurricane/Library.cpp +++ b/hurricane/src/hurricane/Library.cpp @@ -234,7 +234,7 @@ void Library::_toJson(JsonWriter* w) const Inherit::_toJson( w ); jsonWrite( w, "_name" , getName() ); - jsonWrite( w, "+cellMap" , getCells() ); +//jsonWrite( w, "+cellMap" , getCells() ); jsonWrite( w, "+libraryMap", getLibraries() ); } @@ -243,13 +243,19 @@ void Library::_toJson(JsonWriter* w) const // JsonLibrary implementation // **************************************************************************************************** +Initializer jsonLibraryInit ( 0 ); + +void JsonLibrary::initialize() +// ************************** +{ JsonTypes::registerType( new JsonLibrary (JsonWriter::RegisterMode) ); } + JsonLibrary::JsonLibrary(unsigned long flags) // ************************************ : JsonDBo(flags) { - add( ".Library" , typeid(Library*) ); +//add( ".Library" , typeid(Library*) ); add( "_name" , typeid(string) ); - add( "+cellMap" , typeid(JsonArray) ); +//add( "+cellMap" , typeid(JsonArray) ); add( "+libraryMap", typeid(JsonArray) ); } @@ -267,11 +273,14 @@ void JsonLibrary::toData(JsonStack& stack) check( stack, "JsonLibrary::toData" ); Name libName ( get ( stack, "_name" ) ); - Library* parent = get( stack, ".Library" ); - if (not parent) - parent = get( stack, "_library" ); - Library* library = NULL; + Library* parent = NULL; + + if (stack.rhas(".Library")) + parent = get( stack, ".Library" ); + else if (stack.rhas("_rootLibrary")) + parent = get( stack, "_rootLibrary" ); + if (parent) { library = parent->getLibrary( libName ); if (not library) diff --git a/hurricane/src/hurricane/Net.cpp b/hurricane/src/hurricane/Net.cpp index 3bf41410..e0309436 100644 --- a/hurricane/src/hurricane/Net.cpp +++ b/hurricane/src/hurricane/Net.cpp @@ -267,14 +267,14 @@ Net::Net(Cell* cell, const Name& name) _nextOfCellNetMap(NULL), _mainName(this) { - if (!_cell) - throw Error("Can't create " + _TName("Net") + " : null cell"); + if (!_cell) + throw Error("Can't create " + _TName("Net") + " : null cell"); - if (name.isEmpty()) - throw Error("Can't create " + _TName("Net") + " : empty name"); + if (name.isEmpty()) + throw Error("Can't create " + _TName("Net") + " : empty name"); - if (_cell->getNet(_name)) - throw Error("Can't create " + _TName("Net ") + getString(_name) + " : already exists"); + if (_cell->getNet(_name)) + throw Error("Can't create " + _TName("Net ") + getString(_name) + " : already exists"); } Net* Net::create(Cell* cell, const Name& name) @@ -1064,6 +1064,12 @@ string Net_SlavePlugs::Locator::_getString() const // JsonNet implementation // **************************************************************************************************** +Initializer jsonNetInit ( 0 ); + +void JsonNet::initialize() +// ************************** +{ JsonTypes::registerType( new JsonNet (JsonWriter::RegisterMode) ); } + JsonNet::JsonNet(unsigned long flags) // ********************************** : JsonEntity (flags) diff --git a/hurricane/src/hurricane/NetRoutingProperty.cpp b/hurricane/src/hurricane/NetRoutingProperty.cpp index ab67ea5a..d7c6c832 100644 --- a/hurricane/src/hurricane/NetRoutingProperty.cpp +++ b/hurricane/src/hurricane/NetRoutingProperty.cpp @@ -14,8 +14,9 @@ // +-----------------------------------------------------------------+ -#include "hurricane/NetRoutingProperty.h" -#include "hurricane/Net.h" +#include "hurricane/NetRoutingProperty.h" +#include "hurricane/Initializer.h" +#include "hurricane/Net.h" namespace Hurricane { @@ -24,13 +25,18 @@ namespace Hurricane { using Hurricane::Property; +// ------------------------------------------------------------------- +// Class : "NetRoutingState" + string NetRoutingState::_getString () const { string s; - if (isFixed ()) s += 'f'; - if (isManualGlobalRoute ()) s += 'm'; - if (isAutomaticGlobalRoute()) s += 'a'; + s += (isExcluded ()) ? 'e' : '-'; + s += (isFixed ()) ? 'f' : '-'; + s += (isUnconnected ()) ? 'u' : '-'; + s += (isManualGlobalRoute ()) ? 'm' : '-'; + s += (isAutomaticGlobalRoute()) ? 'a' : '-'; return s; } @@ -101,6 +107,88 @@ namespace Hurricane { } + bool NetRoutingProperty::hasJson () const + { return true; } + + + void NetRoutingProperty::toJson ( JsonWriter* w, const DBo* ) const + { + w->startObject(); + jsonWrite( w, "@typename", _getTypeName() ); + jsonWrite( w, "_state" , _state._getString() ); + w->endObject(); + } + + +// ------------------------------------------------------------------- +// Class : "JsonNetRoutingProperty" + + Initializer jsonNetRoutingPropertyInit ( 20 ); + + + JsonNetRoutingProperty::JsonNetRoutingProperty ( unsigned long flags ) + : JsonObject(flags) + { + add( "_state", typeid(string) ); + } + + + string JsonNetRoutingProperty::getTypeName () const + { return "NetRoutingProperty"; } + + + void JsonNetRoutingProperty::initialize () + { JsonTypes::registerType( new JsonNetRoutingProperty (JsonWriter::RegisterMode) ); } + + + JsonNetRoutingProperty* JsonNetRoutingProperty::clone ( unsigned long flags ) const + { return new JsonNetRoutingProperty ( flags ); } + + + void JsonNetRoutingProperty::toData ( JsonStack& stack ) + { + check( stack, "JsonNetRoutingProperty::toData" ); + + string sflags = get( stack, "_state" ); + unsigned int flags = 0; + + flags |= (sflags[0] == 'e') ? NetRoutingState::Excluded : 0; + flags |= (sflags[1] == 'f') ? NetRoutingState::Fixed : 0; + flags |= (sflags[2] == 'u') ? NetRoutingState::Unconnected : 0; + flags |= (sflags[3] == 'm') ? NetRoutingState::ManualGlobalRoute : 0; + flags |= (sflags[4] == 'a') ? NetRoutingState::AutomaticGlobalRoute : 0; + + NetRoutingProperty* property = NULL; + DBo* dbo = stack.back_dbo(); + if (dbo) { + Net* net = dynamic_cast( dbo ); + if (net) { + property = dynamic_cast( net->getProperty( NetRoutingProperty::getPropertyName() ) ); + if (property) { + cerr << Error( "JsonNetRoutingProperty::toData(): %s has already a NetRoutingProperty (overwrite)." + , getString(net).c_str() + ) << endl; + NetRoutingState* state = property->getState(); + state->unsetFlags( (unsigned int)-1 ); + state->setFlags( flags ); + } else { + property = NetRoutingProperty::create( net ); + property->getState()->setFlags( flags ); + net->put( property ); + } + } else { + cerr << Error( "JsonNetRoutingProperty::toData(): %s must be a Net." + , getString(dbo).c_str() + ) << endl; + } + } else { + cerr << Error( "JsonNetRoutingProperty::toData(): No DBo in stack to attach to." ) << endl; + } + + update( stack, property ); + } + + // ------------------------------------------------------------------- // Class : "NetRoutingExtension" diff --git a/hurricane/src/hurricane/Occurrence.cpp b/hurricane/src/hurricane/Occurrence.cpp index f3201ffd..b5ece974 100644 --- a/hurricane/src/hurricane/Occurrence.cpp +++ b/hurricane/src/hurricane/Occurrence.cpp @@ -34,23 +34,23 @@ namespace Hurricane { // **************************************************************************************************** Occurrence::Occurrence(const Entity* entity) -// ********************************* - : _entity(const_cast(entity)), - _sharedPath(NULL) +// ***************************************** + : _entity(const_cast(entity)) + , _sharedPath(NULL) { } Occurrence::Occurrence(const Entity* entity, const Path& path) -// *************************************************** - : _entity(const_cast(entity)), - _sharedPath(path._getSharedPath()) +// *********************************************************** + : _entity(const_cast(entity)) + , _sharedPath(path._getSharedPath()) { - if (!_entity) { - throw Error("Can't create " + _TName("Occurrence") + " : null entity"); - } - if (_sharedPath) - if (_entity->getCell() != _sharedPath->getMasterCell()) - throw Error("Can't create " + _TName("Occurrence") + " : incompatible path"); + if (!_entity) { + throw Error("Can't create " + _TName("Occurrence") + " : null entity"); + } + if (_sharedPath) + if (_entity->getCell() != _sharedPath->getMasterCell()) + throw Error("Can't create " + _TName("Occurrence") + " : incompatible path"); } Occurrence::Occurrence(const Occurrence& occurrence) @@ -324,6 +324,14 @@ string Occurrence::getName() const return description; } + +Initializer jsonOccurrenceInit ( 0 ); + + +void JsonOccurrence::initialize() +// ******************************* +{ JsonTypes::registerType( new JsonOccurrence (JsonWriter::RegisterMode) ); } + JsonOccurrence::JsonOccurrence(unsigned long flags) // ************************************************ : JsonObject(flags) diff --git a/hurricane/src/hurricane/Pad.cpp b/hurricane/src/hurricane/Pad.cpp index 7c23d9e9..81554c64 100644 --- a/hurricane/src/hurricane/Pad.cpp +++ b/hurricane/src/hurricane/Pad.cpp @@ -153,6 +153,13 @@ Record* Pad::_getRecord() const // JsonPad implementation // **************************************************************************************************** +Initializer jsonPadInit ( 0 ); + + +void JsonPad::initialize() +// ************************ +{ JsonTypes::registerType( new JsonPad (JsonWriter::RegisterMode) ); } + JsonPad::JsonPad(unsigned long flags) // ********************************** : JsonComponent(flags) diff --git a/hurricane/src/hurricane/Plug.cpp b/hurricane/src/hurricane/Plug.cpp index 6027c3de..071dce49 100644 --- a/hurricane/src/hurricane/Plug.cpp +++ b/hurricane/src/hurricane/Plug.cpp @@ -236,6 +236,13 @@ string Plug::getName() const // JsonPlug implementation // **************************************************************************************************** +Initializer jsonPlugInit ( 0 ); + + +void JsonPlug::initialize() +// ************************* +{ JsonTypes::registerType( new JsonPlug (JsonWriter::RegisterMode) ); } + JsonPlug::JsonPlug(unsigned long flags) // ************************************ : JsonComponent(flags) @@ -294,6 +301,12 @@ void JsonPlug::toData(JsonStack& stack) // JsonPlugRef implementation // **************************************************************************************************** +Initializer jsonPlugRefInit ( 0 ); + +void JsonPlugRef::initialize() +// **************************** +{ JsonTypes::registerType( new JsonPlugRef (JsonWriter::RegisterMode) ); } + JsonPlugRef::JsonPlugRef(unsigned long flags) // ****************************************** : JsonObject(flags) diff --git a/hurricane/src/hurricane/Point.cpp b/hurricane/src/hurricane/Point.cpp index 7f6f5a05..8253f245 100644 --- a/hurricane/src/hurricane/Point.cpp +++ b/hurricane/src/hurricane/Point.cpp @@ -126,6 +126,7 @@ Record* Point::_getRecord() const void Point::toJson ( JsonWriter* w ) const // **************************************** { + w->startObject(); jsonWrite( w, "@typename", "Point" ); jsonWrite( w, "_x", getX() ); @@ -133,6 +134,12 @@ void Point::toJson ( JsonWriter* w ) const w->endObject(); } +Initializer jsonPointInit ( 0 ); + +void JsonPoint::initialize() +// ************************** +{ JsonTypes::registerType( new JsonPoint (JsonWriter::RegisterMode) ); } + JsonPoint::JsonPoint(unsigned long flags) // ************************************** : JsonObject(flags) diff --git a/hurricane/src/hurricane/Property.cpp b/hurricane/src/hurricane/Property.cpp index 13b13d16..f9f13618 100644 --- a/hurricane/src/hurricane/Property.cpp +++ b/hurricane/src/hurricane/Property.cpp @@ -1,4 +1,3 @@ - // -*- C++ -*- // // Copyright (c) BULL S.A. 2000-2015, All Rights Reserved @@ -86,6 +85,13 @@ namespace Hurricane { } + bool Property::hasJson () const + { return false; } + + + void Property::toJson ( JsonWriter*, const DBo* ) const + { } + // ------------------------------------------------------------------- // Class : "Hurricane::PrivateProperty". @@ -141,6 +147,76 @@ namespace Hurricane { // ------------------------------------------------------------------- // Class : "Hurricane::SharedProperty". + SharedProperty::OrphanedMap SharedProperty::_orphaneds; + + + const SharedProperty::OrphanedMap& SharedProperty::getOrphaneds () + { return _orphaneds; } + + + SharedProperty* SharedProperty::getOrphaned ( const string& tag ) + { + auto iorphaned = _orphaneds.find( tag ); + if (iorphaned != _orphaneds.end()) return (*iorphaned).second._property; + + return NULL; + } + + + void SharedProperty::addOrphaned ( const string& tag, SharedProperty* property ) + { + auto iorphaned = _orphaneds.find( tag ); + if (iorphaned == _orphaneds.end()) { + _orphaneds.insert( make_pair(tag,Orphaned(property)) ); + } else { + if ((*iorphaned).second._property != property) { + cerr << Error( "SharedProperty::addOrphaned(): Multiple properties with the same tag \"%s\"." + , tag.c_str() + ) << endl; + } + } + } + + + void SharedProperty::refOrphaned ( const string& tag ) + { + auto iorphaned = _orphaneds.find( tag ); + if (iorphaned != _orphaneds.end()) { + (*iorphaned).second._refcount++; + } + } + + + void SharedProperty::countOrphaned ( const string& tag , unsigned int count ) + { + auto iorphaned = _orphaneds.find( tag ); + if (iorphaned != _orphaneds.end()) { + (*iorphaned).second._count = count; + } + } + + + void SharedProperty::removeOrphaned ( const string& tag ) + { + auto iorphaned = _orphaneds.find( tag ); + if (iorphaned != _orphaneds.end()) _orphaneds.erase( iorphaned ); + } + + + void SharedProperty::clearOrphaneds () + { + for ( auto element : _orphaneds ) { + if (element.second._refcount != element.second._count) { + cerr << Error( "SharedProperty::clearOrphaneds(): On tag \"%s\", count:%u refcount:%u." + , element.first.c_str() + , element.second._count + , element.second._refcount + ) << endl; + } + } + _orphaneds.clear(); + } + SharedProperty::SharedProperty () : Property() diff --git a/hurricane/src/hurricane/RoutingPad.cpp b/hurricane/src/hurricane/RoutingPad.cpp index 81465ada..a7b313be 100644 --- a/hurricane/src/hurricane/RoutingPad.cpp +++ b/hurricane/src/hurricane/RoutingPad.cpp @@ -403,6 +403,13 @@ namespace Hurricane { // ------------------------------------------------------------------- // Class : "JsonRoutingPad". + Initializer jsonRoutingPadInit ( 0 ); + + + void JsonRoutingPad::initialize () + { JsonTypes::registerType( new JsonRoutingPad (JsonWriter::RegisterMode) ); } + + JsonRoutingPad::JsonRoutingPad ( unsigned long flags ) : JsonComponent(flags) { diff --git a/hurricane/src/hurricane/Signature.cpp b/hurricane/src/hurricane/Signature.cpp index cbc1dc27..8755dc58 100644 --- a/hurricane/src/hurricane/Signature.cpp +++ b/hurricane/src/hurricane/Signature.cpp @@ -59,6 +59,13 @@ namespace Hurricane { // ------------------------------------------------------------------- // Class : "JsonSignature". + Initializer jsonSignatureInit ( 0 ); + + + void JsonSignature::initialize () + { JsonTypes::registerType( new JsonSignature (JsonWriter::RegisterMode) ); } + + JsonSignature::JsonSignature ( unsigned long flags ) : JsonObject (flags) , _subTypeName("unset") diff --git a/hurricane/src/hurricane/Transformation.cpp b/hurricane/src/hurricane/Transformation.cpp index 904779e0..69f2e735 100644 --- a/hurricane/src/hurricane/Transformation.cpp +++ b/hurricane/src/hurricane/Transformation.cpp @@ -320,9 +320,15 @@ Record* Transformation::Orientation::_getRecord() const // **************************************************************************************************** -// Transformation::Orientation implementation +// JsonTransformation implementation // **************************************************************************************************** +Initializer jsonTransformationInit ( 0 ); + +void JsonTransformation::initialize() +// ************************** +{ JsonTypes::registerType( new JsonTransformation (JsonWriter::RegisterMode) ); } + JsonTransformation::JsonTransformation(unsigned long flags) // ******************************************************** : JsonObject(flags) diff --git a/hurricane/src/hurricane/UpdateSession.cpp b/hurricane/src/hurricane/UpdateSession.cpp index 0a6e31e2..e751b000 100644 --- a/hurricane/src/hurricane/UpdateSession.cpp +++ b/hurricane/src/hurricane/UpdateSession.cpp @@ -36,8 +36,7 @@ stack* UPDATOR_STACK = NULL; UpdateSession::UpdateSession() // *************************** : Inherit() -{ -} +{ } void UpdateSession::destroy() // ************************* @@ -126,9 +125,9 @@ Record* UpdateSession::_getRecord() const return record; } - void UpdateSession::onCapturedBy(DBo* owner) - // ***************************************** - { +void UpdateSession::onCapturedBy(DBo* owner) +// ***************************************** +{ if ( not dynamic_cast(owner) and not dynamic_cast(owner) ) throw Error( "Bad update session capture : not a graphic object (Go) or a Cell" ); @@ -137,8 +136,7 @@ Record* UpdateSession::_getRecord() const void UpdateSession::onNotOwned() // ***************************** -{ -} +{ } @@ -146,9 +144,9 @@ void UpdateSession::onNotOwned() // Go::invalidate implementation : located here to access UPDATOR_STACK variable // **************************************************************************************************** - void Go::invalidate(bool propagateFlag) - // ************************************ - { +void Go::invalidate(bool propagateFlag) +// ************************************ +{ // trace << "invalidate(" << this << ")" << endl; // trace_in(); diff --git a/hurricane/src/hurricane/Vertical.cpp b/hurricane/src/hurricane/Vertical.cpp index e34b14eb..a0075bf8 100644 --- a/hurricane/src/hurricane/Vertical.cpp +++ b/hurricane/src/hurricane/Vertical.cpp @@ -211,6 +211,13 @@ Record* Vertical::_getRecord() const // JsonVertical implementation // **************************************************************************************************** +Initializer jsonVerticalInit ( 0 ); + + +void JsonVertical::initialize() +// ***************************** +{ JsonTypes::registerType( new JsonVertical (JsonWriter::RegisterMode) ); } + JsonVertical::JsonVertical(unsigned long flags) // ******************************************** : JsonSegment(flags) diff --git a/hurricane/src/hurricane/hurricane/Box.h b/hurricane/src/hurricane/hurricane/Box.h index 37c37337..c22478d5 100644 --- a/hurricane/src/hurricane/hurricane/Box.h +++ b/hurricane/src/hurricane/hurricane/Box.h @@ -130,6 +130,7 @@ class Box { class JsonBox : public JsonObject { // ******************************** + public: static void initialize(); public: JsonBox(unsigned long); public: virtual string getTypeName() const; public: virtual JsonBox* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/Cell.h b/hurricane/src/hurricane/hurricane/Cell.h index 55107f02..a82985c3 100644 --- a/hurricane/src/hurricane/hurricane/Cell.h +++ b/hurricane/src/hurricane/hurricane/Cell.h @@ -110,15 +110,39 @@ class Cell : public Entity { virtual Name getName () const; static Name staticGetName (); Name getUniqueName (); + static std::string getTrunkName ( Name name ); + virtual bool hasJson () const; + virtual void toJson ( JsonWriter*, const DBo* ) const; + inline void _setOwner ( Cell* ); + inline void _setDuplicates ( unsigned int ); virtual string _getTypeName () const; virtual Record* _getRecord () const; private: static const Name _name; - unsigned int _duplicates; + unsigned int _duplicates; private: UniquifyRelation ( Cell* ); protected: virtual void _preDestroy (); + + public: + class JsonProperty : public JsonObject { + public: + static void initialize (); + JsonProperty ( unsigned long flags ); + virtual string getTypeName () const; + virtual JsonProperty* clone ( unsigned long ) const; + virtual void toData ( JsonStack& ); + }; + public: + class JsonPropertyRef : public JsonObject { + public: + static void initialize (); + JsonPropertyRef ( unsigned long flags ); + virtual string getTypeName () const; + virtual JsonPropertyRef* clone ( unsigned long ) const; + virtual void toData ( JsonStack& ); + }; }; class ClonedSet : public Collection { @@ -446,9 +470,14 @@ inline Cell::ClonedSet::ClonedSet ( const ClonedSet& other ) { } +inline void Cell::UniquifyRelation::_setOwner ( Cell* owner ) { _setMasterOwner(owner); } +inline void Cell::UniquifyRelation::_setDuplicates ( unsigned int duplicates ) { _duplicates=duplicates; } + + class JsonCell : public JsonEntity { // ********************************* + public: static void initialize(); public: JsonCell(unsigned long flags); public: virtual string getTypeName() const; public: virtual JsonCell* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/Commons.h b/hurricane/src/hurricane/hurricane/Commons.h index 7ccabc15..cc841002 100644 --- a/hurricane/src/hurricane/hurricane/Commons.h +++ b/hurricane/src/hurricane/hurricane/Commons.h @@ -739,6 +739,7 @@ inline Hurricane::Record* getRecord ( const std::multiset* s ) // x-----------------------------------------------------------------x #include "hurricane/Slot.h" +#include "hurricane/Initializer.h" #include "hurricane/Tabulation.h" #include "hurricane/JsonWriter.h" #include "hurricane/JsonReader.h" diff --git a/hurricane/src/hurricane/hurricane/Contact.h b/hurricane/src/hurricane/hurricane/Contact.h index 93b91c44..211879ab 100644 --- a/hurricane/src/hurricane/hurricane/Contact.h +++ b/hurricane/src/hurricane/hurricane/Contact.h @@ -152,6 +152,7 @@ class Contact : public Component { class JsonContact : public JsonComponent { // *************************************** + public: static void initialize(); public: JsonContact(unsigned long flags); public: virtual string getTypeName() const; public: virtual JsonContact* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/DBo.h b/hurricane/src/hurricane/hurricane/DBo.h index 44714b2b..ba582469 100644 --- a/hurricane/src/hurricane/hurricane/DBo.h +++ b/hurricane/src/hurricane/hurricane/DBo.h @@ -89,8 +89,16 @@ namespace Hurricane { class JsonDBo : public JsonObject { public: - JsonDBo ( unsigned int flags ); -}; + JsonDBo ( unsigned int flags ); + template inline void update ( JsonStack&, T ); + }; + + + template inline void JsonDBo::update ( JsonStack& stack, T hobject ) + { + JsonObject::update( stack, hobject ); + stack.push_back_dbo( dynamic_cast(hobject) ); + } } // Hurricane namespace. diff --git a/hurricane/src/hurricane/hurricane/DataBase.h b/hurricane/src/hurricane/hurricane/DataBase.h index efd1bc22..b6c40c43 100644 --- a/hurricane/src/hurricane/hurricane/DataBase.h +++ b/hurricane/src/hurricane/hurricane/DataBase.h @@ -21,6 +21,7 @@ #define HURRICANE_DATA_BASE #include +#include #include "hurricane/DBo.h" #include "hurricane/DbU.h" @@ -43,6 +44,9 @@ class DataBase : public DBo { // ***** public: typedef DBo Inherit; + public: enum Flags { NoFlags = 0 + , CreateLib =(1<<0) + , WarnCreateLib=(1<<2) }; // Attributes // ********** @@ -64,6 +68,7 @@ class DataBase : public DBo { protected: virtual void _preDestroy(); + public: virtual void _toJson(JsonWriter*) const; public: virtual string _getTypeName() const {return _TName("DataBase");}; public: virtual string _getString() const; public: virtual Record* _getRecord() const; @@ -79,12 +84,29 @@ class DataBase : public DBo { public: Technology* getTechnology() const {return _technology;}; public: Library* getRootLibrary() const {return _rootLibrary;}; - public: Library* getLibrary(string) const; - public: Cell* getCell(string) const; + public: Library* getLibrary(string,unsigned int flags); + public: Cell* getCell(string, unsigned int flags); public: static DataBase* getDB(); }; + + +// **************************************************************************************************** +// JsonDataBase declaration +// **************************************************************************************************** + +class JsonDataBase : public JsonDBo { +// ******************************** + + public: static void initialize(); + public: JsonDataBase(unsigned long flags); + public: virtual string getTypeName() const; + public: virtual JsonDataBase* clone(unsigned long) const; + public: virtual void toData(JsonStack&); +}; + + } // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/hurricane/DeepNet.h b/hurricane/src/hurricane/hurricane/DeepNet.h index 6ff462d3..ca5712ff 100644 --- a/hurricane/src/hurricane/hurricane/DeepNet.h +++ b/hurricane/src/hurricane/hurricane/DeepNet.h @@ -71,6 +71,7 @@ namespace Hurricane { class JsonDeepNet : public JsonNet { public: + static void initialize (); JsonDeepNet ( unsigned long flags ); virtual ~JsonDeepNet (); virtual string getTypeName () const; diff --git a/hurricane/src/hurricane/hurricane/DesignBlob.h b/hurricane/src/hurricane/hurricane/DesignBlob.h index c5c9adaf..814e199b 100644 --- a/hurricane/src/hurricane/hurricane/DesignBlob.h +++ b/hurricane/src/hurricane/hurricane/DesignBlob.h @@ -48,6 +48,7 @@ namespace Hurricane { class JsonDesignBlob : public JsonObject { public: + static void initialize (); JsonDesignBlob ( unsigned long flags ); virtual std::string getTypeName () const; virtual JsonDesignBlob* clone ( unsigned long ) const; diff --git a/hurricane/src/hurricane/hurricane/Entity.h b/hurricane/src/hurricane/hurricane/Entity.h index 2fe01aec..5d967dc6 100644 --- a/hurricane/src/hurricane/hurricane/Entity.h +++ b/hurricane/src/hurricane/hurricane/Entity.h @@ -87,14 +87,14 @@ namespace Hurricane { public: JsonEntity ( unsigned long flags ); template inline void update ( JsonStack&, T ); -}; + }; template inline void JsonEntity::update ( JsonStack& stack, T hobject ) { unsigned int jsonId = get(stack,"_id"); - JsonObject::update( stack, hobject ); + JsonDBo::update( stack, hobject ); stack.addEntity( jsonId, hobject ); } diff --git a/hurricane/src/hurricane/hurricane/FileReadGzStream.h b/hurricane/src/hurricane/hurricane/FileReadGzStream.h new file mode 100644 index 00000000..bb30691e --- /dev/null +++ b/hurricane/src/hurricane/hurricane/FileReadGzStream.h @@ -0,0 +1,73 @@ +// -*- mode: C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2016-2015, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/FileReadGzStream.h" | +// +-----------------------------------------------------------------+ + + +#ifndef HURRICANE_FILEREADGZSTREAM_H +#define HURRICANE_FILEREADGZSTREAM_H + + +namespace Hurricane { + + typedef void BZFILE; // Must be identical to the typedef in . + + +// ------------------------------------------------------------------- +// Class : "FileReadGzStream". + + class FileReadGzStream { + public: + typedef char Ch; + public: + FileReadGzStream ( std::FILE* fp + , char* buffer + , size_t bufferSize + ); + inline Ch Peek () const; + inline Ch Take (); + inline size_t Tell () const; + inline void Put ( Ch ); + inline void Flush (); + inline Ch* PutBegin (); + inline size_t PutEnd ( Ch* ); + inline const Ch* Peek4 () const; + private: + void Read (); + private: + std::FILE* fp_; + BZFILE* bzfp_; + Ch* buffer_; + size_t bufferSize_; + Ch* bufferLast_; + Ch* current_; + size_t readCount_; + size_t count_; + bool eof_; + int bzerror_; + }; + + + inline FileReadGzStream::Ch FileReadGzStream::Peek () const { return *current_; } + inline FileReadGzStream::Ch FileReadGzStream::Take () { Ch c = *current_; Read(); return c; } + inline size_t FileReadGzStream::Tell () const { return count_ + static_cast(current_ - buffer_); } + inline void FileReadGzStream::Put ( Ch ) { assert(false); } + inline void FileReadGzStream::Flush () { assert(false); } + inline FileReadGzStream::Ch* FileReadGzStream::PutBegin () { assert(false); return 0; } + inline size_t FileReadGzStream::PutEnd ( Ch* ) { assert(false); return 0; } + inline const FileReadGzStream::Ch* FileReadGzStream::Peek4 () const { return (current_ + 4 <= bufferLast_) ? current_ : 0; } + + +} // Hurricane namespace. + +#endif // HURRICANE_FILEREADGZSTREAM_H diff --git a/hurricane/src/hurricane/hurricane/FileWriteGzStream.h b/hurricane/src/hurricane/hurricane/FileWriteGzStream.h new file mode 100644 index 00000000..0ea2c199 --- /dev/null +++ b/hurricane/src/hurricane/hurricane/FileWriteGzStream.h @@ -0,0 +1,100 @@ +// -*- mode: C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC 2016-2015, All Rights Reserved +// +// +-----------------------------------------------------------------+ +// | C O R I O L I S | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/FileWriteGzStream.h" | +// +-----------------------------------------------------------------+ + + +#ifndef HURRICANE_FILEWRITEGZSTREAM_H +#define HURRICANE_FILEWRITEGZSTREAM_H + +#include "rapidjson/rapidjson.h" + + +namespace Hurricane { + + typedef void BZFILE; // Must be identical to the typedef in . + + + class FileWriteGzStream { + public: + typedef char Ch; + public: + FileWriteGzStream ( std::FILE* fp, char* buffer, size_t bufferSize ); + ~FileWriteGzStream (); + inline void Put ( char c ); + inline void PutN ( char c, size_t n ); + void Flush (); + inline char Peek () const; + inline char Take (); + inline size_t Tell () const; + inline char* PutBegin (); + inline size_t PutEnd ( char* ); + private: + FileWriteGzStream ( const FileWriteGzStream& ); + FileWriteGzStream& operator= ( const FileWriteGzStream& ); + private: + std::FILE* fp_; + BZFILE* bzfp_; + char* buffer_; + char* bufferEnd_; + char* current_; + int bzerror_; + }; + + + inline void FileWriteGzStream::Put ( char c ) + { + if (current_ >= bufferEnd_) Flush(); + *current_++ = c; + } + + + inline void FileWriteGzStream::PutN ( char c, size_t n ) + { + size_t avail = static_cast( bufferEnd_ - current_ ); + while (n > avail) { + std::memset( current_, c, avail ); + current_ += avail; + Flush(); + n -= avail; + avail = static_cast( bufferEnd_ - current_ ); + } + + if (n > 0) { + std::memset( current_, c, n ); + current_ += n; + } + } + + +// Not implemented + inline char FileWriteGzStream::Peek () const { assert(false); return 0; } + inline char FileWriteGzStream::Take () { assert(false); return 0; } + inline size_t FileWriteGzStream::Tell () const { assert(false); return 0; } + inline char* FileWriteGzStream::PutBegin () { assert(false); return 0; } + inline size_t FileWriteGzStream::PutEnd ( char* ) { assert(false); return 0; } + + +} // Hurricane namespace. + + +namespace rapidjson { + + + template<> + inline void PutN ( Hurricane::FileWriteGzStream& stream, char c, size_t n ) { stream.PutN(c,n); } + + +} // rapidjson namespace. + +#endif // HURRICANE_FILEWRITEGZSTREAM_H diff --git a/hurricane/src/hurricane/hurricane/Horizontal.h b/hurricane/src/hurricane/hurricane/Horizontal.h index 2a2cdcd7..e3004c20 100644 --- a/hurricane/src/hurricane/hurricane/Horizontal.h +++ b/hurricane/src/hurricane/hurricane/Horizontal.h @@ -116,6 +116,7 @@ class Horizontal : public Segment { class JsonHorizontal : public JsonSegment { // **************************************** + public: static void initialize(); public: JsonHorizontal(unsigned long flags); public: virtual string getTypeName() const; public: virtual JsonHorizontal* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/Initializer.h b/hurricane/src/hurricane/hurricane/Initializer.h new file mode 100644 index 00000000..38863ba5 --- /dev/null +++ b/hurricane/src/hurricane/hurricane/Initializer.h @@ -0,0 +1,72 @@ +// -*- C++ -*- +// +// Copyright (c) BULL S.A. 2015-2015, All Rights Reserved +// +// This file is part of Hurricane. +// +// Hurricane is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// Hurricane is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- +// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU +// General Public License for more details. +// +// You should have received a copy of the Lesser GNU General Public +// License along with Hurricane. If not, see +// . +// +// +-----------------------------------------------------------------+ +// | H U R R I C A N E | +// | V L S I B a c k e n d D a t a - B a s e | +// | | +// | Authors : Jean-Paul Chaput | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/Initializer.h" | +// +-----------------------------------------------------------------+ + + +#ifndef HURRICANE_INITIALIZER_H +#define HURRICANE_INITIALIZER_H + +#include +#include + + +namespace Hurricane { + + +// ------------------------------------------------------------------- +// Class : "Init". + + class Init { + public: + typedef std::function initializer_t; + typedef std::multimap InitializerMap; + public: + static void destroy (); + static InitializerMap& initializers (); + static void addInitializer ( unsigned int order, initializer_t ); + static bool runOnce (); + private: + static bool _run; + static InitializerMap* _initializers; + }; + + +// ------------------------------------------------------------------- +// Class : "Initializer". + + template + class Initializer { + public: + inline Initializer ( unsigned int order ) { Init::addInitializer( order, T::initialize ); } + }; + + +} // Hurricane namespace. + +#endif // HURRICANE_INITIALIZER_H diff --git a/hurricane/src/hurricane/hurricane/Instance.h b/hurricane/src/hurricane/hurricane/Instance.h index 19cab0d0..cf73183d 100644 --- a/hurricane/src/hurricane/hurricane/Instance.h +++ b/hurricane/src/hurricane/hurricane/Instance.h @@ -197,6 +197,7 @@ class Instance : public Go { class JsonInstance : public JsonEntity { // ************************************* + public: static void initialize(); public: JsonInstance(unsigned long flags); public: virtual string getTypeName() const; public: virtual JsonInstance* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/JsonReader.h b/hurricane/src/hurricane/hurricane/JsonReader.h index 16f62490..94695d3c 100644 --- a/hurricane/src/hurricane/hurricane/JsonReader.h +++ b/hurricane/src/hurricane/hurricane/JsonReader.h @@ -32,6 +32,10 @@ #ifndef HURRICANE_JSON_READER_H #define HURRICANE_JSON_READER_H +#ifndef HURRICANE_SLOT_H +#error "JsonWriter.h must be included through Commons.h" +#endif + #include #include #include @@ -45,6 +49,7 @@ namespace Hurricane { + class DBo; class Hook; class Entity; class Cell; @@ -86,7 +91,7 @@ namespace Hurricane { virtual bool isDummy () const; virtual std::string getTypeName () const = 0; inline std::string getStackName () const; - bool check ( JsonStack&, string fname ) const; + bool check ( JsonStack&, std::string fname ) const; void print ( std::ostream& ) const; bool has ( const std::string& key ) const; void add ( const std::string& key, std::type_index tid ); @@ -95,12 +100,11 @@ namespace Hurricane { inline void copyAttrs ( const JsonObject*, bool reset=false ); inline void clear (); inline std::string getName () const; - inline void setName ( const string& ); + inline void setName ( const std::string& ); template inline T& getObject () const; - template inline void setObject ( T& ) ; + template inline void setObject ( T ) ; inline bool isBound () const; virtual JsonObject* clone ( unsigned long flags ) const = 0; - template void toJson ( JsonWriter*, C* object ) const; virtual void toData ( JsonStack& ); unsigned int presetId ( JsonStack& ); template inline void update ( JsonStack&, T ); @@ -130,7 +134,7 @@ namespace Hurricane { template inline T& JsonObject::getObject () const { return boost::any_cast(_object); } - template inline void JsonObject::setObject ( T& t ) + template inline void JsonObject::setObject ( T t ) { _object = t; } inline void JsonObject::copyAttrs ( const JsonObject* other, bool reset ) @@ -294,6 +298,9 @@ namespace Hurricane { inline int rhas ( const std::string& ) const; template inline T as ( const std::string& ) const; template inline T as ( int ) const; + inline void push_back_dbo ( DBo* ); + inline void pop_back_dbo (); + inline DBo* back_dbo () const; template inline T getEntity ( unsigned int ) const; void addEntity ( unsigned int jsonId, Entity* ); void addHookLink ( Hook*, unsigned int jsonId, const std::string& jsonNext ); @@ -309,18 +316,19 @@ namespace Hurricane { private: unsigned long _flags; vector _stack; + vector _dbos; std::map _entities; HookLut _hooks; }; inline JsonStack::JsonStack () - : _flags(0), _stack(), _entities(), _hooks() + : _flags(0), _stack(), _dbos(), _entities(), _hooks() { } template inline void JsonStack::push_back ( const std::string& key, T t ) { - ltrace(51) << "JsonStack::push_back() key:" << key << " value:" << t + ltrace(51) << "JsonStack::push_back(T) key:" << key << " value:" << t << " (" << demangle(typeid(T)) << ")." << endl; _stack.push_back(std::make_pair(key,boost::any(t))); } @@ -333,7 +341,8 @@ namespace Hurricane { << (count+1) << " elements remains to pop." << std::endl; break; } - ltrace(51) << "| _stack.pop_back() " << _stack.back().first << endl; + ltrace(51) << "| _stack.pop_back() \"" << _stack.back().first + << "\", size:" << _stack.size() << ", dbos:" << _dbos.size() << endl; _stack.pop_back(); } } @@ -395,6 +404,7 @@ namespace Hurricane { return boost::any_cast( _stack[i].second ); } + template inline T JsonStack::getEntity ( unsigned int id ) const { std::map::const_iterator it = _entities.find(id); @@ -402,6 +412,9 @@ namespace Hurricane { return dynamic_cast((*it).second); } + inline void JsonStack::push_back_dbo ( DBo* dbo ) { _dbos.push_back(dbo); } + inline void JsonStack::pop_back_dbo () { _dbos.pop_back(); } + inline DBo* JsonStack::back_dbo () const { return (_dbos.empty()) ? NULL : _dbos.back(); } inline void JsonStack::clearHookLinks () { _hooks.clear(); } inline size_t JsonStack::size () const { return _stack.size(); } inline JsonStack* JsonStack::setFlags ( unsigned long mask ) { _flags |= mask; return this; } @@ -419,8 +432,10 @@ namespace Hurricane { return stack.as( index ); } - template inline void JsonObject::update ( JsonStack& stack, T hobject ) + template + inline void JsonObject::update ( JsonStack& stack, T hobject ) { + ltrace(51) << "JsonObject::update()" << endl; stack.pop_back( _attributes.size() ); stack.push_back( getStackName(), hobject ); setObject( hobject ); diff --git a/hurricane/src/hurricane/hurricane/JsonWriter.h b/hurricane/src/hurricane/hurricane/JsonWriter.h index 93304d27..5b7ace29 100644 --- a/hurricane/src/hurricane/hurricane/JsonWriter.h +++ b/hurricane/src/hurricane/hurricane/JsonWriter.h @@ -43,6 +43,9 @@ namespace rapidjson { class FileWriteStream; } +namespace Hurricane { + class FileWriteGzStream; +} //namespace Hurricane { @@ -55,6 +58,11 @@ namespace rapidjson { , DesignBlobMode = (1<<1) , CellMode = (1<<2) , RegisterMode = (1<<3) + , RegisterStatus = (1<<4) + , RegisterType = (1<<5) + , UnregisterType = (1<<6) + , CellObject = (1<<7) + , DBoObject = (1<<8) }; public: JsonWriter ( std::string fileName ); @@ -88,12 +96,13 @@ namespace rapidjson { JsonWriter ( const JsonWriter& ); JsonWriter& operator= ( const JsonWriter& ) const; private: - unsigned long _flags; - size_t _bufferSize; - char* _buffer; - FILE* _file; - rapidjson::FileWriteStream* _stream; - void* _writer; + unsigned long _flags; + size_t _bufferSize; + char* _buffer; + FILE* _file; + //rapidjson::FileWriteStream* _stream; + Hurricane::FileWriteGzStream* _stream; + void* _writer; }; @@ -172,6 +181,15 @@ inline void jsonWrite ( JsonWriter* w, const std::string& key, const std::strin { w->key( key ); w->write( value ); } +template +inline void jsonWrite ( JsonWriter* w, const std::string& key, const C& ) +{ + w->key( key ); + std::string message = "Unsupported type " + Hurricane::demangle(typeid(C).name()); + w->write( message.c_str() ); +} + + template inline void jsonWrite ( JsonWriter* w, const C* object ) { @@ -187,6 +205,13 @@ inline void jsonWrite ( JsonWriter* w, const C* object ) } +template +inline void jsonWrite ( JsonWriter* w, const std::string& key, C* object ) +{ + jsonWrite( w, key, const_cast(object) ); +} + + template inline void jsonWrite ( JsonWriter* w, const std::string& key, const C* object ) { diff --git a/hurricane/src/hurricane/hurricane/Library.h b/hurricane/src/hurricane/hurricane/Library.h index f36ee18a..509f2de7 100644 --- a/hurricane/src/hurricane/hurricane/Library.h +++ b/hurricane/src/hurricane/hurricane/Library.h @@ -129,6 +129,7 @@ class Library : public DBo { class JsonLibrary : public JsonDBo { // ******************************* + public: static void initialize(); public: JsonLibrary(unsigned long flags); public: virtual string getTypeName() const; public: virtual JsonLibrary* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/Net.h b/hurricane/src/hurricane/hurricane/Net.h index 587e8ffc..5587cdbc 100644 --- a/hurricane/src/hurricane/hurricane/Net.h +++ b/hurricane/src/hurricane/hurricane/Net.h @@ -262,6 +262,7 @@ class Net : public Entity { class JsonNet : public JsonEntity { // ******************************** + public: static void initialize(); public: JsonNet(unsigned long flags); public: virtual ~JsonNet(); public: virtual string getTypeName() const; diff --git a/hurricane/src/hurricane/hurricane/NetRoutingProperty.h b/hurricane/src/hurricane/hurricane/NetRoutingProperty.h index 3635ec4f..5eb64fc0 100644 --- a/hurricane/src/hurricane/hurricane/NetRoutingProperty.h +++ b/hurricane/src/hurricane/hurricane/NetRoutingProperty.h @@ -46,8 +46,9 @@ namespace Hurricane { , MixedPreRoute = Fixed|ManualGlobalRoute }; public: - inline bool isUnconnected () const; + inline bool isExcluded () const; inline bool isFixed () const; + inline bool isUnconnected () const; inline bool isManualGlobalRoute () const; inline bool isAutomaticGlobalRoute () const; inline bool isMixedPreRoute () const; @@ -69,8 +70,9 @@ namespace Hurricane { inline NetRoutingState::NetRoutingState ( Net* net, unsigned int flags ) : _net(net), _flags(flags) { } - inline bool NetRoutingState::isUnconnected () const { return _flags & Unconnected; }; + inline bool NetRoutingState::isExcluded () const { return _flags & Excluded; }; inline bool NetRoutingState::isFixed () const { return _flags & Fixed; }; + inline bool NetRoutingState::isUnconnected () const { return _flags & Unconnected; }; inline bool NetRoutingState::isManualGlobalRoute () const { return _flags & ManualGlobalRoute; }; inline bool NetRoutingState::isAutomaticGlobalRoute () const { return _flags & AutomaticGlobalRoute; }; inline bool NetRoutingState::isMixedPreRoute () const { return _flags & MixedPreRoute; }; @@ -94,6 +96,8 @@ namespace Hurricane { virtual Name getName () const; inline NetRoutingState* getState (); virtual void onReleasedBy ( DBo* owner ); + virtual bool hasJson () const; + virtual void toJson ( JsonWriter*, const DBo* ) const; virtual std::string _getTypeName () const; virtual std::string _getString () const; virtual Record* _getRecord () const; @@ -111,6 +115,19 @@ namespace Hurricane { inline NetRoutingState* NetRoutingProperty::getState () { return &_state; } +// ------------------------------------------------------------------- +// Class : "Hurricane::JsonNetRoutingProperty". + + class JsonNetRoutingProperty : public JsonObject { + public: + static void initialize (); + JsonNetRoutingProperty ( unsigned long ); + virtual std::string getTypeName () const; + virtual JsonNetRoutingProperty* clone ( unsigned long ) const; + virtual void toData ( JsonStack& ); + }; + + // ------------------------------------------------------------------- // Class : "Hurricane::NetRoutingExtension". diff --git a/hurricane/src/hurricane/hurricane/Occurrence.h b/hurricane/src/hurricane/hurricane/Occurrence.h index bcb67a2a..f2a011a4 100644 --- a/hurricane/src/hurricane/hurricane/Occurrence.h +++ b/hurricane/src/hurricane/hurricane/Occurrence.h @@ -113,6 +113,7 @@ class Occurrence { class JsonOccurrence : public JsonObject { // ********************************** + public: static void initialize(); public: JsonOccurrence(unsigned long); public: virtual string getTypeName() const; public: virtual JsonOccurrence* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/Pad.h b/hurricane/src/hurricane/hurricane/Pad.h index 2350e977..7e4b4903 100644 --- a/hurricane/src/hurricane/hurricane/Pad.h +++ b/hurricane/src/hurricane/hurricane/Pad.h @@ -85,6 +85,7 @@ class Pad : public Component { class JsonPad : public JsonComponent { // *********************************** + public: static void initialize(); public: JsonPad(unsigned long flags); public: virtual string getTypeName() const; public: virtual JsonPad* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/Plug.h b/hurricane/src/hurricane/hurricane/Plug.h index 245d0399..cd588961 100644 --- a/hurricane/src/hurricane/hurricane/Plug.h +++ b/hurricane/src/hurricane/hurricane/Plug.h @@ -118,6 +118,7 @@ class Plug : public Component { class JsonPlug : public JsonComponent { // ************************************ + public: static void initialize(); public: JsonPlug(unsigned long flags); public: virtual string getTypeName() const; public: virtual JsonPlug* clone(unsigned long) const; @@ -128,6 +129,7 @@ class JsonPlug : public JsonComponent { class JsonPlugRef : public JsonObject { // ************************************ + public: static void initialize(); public: JsonPlugRef(unsigned long flags); public: virtual string getTypeName() const; public: virtual JsonPlugRef* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/Point.h b/hurricane/src/hurricane/hurricane/Point.h index caceb531..26f7b25c 100644 --- a/hurricane/src/hurricane/hurricane/Point.h +++ b/hurricane/src/hurricane/hurricane/Point.h @@ -90,6 +90,7 @@ class Point { class JsonPoint : public JsonObject { // ********************************** + public: static void initialize(); public: JsonPoint(unsigned long); public: virtual string getTypeName() const; public: virtual JsonPoint* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/Property.h b/hurricane/src/hurricane/hurricane/Property.h index 97468d50..dfe5ad8d 100644 --- a/hurricane/src/hurricane/hurricane/Property.h +++ b/hurricane/src/hurricane/hurricane/Property.h @@ -1,4 +1,3 @@ - // -*- C++ -*- // // Copyright (c) BULL S.A. 2000-2015, All Rights Reserved @@ -19,12 +18,7 @@ // License along with Hurricane. If not, see // . // -// =================================================================== -// -// $Id$ -// -// x-----------------------------------------------------------------x -// | | +// +-----------------------------------------------------------------+ // | H U R R I C A N E | // | V L S I B a c k e n d D a t a - B a s e | // | | @@ -32,14 +26,11 @@ // | E-mail : Jean-Paul.Chaput@lip6.fr | // | =============================================================== | // | C++ Header : "./hurricane/Property.h" | -// | *************************************************************** | -// | U p d a t e s | -// | | -// x-----------------------------------------------------------------x +// +-----------------------------------------------------------------+ -#ifndef __HURRICANE_PROPERTY__ -#define __HURRICANE_PROPERTY__ +#ifndef HURRICANE_PROPERTY_H +#define HURRICANE_PROPERTY_H #include "hurricane/Name.h" #include "hurricane/Properties.h" @@ -53,6 +44,13 @@ namespace Hurricane { extern const char* propertyTypeNameError; +// ------------------------------------------------------------------- +// Classes : template enable/disable Json support. + + struct JsonEnabled { enum State { enabled=1 }; }; + struct JsonDisabled { enum State { enabled=0 }; }; + + // ------------------------------------------------------------------- // Class : "Hurricane::Property". @@ -76,6 +74,8 @@ namespace Hurricane { virtual void onCapturedBy ( DBo* owner ) = 0; virtual void onReleasedBy ( DBo* owner ) = 0; // Hurricane Managment. + virtual bool hasJson () const; + virtual void toJson ( JsonWriter*, const DBo* ) const; virtual string _getTypeName () const = 0; virtual string _getString () const; virtual Record* _getRecord () const; @@ -160,8 +160,8 @@ namespace Hurricane { // Template Class : "Hurricane::StandardPrivateProperty". - template class StandardPrivateProperty : public PrivateProperty { - + template + class StandardPrivateProperty : public PrivateProperty { public: static Name staticGetName (); static Value* staticGetValue ( const DBo* ); @@ -173,49 +173,99 @@ namespace Hurricane { virtual Name getName () const; Value& getValue () const; void setValue ( const Value& ); + virtual bool hasJson () const; + virtual void toJson ( JsonWriter*, const DBo* ) const; virtual string _getTypeName () const; virtual string _getString () const; virtual Record* _getRecord () const; - private: // Internal: Attributes. static Name _name; static DBo* _owner; static StandardPrivateProperty* _cache; mutable Value _value; - protected: // Internal: Constructor. StandardPrivateProperty (); StandardPrivateProperty ( const Value& ); + public: + class JsonProperty : public JsonObject { + public: + static void initialize (); + JsonProperty ( unsigned long flags ); + virtual string getTypeName () const; + virtual JsonProperty* clone ( unsigned long ) const; + virtual void toData ( JsonStack& ); + }; }; - template - DBo* StandardPrivateProperty::_owner = NULL; + template + StandardPrivateProperty::JsonProperty::JsonProperty ( unsigned long flags ) + : JsonObject(flags) + { + if (flags & JsonWriter::RegisterMode) + cerr << "Registering JsonProperty" << endl; + add( "_value", typeid(Value) ); + } - template - StandardPrivateProperty* StandardPrivateProperty::_cache = NULL; + template + string StandardPrivateProperty::JsonProperty::getTypeName () const + { return getString(StandardPrivateProperty::staticGetName()); } - template - Name StandardPrivateProperty::staticGetName () + template + void StandardPrivateProperty::JsonProperty::initialize () + { JsonTypes::registerType( new JsonProperty (JsonWriter::RegisterMode) ); } + + + template + typename StandardPrivateProperty::JsonProperty* + StandardPrivateProperty::JsonProperty::clone ( unsigned long flags ) const + { return new JsonProperty ( flags ); } + + + template + void StandardPrivateProperty::JsonProperty::toData ( JsonStack& stack ) + { + check( stack, "JsonProperty::toData" ); + + DBo* dbo = stack.back_dbo(); + Value value = get(stack,"_value"); + StandardPrivateProperty* property + = StandardPrivateProperty::create(value); + if (dbo) dbo->put( property ); + + update( stack, property ); + } + + + template + DBo* StandardPrivateProperty::_owner = NULL; + + + template + StandardPrivateProperty* StandardPrivateProperty::_cache = NULL; + + + template + Name StandardPrivateProperty::staticGetName () { return _name; } - template - Value* StandardPrivateProperty::staticGetValue ( const DBo* object ) + template + Value* StandardPrivateProperty::staticGetValue ( const DBo* object ) { if ( ( object == _owner ) || get(object) ) return _cache->getValue(); return NULL; } - template - StandardPrivateProperty* StandardPrivateProperty::create () + template + StandardPrivateProperty* StandardPrivateProperty::create () { _cache = new StandardPrivateProperty(); _cache->_postCreate(); @@ -223,8 +273,8 @@ namespace Hurricane { } - template - StandardPrivateProperty* StandardPrivateProperty::create ( const Value& value ) + template + StandardPrivateProperty* StandardPrivateProperty::create ( const Value& value ) { _cache = new StandardPrivateProperty(value); _cache->_postCreate(); @@ -232,8 +282,8 @@ namespace Hurricane { } - template - StandardPrivateProperty* StandardPrivateProperty::get ( const DBo* object, bool create ) + template + StandardPrivateProperty* StandardPrivateProperty::get ( const DBo* object, bool create ) { if ( object == _owner ) return _cache; @@ -253,60 +303,79 @@ namespace Hurricane { } - template - StandardPrivateProperty::StandardPrivateProperty () + template + StandardPrivateProperty::StandardPrivateProperty () : PrivateProperty(), _value() { } - template - StandardPrivateProperty::StandardPrivateProperty ( const Value& value ) + template + StandardPrivateProperty::StandardPrivateProperty ( const Value& value ) : PrivateProperty(), _value(value) { } - template - Name StandardPrivateProperty::getName() const + template + Name StandardPrivateProperty::getName() const { return staticGetName(); } - template - Value& StandardPrivateProperty::getValue () const + template + Value& StandardPrivateProperty::getValue () const { return _value; } - template - void StandardPrivateProperty::setValue ( const Value& value ) + template + void StandardPrivateProperty::setValue ( const Value& value ) { _value = value; } - template - string StandardPrivateProperty::_getTypeName () const + template + bool StandardPrivateProperty::hasJson () const + { + return JsonState::enabled; + } + + + template + void StandardPrivateProperty::toJson ( JsonWriter* w, const DBo* ) const + { + w->startObject(); + std::string tname = getString(staticGetName()); + jsonWrite( w, "@typename", tname ); + jsonWrite( w, "_value", _value ); + w->endObject(); + } + + + template + string StandardPrivateProperty::_getTypeName () const { return _TName("StandardPrivateProperty"); } - template - string StandardPrivateProperty::_getString () const + template + string StandardPrivateProperty::_getString () const { string s = PrivateProperty::_getString(); s.insert(s.length() - 1, " " + getString(_value)); return s; } - template - Record* StandardPrivateProperty::_getRecord () const + template + Record* StandardPrivateProperty::_getRecord () const { Record* record = PrivateProperty::_getRecord(); if (record) { - record->add ( getSlot("Name" , staticGetName()) ); - record->add ( getSlot("Value",&_value) ); + record->add ( getSlot("_name" , staticGetName()) ); + record->add ( getSlot("_value" ,&_value) ); + record->add ( getSlot("JSON support", JsonState::enabled) ); } return record; } @@ -317,33 +386,51 @@ namespace Hurricane { class SharedProperty : public Property { - - public: - // Types. - typedef set DBoSet; - // Methods. - inline DBos getOwners () const; - virtual void onCapturedBy ( DBo* owner ); - virtual void onReleasedBy ( DBo* owner ); - virtual void onNotOwned (); - inline DBoSet& _getOwnerSet (); - virtual string _getString () const; - virtual Record* _getRecord () const; - private: - // Internal: Attributes. - DBoSet _ownerSet; - + class Orphaned { + public: + inline Orphaned ( SharedProperty* ); + public: + SharedProperty* _property; + unsigned int _refcount; + unsigned int _count; + }; + public: + typedef set DBoSet; + typedef map OrphanedMap; + public: + static const OrphanedMap& getOrphaneds (); + static SharedProperty* getOrphaned ( const string& ); + static void addOrphaned ( const string&, SharedProperty* ); + static void refOrphaned ( const string& ); + static void countOrphaned ( const string&, unsigned int ); + static void removeOrphaned ( const string& ); + static void clearOrphaneds (); + public: + inline DBos getOwners () const; + virtual void onCapturedBy ( DBo* owner ); + virtual void onReleasedBy ( DBo* owner ); + virtual void onNotOwned (); + inline DBoSet& _getOwnerSet (); + virtual string _getString () const; + virtual Record* _getRecord () const; + private: + static OrphanedMap _orphaneds; + private: + DBoSet _ownerSet; protected: - // Internal: Constructor & Destructor. SharedProperty (); virtual void _preDestroy (); }; // Inline Functions. - DBos SharedProperty::getOwners () const { return getCollection(_ownerSet); } - SharedProperty::DBoSet& SharedProperty::_getOwnerSet () { return _ownerSet; } + inline SharedProperty::Orphaned::Orphaned ( SharedProperty* property ) + : _property(property), _refcount(0), _count(0) + { } + + inline DBos SharedProperty::getOwners () const { return getCollection(_ownerSet); } + inline SharedProperty::DBoSet& SharedProperty::_getOwnerSet () { return _ownerSet; } // ------------------------------------------------------------------- @@ -505,10 +592,10 @@ namespace Hurricane { } -} // End of Hurricane namespace. +} // Hurricane namespace. INSPECTOR_P_SUPPORT(Hurricane::Property); -#endif // __HURRICANE_PROPERTY__ +#endif // HURRICANE_PROPERTY_H diff --git a/hurricane/src/hurricane/hurricane/Relation.h b/hurricane/src/hurricane/hurricane/Relation.h index cfe4623b..0dcc3db1 100644 --- a/hurricane/src/hurricane/hurricane/Relation.h +++ b/hurricane/src/hurricane/hurricane/Relation.h @@ -62,6 +62,7 @@ class Relation : public SharedProperty { // Others // ****** + public: void _setMasterOwner(DBo* owner) {_masterOwner=owner; } protected: virtual void _postCreate(); public: virtual string _getTypeName() const {return _TName("Relation");}; diff --git a/hurricane/src/hurricane/hurricane/RoutingPad.h b/hurricane/src/hurricane/hurricane/RoutingPad.h index bf53293a..983ea8e7 100644 --- a/hurricane/src/hurricane/hurricane/RoutingPad.h +++ b/hurricane/src/hurricane/hurricane/RoutingPad.h @@ -103,6 +103,7 @@ namespace Hurricane { class JsonRoutingPad : public JsonComponent { public: + static void initialize (); JsonRoutingPad ( unsigned long flags ); virtual std::string getTypeName () const; virtual JsonRoutingPad* clone ( unsigned long flags ) const; diff --git a/hurricane/src/hurricane/hurricane/Signature.h b/hurricane/src/hurricane/hurricane/Signature.h index 1ea2d777..e4a2fbfb 100644 --- a/hurricane/src/hurricane/hurricane/Signature.h +++ b/hurricane/src/hurricane/hurricane/Signature.h @@ -132,6 +132,7 @@ namespace Hurricane { class JsonSignature : public JsonObject { public: + static void initialize (); JsonSignature ( unsigned long flags ); void setSubType ( const std::string& ); virtual std::string getTypeName () const; diff --git a/hurricane/src/hurricane/hurricane/Transformation.h b/hurricane/src/hurricane/hurricane/Transformation.h index 0043fdd9..1feab82c 100644 --- a/hurricane/src/hurricane/hurricane/Transformation.h +++ b/hurricane/src/hurricane/hurricane/Transformation.h @@ -142,6 +142,7 @@ class Transformation { class JsonTransformation : public JsonObject { // ******************************************* + public: static void initialize(); public: JsonTransformation(unsigned long); public: virtual string getTypeName() const; public: virtual JsonTransformation* clone(unsigned long) const; diff --git a/hurricane/src/hurricane/hurricane/Vertical.h b/hurricane/src/hurricane/hurricane/Vertical.h index 28f98cff..01ccafae 100644 --- a/hurricane/src/hurricane/hurricane/Vertical.h +++ b/hurricane/src/hurricane/hurricane/Vertical.h @@ -117,6 +117,7 @@ class Vertical : public Segment { class JsonVertical : public JsonSegment { // ************************************** + public: static void initialize(); public: JsonVertical(unsigned long flags); public: virtual string getTypeName() const; public: virtual JsonVertical* clone(unsigned long) const; diff --git a/hurricane/src/viewer/CellViewer.cpp b/hurricane/src/viewer/CellViewer.cpp index cdfe7f43..e271bce8 100644 --- a/hurricane/src/viewer/CellViewer.cpp +++ b/hurricane/src/viewer/CellViewer.cpp @@ -732,6 +732,7 @@ namespace Hurricane { DebugSession::close(); setCell ( topCell ); + emit cellLoadedFromDisk( topCell ); } } @@ -741,14 +742,14 @@ namespace Hurricane { Cell* cell = getCell(); if (not cell) return; - string blobName = getString(cell->getName()) + ".blob.json"; + string blobName = getString(cell->getName()) + ".blob.json.bz2"; DesignBlob blob ( cell ); - DebugSession::open( 50 ); + //DebugSession::open( 50 ); JsonWriter writer ( blobName ); writer.setFlags( JsonWriter::DesignBlobMode ); jsonWrite( &writer, &blob ); - DebugSession::close(); + //DebugSession::close(); } diff --git a/hurricane/src/viewer/OpenBlobDialog.cpp b/hurricane/src/viewer/OpenBlobDialog.cpp index eb87dd89..a9a115a5 100644 --- a/hurricane/src/viewer/OpenBlobDialog.cpp +++ b/hurricane/src/viewer/OpenBlobDialog.cpp @@ -44,7 +44,7 @@ namespace Hurricane { setWindowTitle( tr("Open Design Blob") ); QLabel* label = new QLabel (); - label->setText( tr("Enter the Blob name (without extention \".blob.json\")") ); + label->setText( tr("Enter the Blob name (without extention \".blob.json.bz2\")") ); label->setFont( Graphics::getNormalFont(true) ); _lineEdit = new QLineEdit (); diff --git a/hurricane/src/viewer/hurricane/viewer/CellViewer.h b/hurricane/src/viewer/hurricane/viewer/CellViewer.h index 0bb9ce08..33626aec 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellViewer.h +++ b/hurricane/src/viewer/hurricane/viewer/CellViewer.h @@ -150,6 +150,7 @@ namespace Hurricane { inline void emitCellPreModificated (); inline void emitCellPostModificated (); signals: + void cellLoadedFromDisk ( Cell* ); void showSelectionToggled ( bool ); void stateChanged ( shared_ptr& ); void redrawCellWidget (); diff --git a/unicorn/src/UnicornGui.cpp b/unicorn/src/UnicornGui.cpp index 08c5e9bd..a92c55ee 100644 --- a/unicorn/src/UnicornGui.cpp +++ b/unicorn/src/UnicornGui.cpp @@ -182,6 +182,7 @@ namespace Unicorn { , QKeySequence(tr("CTRL+M")) ); connect( action, SIGNAL(triggered()), _libraryManager, SLOT(toggleShow()) ); + connect( this , SIGNAL(cellLoadedFromDisk(Cell*)), _libraryManager, SLOT(updateLibrary(Cell*)) ); } @@ -238,6 +239,7 @@ namespace Unicorn { viewer->show (); } viewer->setCell ( cell ); + emit cellLoadedFromDisk ( cell ); } else cerr << "[ERROR] Cell not found: " << cellName.toStdString() << endl; } @@ -260,6 +262,7 @@ namespace Unicorn { viewer->show(); } viewer->setCell( cell ); + emit cellLoadedFromDisk ( cell ); } } } @@ -291,10 +294,10 @@ namespace Unicorn { } break; case ExportCellDialog::Json: - { DebugSession::open( 50 ); - JsonWriter writer ( cellName.toStdString()+".json" ); + { //DebugSession::open( 50 ); + JsonWriter writer ( cellName.toStdString()+".json.bz2" ); jsonWrite( &writer, cell ); - DebugSession::close(); + //DebugSession::close(); } break; }