Implementation of DataBase native save/restore in JSON (step 3).

* Test: post-receive hook on server should send mail [1].
* New: In VLSISAPD, in Parameter, callback have now a tag, which the
    pointer to the caller. This allow for the callback removal when
    the caller is destroyed.
* New: In VLSISAPD, in WidgetDescription, when associated to a parameter,
    the destructor must remove the associated callback function on
    the Parameter.
* New: In Hurricane, added JSON support for Configuration, separated
    from vlsisapd, as the support is not available at this point.
    JSON support for Configuration, Parameter & LayoutDescription.
* Change: In Hurricane, in JsonStack, the stack of JsonObjects has been
    displaced here from HurricaneHandler. This way, all
    JsonObject::toData() can access the JsonOjects in the context
    of the parser.
* New: In Hurricane, in DBo::toJson() added support for Entity by
    reference (ids).
* New: In Hurricane, added JSON support for all Layer sub-class types.
* New: In Hurricane, in Technology, export the Layers, but must be
   sorted by increasing mask value.
* New: In Hurricane, in Entity, added support for Entity by reference (ids).
* New: In Hurricane, in DataBase, added technology full support.
* New: In Hurricane, In JsonNet, move the ring rebuild management from
    JsonStack to JsonNet.
* New: In Hurricane, added JSON support for NetAlias, NetExternalcomponents
    (not cleanly implemented as a Relation).
* New: In Hurricane, new method Cell::fromJson() to load a cell from
    a JSON file.
* New: In Hurricane, In Graphics, make it an observable, for when JSON
    fully reload the graphic state, it must be able to notify other
    objects (namely the Controller).
* New: In Hurricane, in ControllerWidget, observe the Graphics to regenerate
    the palette as needed. New method ControllerTab::graphicsUpdated().
* New: In Hurricane, in RawDrawingStyle added a destructor to release the
    Qt pen/brush. Added JSON support for HSVr, DrawingStyle, DrawingGroup,
    & DisplayStyle.
* New: In Hurricane, in GraphicsWidget, rewrite correctly the readGraphics()
    to erase the previous widgets and re-create the new ones.
* New: In Hurricane, in PaletteWidget, correct re-creation of the layout/widgets
    in case of Graphics change.
* New: In CRL Core, in System, register the parameters callbacks with
    the address of the object, for later deletion.
* New: In CRL Core, in AllianceFramework, make it observable, to notify
    library changes. For the AllianceFramework creation, now allow to
    completly bypass the Python initialization system, when we expect
    to restore it from a full blob. Added methods to sets the default
    RoutingGauge & CellGauge.
* New: In CRL Core, added JSON suppport for CellGauge, RoutingLayerGauge
    & RoutingGauge.
* New: In CRL Core, in LibraryManager, oberver AllianceFramework, to update
    the list of libraries in case of change (for JSON full reload).
This commit is contained in:
Jean-Paul Chaput 2016-02-20 21:24:44 +01:00
parent f508bb0d20
commit 0efe75af00
111 changed files with 5791 additions and 1842 deletions

View File

@ -24,6 +24,7 @@
namespace CRL { namespace CRL {
using namespace std;
using Hurricane::Graphics; using Hurricane::Graphics;
@ -37,6 +38,10 @@ namespace CRL {
{ } { }
void LibrariesModel::update ()
{ emit layoutChanged(); }
QVariant LibrariesModel::data ( const QModelIndex& index, int role ) const QVariant LibrariesModel::data ( const QModelIndex& index, int role ) const
{ {
static QFont nameFont = Graphics::getFixedFont( QFont::Bold ); static QFont nameFont = Graphics::getFixedFont( QFont::Bold );

View File

@ -75,6 +75,10 @@ namespace CRL {
} }
void LibrariesWidget::update ()
{ _baseModel->update(); }
void LibrariesWidget::initSelection () void LibrariesWidget::initSelection ()
{ _view->selectRow( 0 ); } { _view->selectRow( 0 ); }

View File

@ -23,6 +23,7 @@
#include "hurricane/Error.h" #include "hurricane/Error.h"
#include "hurricane/viewer/Graphics.h" #include "hurricane/viewer/Graphics.h"
#include "hurricane/viewer/CellViewer.h" #include "hurricane/viewer/CellViewer.h"
#include "crlcore/AllianceFramework.h"
#include "crlcore/LibraryManager.h" #include "crlcore/LibraryManager.h"
#include "crlcore/LibrariesWidget.h" #include "crlcore/LibrariesWidget.h"
#include "crlcore/CellsWidget.h" #include "crlcore/CellsWidget.h"
@ -39,9 +40,26 @@ namespace CRL {
using Hurricane::Graphics; using Hurricane::Graphics;
// -------------------------------------------------------------------
// Class : "FrameworkObserver".
void FrameworkObserver::notify ( unsigned int flags )
{
LibraryManager* manager = getOwner();
if (flags & (AllianceFramework::AddedLibrary
|AllianceFramework::RemovedLibrary)) {
manager->getLibrariesWidget()->update();
}
}
// -------------------------------------------------------------------
// Class : "LibraryManager".
LibraryManager::LibraryManager ( QWidget* parent ) LibraryManager::LibraryManager ( QWidget* parent )
: QWidget (parent) : QWidget (parent)
, _librariesWidget(new LibrariesWidget()) , _frameworkObserver(this)
, _librariesWidget (new LibrariesWidget())
, _cellsWidget (new CellsWidget()) , _cellsWidget (new CellsWidget())
, _viewsWidget (new ViewsWidget()) , _viewsWidget (new ViewsWidget())
, _cellViewer (NULL) , _cellViewer (NULL)
@ -100,10 +118,18 @@ namespace CRL {
_librariesWidget->initSelection(); _librariesWidget->initSelection();
AllianceFramework::get()->addObserver( &_frameworkObserver );
resize( Graphics::toHighDpi(750), Graphics::toHighDpi(550) ); resize( Graphics::toHighDpi(750), Graphics::toHighDpi(550) );
} }
LibraryManager::~LibraryManager ()
{
AllianceFramework::get()->removeObserver( &_frameworkObserver );
}
void LibraryManager::toggleShow () void LibraryManager::toggleShow ()
{ setVisible( not isVisible() ); } { setVisible( not isVisible() ); }

View File

@ -39,6 +39,7 @@ namespace CRL {
QVariant headerData ( int section, Qt::Orientation orientation, int role=Qt::DisplayRole ) const; QVariant headerData ( int section, Qt::Orientation orientation, int role=Qt::DisplayRole ) const;
const AllianceLibrary* getLibrary ( const QModelIndex& ); const AllianceLibrary* getLibrary ( const QModelIndex& );
const AllianceLibrary* getLibrary ( size_t ); const AllianceLibrary* getLibrary ( size_t );
void update ();
private: private:
const AllianceLibraries& _libraries; const AllianceLibraries& _libraries;
}; };

View File

@ -36,12 +36,12 @@ namespace CRL {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "LibrariesWidget". // Class : "LibrariesWidget".
class LibrariesWidget : public QWidget { class LibrariesWidget : public QWidget {
Q_OBJECT; Q_OBJECT;
public: public:
LibrariesWidget ( QWidget* parent=NULL ); LibrariesWidget ( QWidget* parent=NULL );
void initSelection (); void initSelection ();
void update ();
signals: signals:
void selectedLibrary ( const AllianceLibrary* ); void selectedLibrary ( const AllianceLibrary* );
public slots: public slots:

View File

@ -18,6 +18,7 @@
#define CRL_LIBRARY_MANAGER_H #define CRL_LIBRARY_MANAGER_H
#include <QWidget> #include <QWidget>
#include "hurricane/Observer.h"
class QLabel; class QLabel;
class QModelIndex; class QModelIndex;
@ -34,10 +35,29 @@ namespace CRL {
using Hurricane::Cell; using Hurricane::Cell;
using Hurricane::CellViewer; using Hurricane::CellViewer;
using Hurricane::Observer;
class AllianceLibrary; class AllianceLibrary;
class ViewsWidget; class ViewsWidget;
class CellsWidget; class CellsWidget;
class LibrariesWidget; class LibrariesWidget;
class LibraryManager;
// -------------------------------------------------------------------
// Class : "FrameworkObserver".
class FrameworkObserver : public Observer<LibraryManager> {
public:
inline FrameworkObserver ( LibraryManager* );
virtual void notify ( unsigned int flags );
private:
FrameworkObserver ( const FrameworkObserver& );
};
inline FrameworkObserver::FrameworkObserver ( LibraryManager* owner )
: Observer<LibraryManager>(owner)
{ }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -48,14 +68,17 @@ namespace CRL {
Q_OBJECT; Q_OBJECT;
public: public:
LibraryManager ( QWidget* parent=NULL ); LibraryManager ( QWidget* parent=NULL );
~LibraryManager ();
inline void setCellViewer ( CellViewer* ); inline void setCellViewer ( CellViewer* );
inline CellViewer* getCellViewer () const; inline CellViewer* getCellViewer () const;
inline LibrariesWidget* getLibrariesWidget () const;
public slots: public slots:
void toggleShow (); void toggleShow ();
void setLibrary ( const AllianceLibrary* library ); void setLibrary ( const AllianceLibrary* library );
CellViewer* openCell ( Cell*, unsigned int flags ); CellViewer* openCell ( Cell*, unsigned int flags );
void updateLibrary ( Cell* ); void updateLibrary ( Cell* );
private: private:
FrameworkObserver _frameworkObserver;
LibrariesWidget* _librariesWidget; LibrariesWidget* _librariesWidget;
CellsWidget* _cellsWidget; CellsWidget* _cellsWidget;
ViewsWidget* _viewsWidget; ViewsWidget* _viewsWidget;
@ -66,6 +89,7 @@ namespace CRL {
inline void LibraryManager::setCellViewer ( CellViewer* cw ) { _cellViewer=cw; } inline void LibraryManager::setCellViewer ( CellViewer* cw ) { _cellViewer=cw; }
inline CellViewer* LibraryManager::getCellViewer () const { return _cellViewer; } inline CellViewer* LibraryManager::getCellViewer () const { return _cellViewer; }
inline LibrariesWidget* LibraryManager::getLibrariesWidget () const { return _librariesWidget; }
} // CRL namespace. } // CRL namespace.

View File

@ -183,12 +183,16 @@ namespace CRL {
AllianceFramework::AllianceFramework () AllianceFramework::AllianceFramework ()
: _environment() : _observers ()
, _parsers() , _environment ()
, _drivers() , _parsers ()
, _catalog() , _drivers ()
, _parentLibrary(NULL) , _catalog ()
, _routingGauges() , _parentLibrary (NULL)
, _routingGauges ()
, _defaultRoutingGauge(NULL)
, _cellGauges ()
, _defaultCellGauge (NULL)
{ {
DataBase* db = DataBase::getDB (); DataBase* db = DataBase::getDB ();
if ( not db ) if ( not db )
@ -255,7 +259,8 @@ namespace CRL {
for ( unsigned i=0 ; i<LIBRARIES.getSize() ; i++ ) { for ( unsigned i=0 ; i<LIBRARIES.getSize() ; i++ ) {
createLibrary ( LIBRARIES[i].getPath(), flags, LIBRARIES[i].getName() ); createLibrary ( LIBRARIES[i].getPath(), flags, LIBRARIES[i].getName() );
//cmess2 << " - \"" << LIBRARIES[i].getPath() << "\""; //cmess2 << " - " << LIBRARIES[i].getName()
// << " \"" << LIBRARIES[i].getPath() << "\"" << endl;
//cmess2.flush(); //cmess2.flush();
//if ( flags&HasCatalog ) cmess2 << " [have CATAL]." << endl; //if ( flags&HasCatalog ) cmess2 << " [have CATAL]." << endl;
@ -264,12 +269,13 @@ namespace CRL {
} }
AllianceFramework* AllianceFramework::create () AllianceFramework* AllianceFramework::create ( unsigned long flags )
{ {
if ( !_singleton ) { if (not _singleton) {
// Triggers System singleton creation. // Triggers System singleton creation.
System::get (); System::get ();
_singleton = new AllianceFramework (); _singleton = new AllianceFramework ();
if (not (flags & NoPythonInit))
System::runPythonInit(); System::runPythonInit();
_singleton->_bindLibraries(); _singleton->_bindLibraries();
} }
@ -280,7 +286,7 @@ namespace CRL {
AllianceFramework* AllianceFramework::get () AllianceFramework* AllianceFramework::get ()
{ {
return create (); return create();
} }
@ -296,6 +302,18 @@ namespace CRL {
} }
void AllianceFramework::addObserver ( BaseObserver* observer )
{ _observers.addObserver( observer ); }
void AllianceFramework::removeObserver ( BaseObserver* observer )
{ _observers.removeObserver( observer ); }
void AllianceFramework::notify ( unsigned flags )
{ _observers.notify( flags ); }
AllianceLibrary* AllianceFramework::getAllianceLibrary ( unsigned index ) AllianceLibrary* AllianceFramework::getAllianceLibrary ( unsigned index )
{ {
if ( index >= _libraries.size() ) if ( index >= _libraries.size() )
@ -444,7 +462,10 @@ namespace CRL {
ParserFormatSlot& parser = _parsers.getParserSlot ( path, Catalog::State::Physical, _environment ); ParserFormatSlot& parser = _parsers.getParserSlot ( path, Catalog::State::Physical, _environment );
if ( not parser.loadByLib() ) return alibrary; if ( not parser.loadByLib() ) {
notify ( AddedLibrary );
return alibrary;
}
// Load the whole library. // Load the whole library.
if ( ! _readLocate(dupLibName,Catalog::State::State::Logical,true) ) return alibrary; if ( ! _readLocate(dupLibName,Catalog::State::State::Logical,true) ) return alibrary;
@ -452,6 +473,7 @@ namespace CRL {
// Call the parser function. // Call the parser function.
(parser.getParsLib())( _environment.getLIBRARIES().getSelected() , alibrary->getLibrary() , _catalog ); (parser.getParsLib())( _environment.getLIBRARIES().getSelected() , alibrary->getLibrary() , _catalog );
notify ( AddedLibrary );
return alibrary; return alibrary;
} }
@ -643,6 +665,18 @@ namespace CRL {
} }
RoutingGauge* AllianceFramework::setRoutingGauge ( const Name& name )
{
RoutingGauge* gauge = getRoutingGauge( name );
if (gauge) _defaultRoutingGauge = gauge;
else
cerr << Error( "AllianceFramework::setRoutingGauge(): No gauge named \"%s\"."
, getString(name).c_str() ) << endl;
return _defaultRoutingGauge;
}
RoutingGauge* AllianceFramework::getRoutingGauge ( const Name& name ) RoutingGauge* AllianceFramework::getRoutingGauge ( const Name& name )
{ {
if ( name.isEmpty() ) return _defaultRoutingGauge; if ( name.isEmpty() ) return _defaultRoutingGauge;
@ -674,6 +708,18 @@ namespace CRL {
} }
CellGauge* AllianceFramework::setCellGauge ( const Name& name )
{
CellGauge* gauge = getCellGauge( name );
if (gauge) _defaultCellGauge = gauge;
else
cerr << Error( "AllianceFramework::setCellGauge(): No gauge named \"%s\"."
, getString(name).c_str() ) << endl;
return _defaultCellGauge;
}
CellGauge* AllianceFramework::getCellGauge ( const Name& name ) CellGauge* AllianceFramework::getCellGauge ( const Name& name )
{ {
if ( name.isEmpty() ) return _defaultCellGauge; if ( name.isEmpty() ) return _defaultCellGauge;
@ -738,7 +784,7 @@ namespace CRL {
record->add ( getSlot ( "_environment" , &_environment ) ); record->add ( getSlot ( "_environment" , &_environment ) );
record->add ( getSlot ( "_libraries" , &_libraries ) ); record->add ( getSlot ( "_libraries" , &_libraries ) );
record->add ( getSlot ( "_catalog" , &_catalog ) ); record->add ( getSlot ( "_catalog" , &_catalog ) );
record->add ( getSlot ( "_defaultRroutingGauge", _defaultRoutingGauge ) ); record->add ( getSlot ( "_defaultRoutingGauge", _defaultRoutingGauge ) );
record->add ( getSlot ( "_routingGauges" , _routingGauges ) ); record->add ( getSlot ( "_routingGauges" , _routingGauges ) );
record->add ( getSlot ( "_defaultCellGauge" , _defaultCellGauge ) ); record->add ( getSlot ( "_defaultCellGauge" , _defaultCellGauge ) );
record->add ( getSlot ( "_cellGauges" , _cellGauges ) ); record->add ( getSlot ( "_cellGauges" , _cellGauges ) );
@ -750,9 +796,12 @@ namespace CRL {
{ {
w->startObject(); w->startObject();
jsonWrite( w, "@typename" , _getTypeName() ); jsonWrite( w, "@typename" , _getTypeName() );
jsonWrite( w, "_environment", &_environment ); jsonWrite( w, "_environment" , &_environment );
jsonWrite( w, "+libraries" , getCollection(getAllianceLibraries()) ); jsonWrite( w, "_defaultRoutingGauge", _defaultRoutingGauge->getName() );
// Environement & Catalog... jsonWrite( w, "_defaultCellGauge" , _defaultCellGauge->getName() );
jsonWrite( w, "+libraries" , getAllianceLibraries() );
jsonWrite( w, "+routingGauges" , _routingGauges );
jsonWrite( w, "+cellGauges" , _cellGauges );
w->endObject(); w->endObject();
} }
@ -763,12 +812,25 @@ namespace CRL {
Initializer<JsonAllianceFramework> jsonFrameworkInit ( 20 ); Initializer<JsonAllianceFramework> jsonFrameworkInit ( 20 );
JsonAllianceFramework::JsonAllianceFramework (unsigned long flags ) JsonAllianceFramework::JsonAllianceFramework ( unsigned long flags )
: JsonObject(flags) : JsonObject (flags)
, _defaultRoutingGauge()
, _defaultCellGauge ()
{ {
// Environement & Catalog... add( "_environment" , typeid(Environment*) );
add( "_environment", typeid(Environment*) ); add( "_defaultRoutingGauge", typeid(string) );
add( "_defaultCellGauge" , typeid(string) );
add( "+libraries" , typeid(JsonArray) ); add( "+libraries" , typeid(JsonArray) );
add( "+routingGauges" , typeid(JsonArray) );
add( "+cellGauges" , typeid(JsonArray) );
}
JsonAllianceFramework::~JsonAllianceFramework ()
{
AllianceFramework* framework = AllianceFramework::get();
framework->setRoutingGauge( _defaultRoutingGauge );
framework->setCellGauge ( _defaultCellGauge );
} }
@ -791,6 +853,9 @@ namespace CRL {
// It's a singleton. Do not create it... // It's a singleton. Do not create it...
AllianceFramework* framework = AllianceFramework::get(); AllianceFramework* framework = AllianceFramework::get();
string _defaultRoutingGauge = get<string>( stack, "_defaultRoutingGauge" );
string _defaultCellGauge = get<string>( stack, "_defaultCellGauge" );
update( stack, framework ); update( stack, framework );
} }

View File

@ -26,6 +26,8 @@
namespace CRL { namespace CRL {
using namespace std; using namespace std;
using Hurricane::tab;
using Hurricane::inltrace;
using Hurricane::Initializer; using Hurricane::Initializer;
using Hurricane::JsonTypes; using Hurricane::JsonTypes;
using Hurricane::Warning; using Hurricane::Warning;
@ -78,8 +80,8 @@ namespace CRL {
Record* AllianceLibrary::_getRecord() const Record* AllianceLibrary::_getRecord() const
{ {
Record* record = new Record ( getString(this) ); Record* record = new Record ( getString(this) );
record->add ( getSlot("Path" ,&_path ) ); record->add ( getSlot("_path" ,&_path ) );
record->add ( getSlot("Library", _library) ); record->add ( getSlot("_library", _library) );
return ( record ); return ( record );
} }
@ -123,14 +125,16 @@ namespace CRL {
{ {
check( stack, "JsonAllianceLibrary::toData" ); check( stack, "JsonAllianceLibrary::toData" );
string libDbPath = get<string>( stack,"_library" ); string libDbPath = get<string>( stack, "_library" );
string libOsPath = get<string>( stack,"_path" ); string libOsPath = get<string>( stack, "_path" );
AllianceFramework* af = AllianceFramework::get(); AllianceFramework* af = AllianceFramework::get();
Library* library = DataBase::getDB()->getLibrary( libDbPath Library* library = DataBase::getDB()->getLibrary( libDbPath
, DataBase::CreateLib|DataBase::WarnCreateLib ); , DataBase::CreateLib|DataBase::WarnCreateLib );
AllianceLibrary* aLibrary = NULL; AllianceLibrary* aLibrary = NULL;
ltrace(51) << "| " << libDbPath << " : " << library << endl;
if (library) { if (library) {
aLibrary = af->getAllianceLibrary( library ); aLibrary = af->getAllianceLibrary( library );
} }
@ -148,6 +152,8 @@ namespace CRL {
if (not library) library = aLibrary->getLibrary(); if (not library) library = aLibrary->getLibrary();
} }
ltrace(51) << "| Associates to: " << aLibrary << endl;
if (aLibrary->getLibrary() != library) { if (aLibrary->getLibrary() != library) {
cerr << Warning( "JsonAllianceLibrary::toData(): Underlying Hurricane Library discrepency for \"%s\".\n" cerr << Warning( "JsonAllianceLibrary::toData(): Underlying Hurricane Library discrepency for \"%s\".\n"
" (may be caused by a change in search path order)" " (may be caused by a change in search path order)"

View File

@ -1,16 +1,9 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | C O R I O L I S | // | C O R I O L I S |
// | Alliance / Hurricane Interface | // | Alliance / Hurricane Interface |
// | | // | |
@ -18,24 +11,16 @@
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./CellGauge.cpp" | // | C++ Header : "./CellGauge.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include <sstream> #include <sstream>
#include "crlcore/CellGauge.h" #include "crlcore/CellGauge.h"
#include "crlcore/AllianceFramework.h"
namespace { namespace {
// const char *missingMandatoryAttr = // const char *missingMandatoryAttr =
// "CRoutingGauge::createFromXml () :\n\n" // "CRoutingGauge::createFromXml () :\n\n"
// " Can't found mandatory attribute \"%s\".\n"; // " Can't found mandatory attribute \"%s\".\n";
@ -57,19 +42,18 @@ namespace {
// "::createCellGaugeFromXml () :\n\n" // "::createCellGaugeFromXml () :\n\n"
// " cellgauge name tag attribute is empty.\n"; // " cellgauge name tag attribute is empty.\n";
} // Anonymous namespace.
} // End of Anonymous namespace.
namespace CRL { namespace CRL {
using namespace std;
using Hurricane::JsonTypes;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "CRL::CellGauge". // Class : "CRL::CellGauge".
CellGauge::CellGauge ( const char* name CellGauge::CellGauge ( const char* name
, const char* pinLayerName , const char* pinLayerName
, const DbU::Unit pitch , const DbU::Unit pitch
@ -151,4 +135,84 @@ namespace CRL {
} }
void CellGauge::toJson ( JsonWriter* w ) const
{
w->startObject();
jsonWrite( w, "@typename" , "CellGauge" );
jsonWrite( w, "_name" , _name );
jsonWrite( w, "_pinLayerName", _pinLayerName );
jsonWrite( w, "_pitch" , _pitch );
jsonWrite( w, "_sliceHeight" , _sliceHeight );
jsonWrite( w, "_sliceStep" , _sliceStep );
w->endObject();
}
// -------------------------------------------------------------------
// Class : "JsonCellGauge"
Initializer<JsonCellGauge> jsonCellGaugeInit ( 0 );
void JsonCellGauge::initialize ()
{ JsonTypes::registerType( new JsonCellGauge (JsonWriter::RegisterMode) ); }
JsonCellGauge::JsonCellGauge( unsigned long flags )
: JsonObject(flags)
{
add( "_name" , typeid(string) );
add( "_pinLayerName", typeid(string) );
add( "_pitch" , typeid(int64_t) );
add( "_sliceHeight" , typeid(int64_t) );
add( "_sliceStep" , typeid(int64_t) );
}
string JsonCellGauge::getTypeName () const
{ return "CellGauge"; }
JsonCellGauge* JsonCellGauge::clone ( unsigned long flags ) const
{ return new JsonCellGauge ( flags ); }
void JsonCellGauge::toData ( JsonStack& stack )
{
check( stack, "JsonCellGauge::toData" );
AllianceFramework* af = get<AllianceFramework*>( stack, "_framework" );
CellGauge* cg = NULL;
string name = get<string> ( stack, "_name" );
string pinLayerName = get<string> ( stack, "_pinLayerName" );
DbU::Unit pitch = get<int64_t>( stack, "_pitch" );
DbU::Unit sliceHeight = get<int64_t>( stack, "_sliceHeight" );
DbU::Unit sliceStep = get<int64_t>( stack, "_sliceStep" );
if (stack.issetFlags(JsonWriter::TechnoMode)) {
if (af) {
if (not name.empty()) {
cg = CellGauge::create( name.c_str()
, pinLayerName.c_str()
, pitch
, sliceHeight
, sliceStep
);
af->addCellGauge( cg );
}
} else {
cerr << Error( "JsonCellGauge::toData(): Missing \"_framework\" in stack context." ) << endl;
}
} else {
if (af) {
cg = af->getCellGauge( name );
}
}
update( stack, cg );
}
} // End of CRL namespace. } // End of CRL namespace.

View File

@ -530,7 +530,7 @@ namespace CRL {
setBLOCKAGE ( "^obs$" ); setBLOCKAGE ( "^obs$" );
setPad ( "^.*_px$" ); setPad ( "^.*_px$" );
_LIBRARIES.append ( "." ); _LIBRARIES.append ( ".", "working" );
_inConstructor = false; _inConstructor = false;
} }

View File

@ -1,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2016, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | C O R I O L I S | // | C O R I O L I S |

View File

@ -24,6 +24,7 @@
#include "crlcore/XmlParser.h" #include "crlcore/XmlParser.h"
#include "crlcore/RoutingLayerGauge.h" #include "crlcore/RoutingLayerGauge.h"
#include "crlcore/RoutingGauge.h" #include "crlcore/RoutingGauge.h"
#include "crlcore/AllianceFramework.h"
namespace { namespace {
@ -40,9 +41,11 @@ namespace {
namespace CRL { namespace CRL {
using Hurricane::JsonTypes;
using Hurricane::JsonArray;
using Hurricane::DataBase; using Hurricane::DataBase;
using Hurricane::ViaLayer; using Hurricane::ViaLayer;
using Hurricane::getCollection;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -264,4 +267,65 @@ namespace CRL {
} }
void RoutingGauge::toJson ( JsonWriter* w ) const
{
w->startObject();
jsonWrite( w, "@typename", "RoutingGauge" );
jsonWrite( w, "_name" , _name );
jsonWrite( w, "+routingLayerGauges", getCollection(getLayerGauges()) );
w->endObject();
}
// -------------------------------------------------------------------
// Class : "JsonRoutingGauge"
Initializer<JsonRoutingGauge> jsonRoutingGaugeInit ( 0 );
void JsonRoutingGauge::initialize ()
{ JsonTypes::registerType( new JsonRoutingGauge (JsonWriter::RegisterMode) ); }
JsonRoutingGauge::JsonRoutingGauge( unsigned long flags )
: JsonObject(flags)
{
add( "_name" , typeid(string) );
add( "+routingLayerGauges", typeid(JsonArray) );
}
string JsonRoutingGauge::getTypeName () const
{ return "RoutingGauge"; }
JsonRoutingGauge* JsonRoutingGauge::clone ( unsigned long flags ) const
{ return new JsonRoutingGauge ( flags ); }
void JsonRoutingGauge::toData ( JsonStack& stack )
{
check( stack, "JsonRoutingGauge::toData" );
AllianceFramework* af = get<AllianceFramework*>( stack, "_framework" );
string name = get<string> ( stack, "_name" );
RoutingGauge* rg = NULL;
if (stack.issetFlags(JsonWriter::TechnoMode)) {
if (af) {
if (not name.empty()) {
rg = RoutingGauge::create( name.c_str() );
af->addRoutingGauge( rg );
}
} else {
cerr << Error( "JsonRoutingGauge::toData(): Missing \"_framework\" in stack context." ) << endl;
}
} else {
rg = af->getRoutingGauge( name );
}
update( stack, rg );
}
} // End of CRL namespace. } // End of CRL namespace.

View File

@ -19,8 +19,10 @@
#include <sstream> #include <sstream>
#include "hurricane/BasicLayer.h" #include "hurricane/BasicLayer.h"
#include "hurricane/DataBase.h"
#include "hurricane/Technology.h"
#include "crlcore/RoutingLayerGauge.h" #include "crlcore/RoutingLayerGauge.h"
#include "crlcore/RoutingGauge.h"
namespace { namespace {
@ -86,22 +88,23 @@ namespace CRL {
using namespace std; using namespace std;
using Hurricane::JsonTypes;
using Hurricane::Tabulation; using Hurricane::Tabulation;
using Hurricane::BasicLayer; using Hurricane::BasicLayer;
using Hurricane::trace_in; using Hurricane::trace_in;
using Hurricane::trace_out; using Hurricane::trace_out;
using Hurricane::in_trace; using Hurricane::in_trace;
using Hurricane::tab; using Hurricane::tab;
using Hurricane::DataBase;
using Hurricane::Technology;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "RoutingLayerGauge" // Class : "RoutingLayerGauge"
RoutingLayerGauge::RoutingLayerGauge ( const Layer* layer RoutingLayerGauge::RoutingLayerGauge ( const Layer* layer
, unsigned int direction , Constant::Direction direction
, unsigned int type , Constant::LayerGaugeType type
, unsigned int depth , unsigned int depth
, double density , double density
, DbU::Unit offset , DbU::Unit offset
@ -122,8 +125,8 @@ namespace CRL {
RoutingLayerGauge* RoutingLayerGauge::create ( const Layer* layer RoutingLayerGauge* RoutingLayerGauge::create ( const Layer* layer
, unsigned int direction , Constant::Direction direction
, unsigned int type , Constant::LayerGaugeType type
, unsigned int depth , unsigned int depth
, double density , double density
, DbU::Unit offset , DbU::Unit offset
@ -302,4 +305,103 @@ namespace CRL {
} }
} // End of Coriolis namespace. void RoutingLayerGauge::toJson ( JsonWriter* w ) const
{
w->startObject();
jsonWrite( w, "@typename", "RoutingLayerGauge" );
jsonWrite( w, "_layer" , _layer->getName() );
jsonWrite( w, "_direction" , getString(&_direction) );
jsonWrite( w, "_type" , getString(&_type ) );
jsonWrite( w, "_depth" , _depth );
jsonWrite( w, "_density" , _density );
jsonWrite( w, "_offset" , _offset );
jsonWrite( w, "_pitch" , _pitch );
jsonWrite( w, "_wireWidth" , _wireWidth );
jsonWrite( w, "_viaWidth" , _viaWidth );
w->endObject();
}
// -------------------------------------------------------------------
// Class : "JsonRoutingLayerGauge"
Initializer<JsonRoutingLayerGauge> jsonRoutingLayerGaugeInit ( 0 );
void JsonRoutingLayerGauge::initialize ()
{ JsonTypes::registerType( new JsonRoutingLayerGauge (JsonWriter::RegisterMode) ); }
JsonRoutingLayerGauge::JsonRoutingLayerGauge( unsigned long flags )
: JsonObject(flags)
{
add( ".RoutingGauge" , typeid(RoutingGauge*) );
add( "_layer" , typeid(string) );
add( "_direction" , typeid(string) );
add( "_type" , typeid(string) );
add( "_depth" , typeid(unsigned int) );
add( "_density" , typeid(double) );
add( "_offset" , typeid(int64_t) );
add( "_pitch" , typeid(int64_t) );
add( "_wireWidth" , typeid(int64_t) );
add( "_viaWidth" , typeid(int64_t) );
}
string JsonRoutingLayerGauge::getTypeName () const
{ return "RoutingLayerGauge"; }
JsonRoutingLayerGauge* JsonRoutingLayerGauge::clone ( unsigned long flags ) const
{ return new JsonRoutingLayerGauge ( flags ); }
void JsonRoutingLayerGauge::toData ( JsonStack& stack )
{
check( stack, "JsonRoutingLayerGauge::toData" );
Technology* techno = DataBase::getDB()->getTechnology();
RoutingGauge* rg = get<RoutingGauge*>( stack, ".RoutingGauge" );
RoutingLayerGauge* rlg = NULL;
string layer = get<string> ( stack, "_layer" );
unsigned int depth = get<int64_t> ( stack, "_depth" );
double density = get<double> ( stack, "_density" );
DbU::Unit offset = get<int64_t> ( stack, "_offset" );
DbU::Unit pitch = get<int64_t> ( stack, "_pitch" );
DbU::Unit wireWidth = get<int64_t> ( stack, "_wireWidth" );
DbU::Unit viaWidth = get<int64_t> ( stack, "_viaWidth" );
Constant::Direction direction;
Constant::LayerGaugeType type;
from( direction, get<string>(stack,"_direction") );
from( type , get<string>(stack,"_type" ) );
if (stack.issetFlags(JsonWriter::TechnoMode)) {
if (rg) {
if (not layer.empty()) {
rlg = RoutingLayerGauge::create( techno->getLayer(layer)
, direction
, type
, depth
, density
, offset
, pitch
, wireWidth
, viaWidth
);
rg->addLayerGauge( rlg );
}
} else {
cerr << Error( "JsonRoutingLayerGauge::toData(): Missing \".RoutingGauge\" in stack context." ) << endl;
}
} else {
if (rg) {
rlg = rg->getLayerGauge( techno->getLayer(layer) );
}
}
update( stack, rlg );
}
} // Coriolis namespace.

View File

@ -322,25 +322,25 @@ namespace CRL {
// Triggers Configuration singleton creation. // Triggers Configuration singleton creation.
Cfg::Configuration::get (); Cfg::Configuration::get ();
Cfg::getParamBool ("misc.catchCore" ,true )->registerCb ( catchCoreChanged ); Cfg::getParamBool ("misc.catchCore" ,false)->registerCb ( this, catchCoreChanged );
Cfg::getParamBool ("misc.verboseLevel1" ,true )->registerCb ( verboseLevel1Changed ); Cfg::getParamBool ("misc.verboseLevel1" ,true )->registerCb ( this, verboseLevel1Changed );
Cfg::getParamBool ("misc.verboseLevel2" ,true )->registerCb ( verboseLevel2Changed ); Cfg::getParamBool ("misc.verboseLevel2" ,true )->registerCb ( this, verboseLevel2Changed );
Cfg::getParamBool ("misc.info" ,false)->registerCb ( infoChanged ); Cfg::getParamBool ("misc.info" ,false)->registerCb ( this, infoChanged );
Cfg::getParamBool ("misc.paranoid" ,false)->registerCb ( paranoidChanged ); Cfg::getParamBool ("misc.paranoid" ,false)->registerCb ( this, paranoidChanged );
Cfg::getParamBool ("misc.bug" ,false)->registerCb ( bugChanged ); Cfg::getParamBool ("misc.bug" ,false)->registerCb ( this, bugChanged );
Cfg::getParamBool ("misc.logMode" ,false)->registerCb ( logModeChanged ); Cfg::getParamBool ("misc.logMode" ,false)->registerCb ( this, logModeChanged );
Cfg::getParamInt ("misc.traceLevel" ,1000 )->registerCb ( traceLevelChanged ); Cfg::getParamInt ("misc.traceLevel" ,1000 )->registerCb ( this, traceLevelChanged );
Cfg::getParamString("stratus1.mappingName","./stratus2sxlib.xml")->registerCb ( stratus1MappingNameChanged ); Cfg::getParamString("stratus1.mappingName","./stratus2sxlib.xml")->registerCb ( this, stratus1MappingNameChanged );
// Immediate update from the configuration. // Immediate update from the configuration.
catchCoreChanged ( Cfg::getParamBool("misc.catchCore" ) ); //catchCoreChanged ( Cfg::getParamBool("misc.catchCore" ) );
verboseLevel1Changed ( Cfg::getParamBool("misc.verboseLevel1") ); //verboseLevel1Changed ( Cfg::getParamBool("misc.verboseLevel1") );
verboseLevel2Changed ( Cfg::getParamBool("misc.verboseLevel2") ); //verboseLevel2Changed ( Cfg::getParamBool("misc.verboseLevel2") );
infoChanged ( Cfg::getParamBool("misc.info" ) ); //infoChanged ( Cfg::getParamBool("misc.info" ) );
paranoidChanged ( Cfg::getParamBool("misc.paranoid" ) ); //paranoidChanged ( Cfg::getParamBool("misc.paranoid" ) );
bugChanged ( Cfg::getParamBool("misc.bug" ) ); //bugChanged ( Cfg::getParamBool("misc.bug" ) );
logModeChanged ( Cfg::getParamBool("misc.logMode" ) ); //logModeChanged ( Cfg::getParamBool("misc.logMode" ) );
traceLevelChanged ( Cfg::getParamInt ("misc.traceLevel" ) ); //traceLevelChanged ( Cfg::getParamInt ("misc.traceLevel" ) );
Utilities::Path stratusMappingName; Utilities::Path stratusMappingName;
if ( arguments.count("stratus_mapping_name") ) { if ( arguments.count("stratus_mapping_name") ) {

View File

@ -28,6 +28,8 @@
namespace CRL { namespace CRL {
using Hurricane::Observable;
using Hurricane::BaseObserver;
using Hurricane::JsonObject; using Hurricane::JsonObject;
using Hurricane::JsonStack; using Hurricane::JsonStack;
using Hurricane::Cell; using Hurricane::Cell;
@ -38,6 +40,9 @@ namespace CRL {
class AllianceFramework { class AllianceFramework {
public: public:
enum FunctionsFlags { NoFlags = 0
, NoPythonInit = (1<<0)
};
enum InstancesCountFlags { Recursive = (1<<0) enum InstancesCountFlags { Recursive = (1<<0)
, IgnoreFeeds = (1<<1) , IgnoreFeeds = (1<<1)
}; };
@ -45,9 +50,13 @@ namespace CRL {
, AppendLibrary = (1<<1) , AppendLibrary = (1<<1)
, HasCatalog = (1<<2) , HasCatalog = (1<<2)
}; };
enum NotifyFlags { AddedLibrary = (1<<0)
, RemovedLibrary = (1<<1)
, ConfigChanged = (1<<2)
};
public: public:
// Constructors. // Constructors.
static AllianceFramework* create (); static AllianceFramework* create ( unsigned long flags=NoFlags );
// Destructors. // Destructors.
void destroy (); void destroy ();
// Accessors. // Accessors.
@ -88,8 +97,13 @@ namespace CRL {
CellGauge* getCellGauge ( const Name& name="" ); CellGauge* getCellGauge ( const Name& name="" );
inline const Name getDefaultCGPinLayerName () const; inline const Name getDefaultCGPinLayerName () const;
// Modifiers. // Modifiers.
RoutingGauge* setRoutingGauge ( const Name& name="" );
CellGauge* setCellGauge ( const Name& name="" );
void addRoutingGauge ( RoutingGauge* ); void addRoutingGauge ( RoutingGauge* );
void addCellGauge ( CellGauge* ); void addCellGauge ( CellGauge* );
void addObserver ( BaseObserver* );
void removeObserver ( BaseObserver* );
void notify ( unsigned int flags );
// Cell Management. // Cell Management.
Cell* cellLoader ( const string& rpath ); Cell* cellLoader ( const string& rpath );
Cell* getCell ( const string& name Cell* getCell ( const string& name
@ -110,15 +124,16 @@ namespace CRL {
protected: protected:
static const Name _parentLibraryName; static const Name _parentLibraryName;
static AllianceFramework* _singleton; static AllianceFramework* _singleton;
Observable _observers;
Environment _environment; Environment _environment;
ParsersMap _parsers; ParsersMap _parsers;
DriversMap _drivers; DriversMap _drivers;
Catalog _catalog; Catalog _catalog;
AllianceLibraries _libraries; AllianceLibraries _libraries;
Library* _parentLibrary; Library* _parentLibrary;
RoutingGauge* _defaultRoutingGauge;
map<const Name,RoutingGauge*> map<const Name,RoutingGauge*>
_routingGauges; _routingGauges;
RoutingGauge* _defaultRoutingGauge;
map<const Name,CellGauge*> map<const Name,CellGauge*>
_cellGauges; _cellGauges;
CellGauge* _defaultCellGauge; CellGauge* _defaultCellGauge;
@ -170,9 +185,13 @@ namespace CRL {
public: public:
static void initialize (); static void initialize ();
JsonAllianceFramework( unsigned long ); JsonAllianceFramework( unsigned long );
virtual ~JsonAllianceFramework();
virtual string getTypeName () const; virtual string getTypeName () const;
virtual JsonAllianceFramework* clone ( unsigned long ) const; virtual JsonAllianceFramework* clone ( unsigned long ) const;
virtual void toData ( JsonStack& ); virtual void toData ( JsonStack& );
private:
std::string _defaultRoutingGauge;
std::string _defaultCellGauge;
}; };

View File

@ -1,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2016, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | C O R I O L I S | // | C O R I O L I S |
@ -29,7 +29,9 @@ namespace CRL {
using std::string; using std::string;
using std::map; using std::map;
using Hurricane::JsonObject;
using Hurricane::JsonStack;
using Hurricane::Initializer;
using Hurricane::Record; using Hurricane::Record;
using Hurricane::DbU; using Hurricane::DbU;
using Hurricane::Name; using Hurricane::Name;
@ -38,7 +40,6 @@ namespace CRL {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "CRL::CellGauge". // Class : "CRL::CellGauge".
class CellGauge { class CellGauge {
public: public:
@ -57,6 +58,7 @@ namespace CRL {
inline const DbU::Unit getSliceStep () const; inline const DbU::Unit getSliceStep () const;
CellGauge* getClone () const; CellGauge* getClone () const;
// Hurricane management. // Hurricane management.
void toJson ( JsonWriter* ) const;
virtual string _getTypeName () const; virtual string _getTypeName () const;
virtual string _getString () const; virtual string _getString () const;
virtual Record* _getRecord () const; virtual Record* _getRecord () const;
@ -96,6 +98,19 @@ namespace CRL {
inline const DbU::Unit CellGauge::getSliceStep () const { return _sliceStep; } inline const DbU::Unit CellGauge::getSliceStep () const { return _sliceStep; }
// -------------------------------------------------------------------
// Class : "JsonCellGauge".
class JsonCellGauge : public JsonObject {
public:
static void initialize ();
JsonCellGauge ( unsigned long flags );
virtual string getTypeName () const;
virtual JsonCellGauge* clone ( unsigned long flags ) const;
virtual void toData ( JsonStack& );
};
} // namespace CRL. } // namespace CRL.

View File

@ -36,6 +36,9 @@ namespace CRL {
using std::string; using std::string;
using std::vector; using std::vector;
using Hurricane::JsonObject;
using Hurricane::JsonStack;
using Hurricane::Initializer;
using Hurricane::Name; using Hurricane::Name;
using Hurricane::Record; using Hurricane::Record;
using Hurricane::Layer; using Hurricane::Layer;
@ -78,6 +81,7 @@ namespace CRL {
void addLayerGauge ( RoutingLayerGauge* layerGauge ); void addLayerGauge ( RoutingLayerGauge* layerGauge );
void checkConnexity () const; void checkConnexity () const;
// Hurricane Managment. // Hurricane Managment.
void toJson ( JsonWriter* ) const;
virtual Record* _getRecord ( Record* record=NULL ) const; virtual Record* _getRecord ( Record* record=NULL ) const;
virtual string _getString () const; virtual string _getString () const;
virtual string _getTypeName () const; virtual string _getTypeName () const;
@ -109,6 +113,19 @@ namespace CRL {
inline DbU::Unit RoutingGauge::getViaWidth ( size_t depth ) const { return getLayerGauge(depth)->getViaWidth(); } inline DbU::Unit RoutingGauge::getViaWidth ( size_t depth ) const { return getLayerGauge(depth)->getViaWidth(); }
// -------------------------------------------------------------------
// Class : "JsonRoutingGauge".
class JsonRoutingGauge : public JsonObject {
public:
static void initialize ();
JsonRoutingGauge ( unsigned long flags );
virtual string getTypeName () const;
virtual JsonRoutingGauge* clone ( unsigned long flags ) const;
virtual void toData ( JsonStack& );
};
} // CRL namespace. } // CRL namespace.
INSPECTOR_P_SUPPORT(CRL::RoutingGauge); INSPECTOR_P_SUPPORT(CRL::RoutingGauge);

View File

@ -1,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2016, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | C O R I O L I S | // | C O R I O L I S |
@ -20,6 +20,7 @@
#include <map> #include <map>
#include "hurricane/Commons.h" #include "hurricane/Commons.h"
#include "hurricane/Error.h"
#include "hurricane/DbU.h" #include "hurricane/DbU.h"
#include "hurricane/Collection.h" #include "hurricane/Collection.h"
#include "hurricane/Slot.h" #include "hurricane/Slot.h"
@ -54,9 +55,10 @@ namespace Constant {
namespace CRL { namespace CRL {
using std::map; using std::map;
using Hurricane::JsonObject;
using Hurricane::JsonStack;
using Hurricane::Initializer;
using Hurricane::GenericCollection; using Hurricane::GenericCollection;
using Hurricane::GenericLocator; using Hurricane::GenericLocator;
using Hurricane::GenericFilter; using Hurricane::GenericFilter;
@ -77,8 +79,8 @@ namespace CRL {
public: public:
// Constructors & Destructors. // Constructors & Destructors.
static RoutingLayerGauge* create ( const Layer* layer static RoutingLayerGauge* create ( const Layer* layer
, unsigned int direction , Constant::Direction direction
, unsigned int type , Constant::LayerGaugeType type
, unsigned int depth , unsigned int depth
, double density , double density
, DbU::Unit offset , DbU::Unit offset
@ -90,8 +92,8 @@ namespace CRL {
inline const Layer* getLayer () const; inline const Layer* getLayer () const;
inline const Layer* getBlockageLayer () const; inline const Layer* getBlockageLayer () const;
inline unsigned int getDepth () const; inline unsigned int getDepth () const;
inline unsigned int getDirection () const; inline Constant::Direction getDirection () const;
inline unsigned int getType () const; inline Constant::LayerGaugeType getType () const;
inline double getDensity () const; inline double getDensity () const;
inline DbU::Unit getOffset () const; inline DbU::Unit getOffset () const;
inline DbU::Unit getPitch () const; inline DbU::Unit getPitch () const;
@ -105,6 +107,7 @@ namespace CRL {
unsigned int getTrackIndex ( DbU::Unit start, DbU::Unit stop, DbU::Unit position, unsigned mode ) const; unsigned int getTrackIndex ( DbU::Unit start, DbU::Unit stop, DbU::Unit position, unsigned mode ) const;
DbU::Unit getTrackPosition ( DbU::Unit start, unsigned depth ) const; DbU::Unit getTrackPosition ( DbU::Unit start, unsigned depth ) const;
// Hurricane Managment. // Hurricane Managment.
void toJson ( JsonWriter* ) const;
virtual string _getTypeName () const; virtual string _getTypeName () const;
virtual string _getString () const; virtual string _getString () const;
virtual Record* _getRecord () const; virtual Record* _getRecord () const;
@ -113,8 +116,8 @@ namespace CRL {
// Internal - Attributes. // Internal - Attributes.
const Layer* _layer; const Layer* _layer;
const Layer* _blockageLayer; const Layer* _blockageLayer;
unsigned int _direction; Constant::Direction _direction;
unsigned int _type; Constant::LayerGaugeType _type;
unsigned int _depth; unsigned int _depth;
double _density; double _density;
DbU::Unit _offset; DbU::Unit _offset;
@ -124,8 +127,8 @@ namespace CRL {
// Internal - Constructors & Destructors. // Internal - Constructors & Destructors.
RoutingLayerGauge ( const Layer* layer RoutingLayerGauge ( const Layer* layer
, unsigned int direction , Constant::Direction direction
, unsigned int type , Constant::LayerGaugeType type
, unsigned int depth , unsigned int depth
, double density , double density
, DbU::Unit offset , DbU::Unit offset
@ -158,8 +161,8 @@ namespace CRL {
inline const Layer* RoutingLayerGauge::getLayer () const { return ( _layer ); } inline const Layer* RoutingLayerGauge::getLayer () const { return ( _layer ); }
inline const Layer* RoutingLayerGauge::getBlockageLayer () const { return ( _blockageLayer ); } inline const Layer* RoutingLayerGauge::getBlockageLayer () const { return ( _blockageLayer ); }
inline unsigned int RoutingLayerGauge::getDirection () const { return ( _direction ); } inline Constant::Direction RoutingLayerGauge::getDirection () const { return ( _direction ); }
inline unsigned int RoutingLayerGauge::getType () const { return ( _type ); } inline Constant::LayerGaugeType RoutingLayerGauge::getType () const { return ( _type ); }
inline unsigned int RoutingLayerGauge::getDepth () const { return ( _depth ); } inline unsigned int RoutingLayerGauge::getDepth () const { return ( _depth ); }
inline double RoutingLayerGauge::getDensity () const { return ( _density ); } inline double RoutingLayerGauge::getDensity () const { return ( _density ); }
inline DbU::Unit RoutingLayerGauge::getOffset () const { return ( _offset ); } inline DbU::Unit RoutingLayerGauge::getOffset () const { return ( _offset ); }
@ -171,8 +174,20 @@ namespace CRL {
inline DbU::Unit RoutingLayerGauge::getHalfViaWidth () const { return ( _viaWidth>>1 ); } inline DbU::Unit RoutingLayerGauge::getHalfViaWidth () const { return ( _viaWidth>>1 ); }
// -------------------------------------------------------------------
// Class : "JsonRoutingLayerGauge".
} // End of CRL namespace. class JsonRoutingLayerGauge : public JsonObject {
public:
static void initialize ();
JsonRoutingLayerGauge ( unsigned long flags );
virtual string getTypeName () const;
virtual JsonRoutingLayerGauge* clone ( unsigned long flags ) const;
virtual void toData ( JsonStack& );
};
} // CRL namespace.
INSPECTOR_P_SUPPORT(CRL::RoutingLayerGauge); INSPECTOR_P_SUPPORT(CRL::RoutingLayerGauge);
@ -182,6 +197,18 @@ INSPECTOR_P_SUPPORT(CRL::RoutingLayerGauge);
// Inspector Support for : "const ::Constant::Direction*". // Inspector Support for : "const ::Constant::Direction*".
inline void from ( Constant::Direction& direction, const std::string& s )
{
if (s == "Vertical") direction = Constant::Vertical;
else {
if (s != "Horizontal")
std::cerr << Hurricane::Error( "::from(Direction&,string&): Unknown value \"%s\"."
, s.c_str() ) << std::endl;
direction = Constant::Horizontal;
}
}
template<> template<>
inline std::string getString<const Constant::Direction*> inline std::string getString<const Constant::Direction*>
( const Constant::Direction* direction ) ( const Constant::Direction* direction )
@ -190,7 +217,7 @@ inline std::string getString<const Constant::Direction*>
case Constant::Horizontal: return "Horizontal"; case Constant::Horizontal: return "Horizontal";
case Constant::Vertical: return "Vertical"; case Constant::Vertical: return "Vertical";
} }
return ( "Unknown Constant::Direction" ); return "Unknown Constant::Direction";
} }
@ -202,7 +229,7 @@ inline std::string getString<Constant::Direction>
case Constant::Horizontal: return "Horizontal"; case Constant::Horizontal: return "Horizontal";
case Constant::Vertical: return "Vertical"; case Constant::Vertical: return "Vertical";
} }
return ( "Unknown Constant::Direction" ); return "Unknown Constant::Direction";
} }
@ -213,19 +240,43 @@ IOSTREAM_POINTER_SUPPORT(Constant::Direction);
// Inspector Support for : "const Constant::LayerGaugeType*". // Inspector Support for : "const Constant::LayerGaugeType*".
inline void from ( Constant::LayerGaugeType& type, const std::string& s )
{
if (s == "PinOnly") type = Constant::PinOnly;
else {
if (s != "Default")
std::cerr << Hurricane::Error( "::from(LayerGaugeType&,string&): Unknown value \"%s\"."
, s.c_str() ) << std::endl;
type = Constant::Default;
}
}
template<> template<>
inline std::string getString<const Constant::LayerGaugeType*> inline std::string getString<const Constant::LayerGaugeType*>
( const Constant::LayerGaugeType* layerGaugeType ) ( const Constant::LayerGaugeType* layerGaugeType )
{ {
switch ( *layerGaugeType ) { switch ( *layerGaugeType ) {
case Constant::Horizontal: return "Horizontal"; case Constant::Default: return "Default";
case Constant::Vertical: return "Vertical"; case Constant::PinOnly: return "PinOnly";
} }
return ( "Unknown Constant::LayerGaugeType" ); return "Unknown Constant::LayerGaugeType";
}
template<>
inline std::string getString<const Constant::LayerGaugeType>
( const Constant::LayerGaugeType layerGaugeType )
{
switch ( layerGaugeType ) {
case Constant::Default: return "Default";
case Constant::PinOnly: return "PinOnly";
}
return "Unknown Constant::LayerGaugeType";
} }
IOSTREAM_POINTER_SUPPORT(Constant::LayerGaugeType); IOSTREAM_POINTER_SUPPORT(Constant::LayerGaugeType);
# endif // __CRL_ROUTING_LAYER_GAUGE_H__ #endif // CRL_ROUTING_LAYER_GAUGE_H

View File

@ -132,7 +132,7 @@ int main ( int argc, char *argv[] )
if (verbose1) mstream::enable ( mstream::Verbose0|mstream::Verbose1 ); if (verbose1) mstream::enable ( mstream::Verbose0|mstream::Verbose1 );
if (verbose2) mstream::enable ( mstream::Verbose0|mstream::Verbose1|mstream::Verbose2 ); if (verbose2) mstream::enable ( mstream::Verbose0|mstream::Verbose1|mstream::Verbose2 );
dbo_ptr<AllianceFramework> af ( AllianceFramework::create() ); dbo_ptr<AllianceFramework> af ( AllianceFramework::get() );
Technology* technology = DataBase::getDB()->getTechnology(); Technology* technology = DataBase::getDB()->getTechnology();
// technology->setWorkingLayer ( "cut0" ); // technology->setWorkingLayer ( "cut0" );

View File

@ -64,7 +64,33 @@ extern "C" {
#if defined(__PYTHON_MODULE__) #if defined(__PYTHON_MODULE__)
static PyObject* PyAllianceFramework_get ( PyObject* ) static PyObject* PyAllianceFramework_create ( PyObject*, PyObject* args )
{
trace << "PyAllianceFramework_create()" << endl;
AllianceFramework* af = NULL;
PyAllianceFramework* pyAf = NULL;
unsigned long flags = AllianceFramework::NoFlags;
HTRY
PyObject* arg0;
if (ParseOneArg("AllianceFramework.create()", args, INT_ARG, &arg0)) {
flags = PyInt_AsUnsignedLongMask(arg0);
}
af = AllianceFramework::create( flags );
pyAf = PyObject_NEW( PyAllianceFramework, &PyTypeAllianceFramework );
if (pyAf == NULL) return NULL;
pyAf->_object = af;
HCATCH
return (PyObject*)pyAf;
}
static PyObject* PyAllianceFramework_get ( PyObject* args )
{ {
trace << "PyAllianceFramework_get()" << endl; trace << "PyAllianceFramework_get()" << endl;
@ -72,10 +98,10 @@ extern "C" {
PyAllianceFramework* pyAf = NULL; PyAllianceFramework* pyAf = NULL;
HTRY HTRY
af = AllianceFramework::get (); af = AllianceFramework::get();
pyAf = PyObject_NEW ( PyAllianceFramework, &PyTypeAllianceFramework ); pyAf = PyObject_NEW( PyAllianceFramework, &PyTypeAllianceFramework );
if ( pyAf == NULL ) return NULL; if (pyAf == NULL) return NULL;
pyAf->_object = af; pyAf->_object = af;
HCATCH HCATCH
@ -298,7 +324,9 @@ extern "C" {
PyMethodDef PyAllianceFramework_Methods[] = PyMethodDef PyAllianceFramework_Methods[] =
{ { "get" , (PyCFunction)PyAllianceFramework_get , METH_NOARGS|METH_STATIC { { "create" , (PyCFunction)PyAllianceFramework_create , METH_VARARGS|METH_STATIC
, "Gets the Alliance Framework." }
, { "get" , (PyCFunction)PyAllianceFramework_get , METH_NOARGS|METH_STATIC
, "Gets the Alliance Framework." } , "Gets the Alliance Framework." }
, { "getEnvironment" , (PyCFunction)PyAllianceFramework_getEnvironment , METH_NOARGS , { "getEnvironment" , (PyCFunction)PyAllianceFramework_getEnvironment , METH_NOARGS
, "Gets the Alliance Environment." } , "Gets the Alliance Environment." }
@ -338,11 +366,18 @@ extern "C" {
// x=================================================================x // x=================================================================x
// Link/Creation Method. // Link/Creation Method.
PyTypeObjectDefinitions(AllianceFramework) PyTypeObjectDefinitions(AllianceFramework)
extern void PyAllianceFramework_postModuleInit ()
{
PyObject* constant;
LoadObjectConstant(PyTypeAllianceFramework.tp_dict,AllianceFramework::NoPythonInit,"NoPythonInit");
}
#endif // End of Shared Library Code Part. #endif // End of Shared Library Code Part.

View File

@ -185,6 +185,7 @@ extern "C" {
PyCatalog_postModuleInit (); PyCatalog_postModuleInit ();
PyEnvironment_postModuleInit (); PyEnvironment_postModuleInit ();
PyRoutingLayerGauge_postModuleInit (); PyRoutingLayerGauge_postModuleInit ();
PyAllianceFramework_postModuleInit ();
//PyObject* dictionnary = PyModule_GetDict ( module ); //PyObject* dictionnary = PyModule_GetDict ( module );
//DbULoadConstants ( dictionnary ); //DbULoadConstants ( dictionnary );

View File

@ -107,8 +107,8 @@ extern "C" {
} }
rlg = RoutingLayerGauge::create( PYLAYER_O(pyLayer) rlg = RoutingLayerGauge::create( PYLAYER_O(pyLayer)
, direction , (Constant::Direction)direction
, type , (Constant::LayerGaugeType)type
, depth , depth
, density , density
, offset , offset

View File

@ -44,6 +44,7 @@ extern "C" {
extern PyObject* PyAllianceFramework_Link ( CRL::AllianceFramework* ); extern PyObject* PyAllianceFramework_Link ( CRL::AllianceFramework* );
extern void PyAllianceFramework_LinkPyType (); extern void PyAllianceFramework_LinkPyType ();
extern void PyAllianceFramework_postModuleInit ();
#define IsPyAllianceFramework(v) ( (v)->ob_type == &PyTypeAllianceFramework ) #define IsPyAllianceFramework(v) ( (v)->ob_type == &PyTypeAllianceFramework )

View File

@ -49,7 +49,7 @@ int main(int argc, char *argv[]) {
if (verbose1) mstream::enable ( mstream::Verbose0|mstream::Verbose1 ); if (verbose1) mstream::enable ( mstream::Verbose0|mstream::Verbose1 );
if (verbose2) mstream::enable ( mstream::Verbose0|mstream::Verbose1|mstream::Verbose2 ); if (verbose2) mstream::enable ( mstream::Verbose0|mstream::Verbose1|mstream::Verbose2 );
AllianceFramework* af = AllianceFramework::create (); AllianceFramework* af = AllianceFramework::get ();
Cell* cell = NULL; Cell* cell = NULL;

View File

@ -6,12 +6,13 @@
//! \addtogroup JsonSupport //! \addtogroup JsonSupport
//! \{ //! \{
/*! \class JsonObject /*! \class JsonObject
* \brief Support for JSON export. * \brief Support for JSON export.
* *
*/ */
//! \}
//! \function JsonObject::JsonObject ( unsigned long flags ); //! \function JsonObject::JsonObject ( unsigned long flags );
//! \param flags Flags sets by derived classes. //! \param flags Flags sets by derived classes.
//! //!
@ -31,6 +32,9 @@
//! //!
//! For adding a requirement/attribute, see JsonObject::add(). //! For adding a requirement/attribute, see JsonObject::add().
//! \function bool JsonObject::isDummy () const;
//! \Return \true if the concrete object is of type \c JsonDummy, \false otherwise.
//! \function string JsonObject::getTypeName () const; //! \function string JsonObject::getTypeName () const;
//! \Return The typename of the concrete object, that is, the value //! \Return The typename of the concrete object, that is, the value
//! of the \c @typename key of the JSON object. //! of the \c @typename key of the JSON object.
@ -109,6 +113,16 @@
//! - If an element matching the key is found, \b but it's type do not //! - 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. //! match \c T, an exception from \c any_cast<> will be thrown.
//! \function T* JsonObject::jget ( JsonStack& stack ) const;
//! \param stack The parser stack.
//! \Return the first JsonObject that can be cast into type \c T*.
//!
//! Search the JsonObject stack, from the top, the first object that
//! can be cast into type \c T*. Base classes can be used here, as the
//! \c dynamic_cast<> operator is used to perform the casts.
//!
//! This function \b always return a pointer (never a value).
//! \function void JsonObject::copyAttrs ( const JsonObject* other, bool reset=false ); //! \function void JsonObject::copyAttrs ( const JsonObject* other, bool reset=false );
//! \param other The object from which to copy attributes. //! \param other The object from which to copy attributes.
//! \param reset Whether to keep or erase the original attributes of the object. //! \param reset Whether to keep or erase the original attributes of the object.
@ -173,7 +187,7 @@
//! is created from them and the result is then pushed back. //! is created from them and the result is then pushed back.
//! \function unsigned int JsonObject::presetId ( JsonStack& stack ); //! \function unsigned int JsonObject::presetId ( JsonStack& stack );
//! \param The parser object stack. //! \param stack The parser object stack.
//! \Return the <em>next id</em> that has been set. //! \Return the <em>next id</em> that has been set.
//! //!
//! \Remark This is a helper for JsonStack::toData(). //! \Remark This is a helper for JsonStack::toData().
@ -184,7 +198,7 @@
//! and sets it so that the next Entity created will use it. //! and sets it so that the next Entity created will use it.
//! \function void JsonObject::update ( JsonStack& stack, T hobject ); //! \function void JsonObject::update ( JsonStack& stack, T hobject );
//! \param The parser object stack. //! \param stack parser object stack.
//! \param hobject the newly created DataBase object. //! \param hobject the newly created DataBase object.
//! //!
//! \Remark This is a helper for JsonStack::toData(). //! \Remark This is a helper for JsonStack::toData().
@ -193,6 +207,117 @@
//! object and bind it to the JsonObject. //! object and bind it to the JsonObject.
//! \addtogroup JsonSupport
//! \{
/*! \class JsonStack
* \brief JSON Parser Stack
*
*
* The JSON parser stack contains three separate stacks and a lookup
* table:
* -# The \c attribute stack. Objects that have been translated from
* JSON to the Hurricane database (or POD objects).
* -# The \c dbo stack, similar to the previous one, but contains
* \b only objects whose base class is DBo.
* -# The JsonObject stack. The stack of objects currently under
* parsing.
* -# A lookup table for the Entity, between the Hurricane \c id and
* the JSON \c id.
*/
//! \} //! \}
//! \function size_t JsonStack::size () const;
//! \Return The size of the attribute stack.
//! \function void JsonStack::push_back ( const std::string& key, T hobject );
//! \param key Key associated to \c hobject
//! \param hobject The \e attribute object.
//!
//! Push back (on top) an element on the \e attribute stack.
//! \function void JsonStack::pop_back ( size_t count=1 );
//! \param count The number of element to pop.
//!
//! Remove \c count element(s) from the top of the stack.
//! \function int JsonStack::rhas ( const string& key );
//! \param key The key element's to look for.
//! \return the index of the element, from the top.
//!
//! The function name's stands for "Reverse HAS".
//! Search from the top of the \e attribute stack downward an
//! element with \c key. Return an index from the top of the stack,
//! that is, the end of the vector. The returned index is a negative
//! value, for exemple the element on top of the stack has an index
//! of \c -1. If no element with a matching key is found, returns 0.
//! \function T JsonStack::as ( const std::string& key ) const;
//! \param key The key's element to search.
//! \return The element, casted as type T.
//!
//! Search an element with key matching \c key, from the top of the
//! stack. If found, returns the element casted as type \c T.
//! As the cast operation uses \c boost::any_cast<>, the exact type
//! \c T must be used (\b not a base class of \c T), otherwise the
//! cast will fail and an exception will be thrown.
//! \function T JsonStack::as ( int index ) const;
//! \param index the position of the element to convert.
//! \return The element, casted as type T.
//!
//! Cast the element at \c index into type T.
//! As the cast operation uses \c boost::any_cast<>, the exact type
//! \c T must be used (\b not a base class of \c T), otherwise the
//! cast will fail and an exception will be thrown.
//!
//! A positive or null index means the element must be taken from the
//! bottom of the stack and a stictly negative one means from the top
//! of the stack.
//! \function void JsonStack::push_back_dbo ( DBo* dbo );
//! \param dbo The DataBase object to push back.
//!
//! Dedicated stack to push objects \e after they had been casted
//! into the DBo* base class. We need to create this separate stack
//! from the \e attribute stack due to the inability of \c boost::any_cast<>
//! to use a base class.
//! \function void JsonStack::pop_back_dbo ();
//! Remove one element from the top of the DBo* stack.
//! \function DBo* JsonStack::back_dbo () const;
//! \Return The elemet at the top of the DBo* stack.
//! \function void JsonStack::addEntity ( unsigned int jsonId, Entity* entity );
//! \param jsonId the \c id of the Entity, in the JSON file
//! \param entity the associated Entity.
//!
//! When parsing a DataBase object \b not in \e blob mode, we cannot
//! restore the ids of the Entities as they are in the file.
//! Thus when an Entity is re-created, it comes with a different id.
//! So we have to keep track of the association between this newbox
//! id (in the Hurricane database) and the one in the JSON file.
//!
//! This function adds such an association.
//! \function T JsonStack::getEntity ( unsigned int jsonId ) const;
//! \Return The entity, casted as type \c T.
//!
//! Find an Entity with the JSON id \c jsonId and cast it into
//! type \c T.
//!
//! Obviously, this Entity must have been registered with a call
//! to addEntity() before.
//! \function vector<JsonObject*>& JsonStack::jobjects ();
//! \Return the stack of JSON objects, for direct manipulation by the involded
//! parties.
//! \function void JsonStack::print ( std::ostream& o ) const;
//! Dump the contents of the \e attribute stack int the stream \c o.
//! For debugging purposes.
} }

View File

@ -58,7 +58,6 @@
"+netMap": [ "+netMap": [
], ],
} }
\endcode \endcode
* *
* \section secJsonDriver JSON Driver Support * \section secJsonDriver JSON Driver Support
@ -165,8 +164,8 @@ class JsonPoint : public JsonObject {
public: public:
static void initialize (); static void initialize ();
JsonPoint (unsigned long flags); JsonPoint (unsigned long flags);
virtual string getTypeName(); virtual string getTypeName() const;
virtual JsonPoint* clone (unsigned long flags); virtual JsonPoint* clone (unsigned long flags) const;
virtual void toData (JsonStack&); virtual void toData (JsonStack&);
}; };
\endcode \endcode
@ -235,6 +234,105 @@ void JsonPoint::toData ( JsonStack& stack )
update( stack, point ); update( stack, point );
} }
\endcode \endcode
*
*
* \subsection secJsonArray JSON Array
*
* JSON array are not translated into containers of any kind.
* They are simply ignored (from the stack point of view).
* Objects in array comes from a great variety of containers
* including Hurricane::Collection, in almost all cases, their
* very constructors are responsibles for inserting the object
* in the relevant container/collection. So there is no need
* to build a mechanism to keep track of all the objects in an
* array through a temporary container.
*
* The corollary is that an object in an array must be able to
* extract the relevant context information from the stack.
* Say, if we are in an array of components, they must belong
* to a Net, which must be present in the stack with a key ".Net".
*
*
* \subsection secJsonStack Parser Stack
*
* While performing the parsing, the parser maintain a stack
* (JsonStack) containing:
* - The stack of attributes translateds, but not consumeds
* by the parser and the objects currently openeds (that is,
* which parsing is not completed). This stack contains POD
* or Hurricane objects (value or pointer).
* It is a vector of pair \c (key,value) where the \e key
* is either the attribute name (\c _boundingBox, \c _xMin,
* \c _masterCell, ...) or the class name (\c .Net, \c .Cell, ...).
* - The stack of JSON objects currently openeds, thoses objects
* are all derived classes of JsonObject.
* - A stack of currently opened DBo*. This stack is somewhat
* redundant with the first, but is needed because
* \c boost::any_cast<> is not able to perform dynamic conversions.
* You have to know the exact for the conversion to work.
* Here, everything is DBo*, so the problem do not arises.
*
*
* \subsection secJsonCycle JsonObject Life Cycle
*
\code{.json}
{ # JsonDummy() (1).
"_typename": "Net", # JsonNet() CTOR (2).
"_id": 14622,
"_name": "saccu(0)",
"_isGlobal": false,
"_isExternal": false,
"_isAutomatic": false,
"_type": "LOGICAL",
"_direction": "---- (UNDEFINED)",
"+aliases": [], # JsonNet::toData() (3).
"+componentSet": [
{
"@typename": "RoutingPad",
"_id": 27410,
"_bodyHook": "Contact::AnchorHook.46566",
"_occurrence": {
"@typename": "Occurrence",
"_path": "14720.14976",
"_entity": 3888
},
"+propertySet": []
},
{
"@typename": "RoutingPad",
"_id": 27409,
"_bodyHook": "Contact::AnchorHook.46574",
"_occurrence": {
"@typename": "Occurrence",
"_path": "14654.18564",
"_entity": 4529
},
"+propertySet": []
}
}
} # ~JsonNet() DTOR (4).
\endcode
*
* At \c (1) , before \c _typename is encountered, we know that a new
* object is about to be created, but do not know what is type will be.
* So we push on top of the stack a \c JsonDummy.
*
* At \c (2) , the \c _typename allows us to create the right kind of
* JsonObject, which will \e replace the \c JsonDummy on top of the
* stack.
*
* At \c (3) , a first non-POD attribute of JsonNet is encountered.
* This triggers the call to \c JsonObject::toData(), which creates
* the Hurricane object Net, and put it back on the attribute stack
* with the key \c ".Net" (because it is \e not an attribute).
*
* At \c (4) , the Json parser knows that the current JsonObject is
* finished, so it removes JsonNet from the stack and destroy it.
*
* So, if you need to perform specific post-processing that can only
* take place \c after the object and all it's sub-objects has been
* fully parsed, you may do it in the destructor of the JsonObject.
* For example, this technique is used to rebuild the rings of a Net.
*/ */

View File

@ -590,6 +590,7 @@ INPUT = Generalities.dox \
Initializer.dox \ Initializer.dox \
../../src/hurricane/hurricane/Initializer.h \ ../../src/hurricane/hurricane/Initializer.h \
JsonObject.dox \ JsonObject.dox \
../../src/hurricane/hurricane/JsonObject.h \
../../src/hurricane/hurricane/JsonReader.h \ ../../src/hurricane/hurricane/JsonReader.h \
Hurricane.dox \ Hurricane.dox \
../../src/hurricane/hurricane/Commons.h \ ../../src/hurricane/hurricane/Commons.h \

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
@ -32,15 +26,13 @@
// | E-mail : Jean-Paul.Chaput@lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./BasicLayer.cpp" | // | C++ Module : "./BasicLayer.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
# include "hurricane/BasicLayer.h" #include "hurricane/Error.h"
# include "hurricane/Technology.h" #include "hurricane/DataBase.h"
# include "hurricane/Error.h" #include "hurricane/Technology.h"
#include "hurricane/BasicLayer.h"
namespace Hurricane { namespace Hurricane {
@ -272,13 +264,29 @@ namespace Hurricane {
{ {
Record* record = Layer::_getRecord(); Record* record = Layer::_getRecord();
if (record) { if (record) {
record->add(getSlot("Material", &_material)); record->add(getSlot("_material" , &_material));
record->add(getSlot("RealName", &_realName)); record->add(getSlot("_realName" , &_realName));
record->add(getSlot("_blockageLayer", _blockageLayer));
} }
return record; return record;
} }
void BasicLayer::_toJson ( JsonWriter* writer ) const
{
Super::_toJson( writer );
jsonWrite( writer, "_material" , getString(&_material) );
jsonWrite( writer, "_extractNumber", _extractNumber );
jsonWrite( writer, "_realName" , _realName );
if (_blockageLayer) {
jsonWrite( writer, "_blockageLayer", _blockageLayer->getName() );
} else {
jsonWrite( writer, "_blockageLayer", "no_blockage_layer" );
}
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::BasicLayer::Material". // Class : "Hurricane::BasicLayer::Material".
@ -300,6 +308,23 @@ namespace Hurricane {
} }
BasicLayer::Material BasicLayer::Material::fromString ( const string& s )
{
Code code = other;
if (s == "nWell" ) code = nWell;
else if (s == "pWell" ) code = pWell;
else if (s == "nImplant") code = nImplant;
else if (s == "pImplant") code = pImplant;
else if (s == "active" ) code = active;
else if (s == "poly" ) code = poly;
else if (s == "cut" ) code = cut;
else if (s == "metal" ) code = metal;
else if (s == "blockage") code = blockage;
return Material(code);
}
string BasicLayer::Material::_getString () const string BasicLayer::Material::_getString () const
{ return getString(&_code); } { return getString(&_code); }
@ -312,4 +337,120 @@ namespace Hurricane {
} }
} // End of Hurricane namespace. // -------------------------------------------------------------------
// Class : "Hurricane::JsonBasicLayer".
Initializer<JsonBasicLayer> jsonBasicLayerInit ( 0 );
void JsonBasicLayer::initialize ()
{ JsonTypes::registerType( new JsonBasicLayer (JsonWriter::RegisterMode) ); }
JsonBasicLayer::JsonBasicLayer ( unsigned long flags )
: JsonLayer(flags)
{
if (flags & JsonWriter::RegisterMode) return;
ltrace(51) << "JsonBasicLayer::JsonBasicLayer()" << endl;
add( "_material" , typeid(string) );
add( "_extractNumber", typeid(string) );
add( "_blockageLayer", typeid(string) );
add( "_realName" , typeid(string) );
}
JsonBasicLayer::~JsonBasicLayer ()
{ }
string JsonBasicLayer::getTypeName () const
{ return "BasicLayer"; }
JsonBasicLayer* JsonBasicLayer::clone ( unsigned long flags ) const
{ return new JsonBasicLayer ( flags ); }
void JsonBasicLayer::toData(JsonStack& stack)
{
ltracein(51);
check( stack, "JsonBasicLayer::toData" );
Technology* techno = lookupTechnology( stack, "JsonBasicLayer::toData" );
BasicLayer* basicLayer = NULL;
if (techno) {
string name = get<string> ( stack, "_name" );
string smask = get<string> ( stack, "_mask" );
DbU::Unit minimalSize = get<int64_t>( stack, "_minimalSize" );
DbU::Unit minimalSpacing = get<int64_t>( stack, "_minimalSpacing" );
bool isWorking = get<bool> ( stack, "_working" );
string materialName = get<string> ( stack, "_material" );
unsigned int extractNumber = get<int64_t>( stack, "_extractNumber" );
string blockageLayer = get<string> ( stack, "_blockageLayer" );
string realName = get<string> ( stack, "_realName" );
BasicLayer::Material material = BasicLayer::Material::fromString(materialName);
Layer::Mask mask = Layer::Mask::fromString(smask);
if (stack.issetFlags(JsonWriter::TechnoMode)) {
// Actual creation.
basicLayer = BasicLayer::create( techno
, name
, material
, extractNumber
, minimalSize
, minimalSpacing
);
basicLayer->setWorking( isWorking );
if (blockageLayer != "no_blockage_layer") {
JsonTechnology* jtechno = jget<JsonTechnology>( stack );
if (jtechno) {
jtechno->addBlockageRef( blockageLayer, basicLayer );
}
}
if (basicLayer->getMask() != mask) {
cerr << Error( "JsonBasicLayer::toData(): Layer mask re-creation discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(basicLayer->getMask()).c_str()
) << endl;
}
// Add here association with blockage layer...
} else {
// Check coherency with existing layer.
basicLayer = dynamic_cast<BasicLayer*>( techno->getLayer(name) );
if (basicLayer) {
if (basicLayer->getMask() != mask) {
cerr << Error( "JsonBasicLayer::toData(): Layer mask discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(basicLayer->getMask()).c_str()
) << endl;
}
} else {
cerr << Error( "JsonBasicLayer::toData(): No BasicLayer \"%s\" in the existing technology."
, name.c_str()
) << endl;
}
}
} else {
cerr << Error( "JsonBasicLayer::toData(): Cannot find technology, aborting BasicLayer creation." ) << endl;
}
update( stack, basicLayer );
ltraceout(51);
}
} // Hurricane namespace.

View File

@ -12,6 +12,7 @@
hurricane/FileReadGzStream.h hurricane/FileReadGzStream.h
hurricane/FileWriteGzStream.h hurricane/FileWriteGzStream.h
hurricane/JsonWriter.h hurricane/JsonWriter.h
hurricane/JsonObject.h
hurricane/JsonReader.h hurricane/JsonReader.h
hurricane/Signature.h hurricane/Signature.h
hurricane/Observer.h hurricane/Observer.h
@ -98,7 +99,6 @@
hurricane/Views.h hurricane/Views.h
hurricane/Warning.h hurricane/Warning.h
hurricane/TextTranslator.h hurricane/TextTranslator.h
hurricane/DesignBlob.h
) )
set ( cpps Record.cpp set ( cpps Record.cpp
Slot.cpp Slot.cpp
@ -109,6 +109,7 @@
FileReadGzStream.cpp FileReadGzStream.cpp
FileWriteGzStream.cpp FileWriteGzStream.cpp
JsonWriter.cpp JsonWriter.cpp
JsonObject.cpp
JsonReader.cpp JsonReader.cpp
Signature.cpp Signature.cpp
Exception.cpp Exception.cpp
@ -179,7 +180,6 @@
Marker.cpp Marker.cpp
Timer.cpp Timer.cpp
TextTranslator.cpp TextTranslator.cpp
DesignBlob.cpp
) )
add_library ( hurricane ${cpps} ) add_library ( hurricane ${cpps} )

View File

@ -39,6 +39,7 @@
#include "hurricane/Component.h" #include "hurricane/Component.h"
#include "hurricane/UpdateSession.h" #include "hurricane/UpdateSession.h"
#include "hurricane/Error.h" #include "hurricane/Error.h"
#include "hurricane/JsonReader.h"
namespace Hurricane { namespace Hurricane {
@ -365,6 +366,22 @@ Cell* Cell::create(Library* library, const Name& name)
return cell; return cell;
} }
Cell* Cell::fromJson(const string& filename)
// *****************************************
{
UpdateSession::open();
JsonReader reader ( JsonWriter::CellMode );
reader.parse( filename );
UpdateSession::close();
const JsonStack& stack = reader.getStack();
if (stack.rhas(".Cell")) return stack.as<Cell*>(".Cell");
return NULL;
}
Box Cell::getBoundingBox() const Box Cell::getBoundingBox() const
// ***************************** // *****************************
{ {

View File

@ -583,8 +583,13 @@ void JsonContact::toData(JsonStack& stack)
, DbU::fromDb( get<int64_t>(stack,"_height") ) , DbU::fromDb( get<int64_t>(stack,"_height") )
); );
stack.addHookLink( contact->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) ); JsonNet* jnet = jget<JsonNet>( stack );
stack.addHookLink( contact->getAnchorHook(), jsonId, get<string>(stack,"_anchorHook") ); if (jnet) {
jnet->addHookLink( contact->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) );
jnet->addHookLink( contact->getAnchorHook(), jsonId, get<string>(stack,"_anchorHook") );
} else {
cerr << Error( "JsonContact::toData(): Missing (Json)Net in stack context." ) << endl;
}
// Hook/Ring rebuild are done as a post-process. // Hook/Ring rebuild are done as a post-process.
update( stack, contact ); update( stack, contact );

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
@ -32,16 +26,14 @@
// | E-mail : Jean-Paul.Chaput@lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./ContactLayer.cpp" | // | C++ Module : "./ContactLayer.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
# include "hurricane/BasicLayer.h" #include "hurricane/DataBase.h"
# include "hurricane/ContactLayer.h" #include "hurricane/Technology.h"
# include "hurricane/Technology.h" #include "hurricane/BasicLayer.h"
# include "hurricane/Error.h" #include "hurricane/ContactLayer.h"
#include "hurricane/Error.h"
namespace { namespace {
@ -199,4 +191,150 @@ namespace Hurricane {
} }
void ContactLayer::_toJson ( JsonWriter* w ) const
{
Super::_toJson( w );
jsonWrite( w, "_metal" , _basicLayers[0]->getName() );
jsonWrite( w, "_cut" , _basicLayers[1]->getName() );
jsonWrite( w, "_active" , _basicLayers[2]->getName() );
jsonWrite( w, "_diffusion", _basicLayers[3]->getName() );
if (_basicLayers.size() == 5) jsonWrite( w, "_well", _basicLayers[4]->getName() );
else jsonWrite( w, "_well", "no_well_layer" );
jsonWrite( w, "_enclosure.metal" , _enclosures[0] );
jsonWrite( w, "_enclosure.cut" , _enclosures[1] );
jsonWrite( w, "_enclosure.active" , _enclosures[2] );
jsonWrite( w, "_enclosure.diffusion", _enclosures[3] );
jsonWrite( w, "_enclosure.well" , (_basicLayers.size() == 5) ? _enclosures[4] : 0 );
}
// -------------------------------------------------------------------
// Class : "Hurricane::JsonContactLayer".
Initializer<JsonContactLayer> jsonContactLayerInit ( 0 );
void JsonContactLayer::initialize ()
{ JsonTypes::registerType( new JsonContactLayer (JsonWriter::RegisterMode) ); }
JsonContactLayer::JsonContactLayer ( unsigned long flags )
: JsonLayer(flags)
{
if (flags & JsonWriter::RegisterMode) return;
ltrace(51) << "JsonContactLayer::JsonContactLayer()" << endl;
add( "_metal" , typeid(string) );
add( "_cut" , typeid(string) );
add( "_active" , typeid(string) );
add( "_diffusion" , typeid(string) );
add( "_well" , typeid(string) );
add( "_enclosure.metal" , typeid(int64_t) );
add( "_enclosure.cut" , typeid(int64_t) );
add( "_enclosure.active" , typeid(int64_t) );
add( "_enclosure.diffusion", typeid(int64_t) );
add( "_enclosure.well" , typeid(int64_t) );
}
JsonContactLayer::~JsonContactLayer ()
{ }
string JsonContactLayer::getTypeName () const
{ return "ContactLayer"; }
JsonContactLayer* JsonContactLayer::clone ( unsigned long flags ) const
{ return new JsonContactLayer ( flags ); }
void JsonContactLayer::toData(JsonStack& stack)
{
ltracein(51);
check( stack, "JsonContactLayer::toData" );
Technology* techno = lookupTechnology( stack, "JsonContactLayer::toData" );
ContactLayer* layer = NULL;
if (techno) {
string name = get<string> ( stack, "_name" );
string smask = get<string> ( stack, "_mask" );
//DbU::Unit minimalSize = get<int64_t>( stack, "_minimalSize" );
//DbU::Unit minimalSpacing = get<int64_t>( stack, "_minimalSpacing" );
bool isWorking = get<bool> ( stack, "_working" );
BasicLayer* metal = techno->getBasicLayer( get<string>(stack,"_metal" ) );
BasicLayer* cut = techno->getBasicLayer( get<string>(stack,"_cut" ) );
BasicLayer* active = techno->getBasicLayer( get<string>(stack,"_active" ) );
BasicLayer* diffusion = techno->getBasicLayer( get<string>(stack,"_diffusion") );
BasicLayer* well = techno->getBasicLayer( get<string>(stack,"_well" ) );
DbU::Unit metalEncl = get<int64_t>( stack, "_enclosure.metal" );
DbU::Unit cutEncl = get<int64_t>( stack, "_enclosure.cut" );
DbU::Unit activeEncl = get<int64_t>( stack, "_enclosure.active" );
DbU::Unit diffusionEncl = get<int64_t>( stack, "_enclosure.diffusion" );
DbU::Unit wellEncl = get<int64_t>( stack, "_enclosure.well" );
Layer::Mask mask = Layer::Mask::fromString( smask );
if (stack.issetFlags(JsonWriter::TechnoMode)) {
// Actual creation.
layer = ContactLayer::create( techno
, name
, metal
, cut
, active
, diffusion
, well
);
layer->setWorking ( isWorking );
layer->setEnclosure( metal , metalEncl );
layer->setEnclosure( cut , cutEncl );
layer->setEnclosure( active , activeEncl );
layer->setEnclosure( diffusion, diffusionEncl );
if (well) layer->setEnclosure( well, wellEncl );
if (layer->getMask() != mask) {
cerr << Error( "JsonContactLayer::toData(): Layer mask re-creation discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(layer->getMask()).c_str()
) << endl;
}
// Add here association with blockage layer...
} else {
// Check coherency with existing layer.
layer = dynamic_cast<ContactLayer*>( techno->getLayer(name) );
if (layer) {
if (layer->getMask() != mask) {
cerr << Error( "JsonContactLayer::toData(): Layer mask discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(layer->getMask()).c_str()
) << endl;
}
} else {
cerr << Error( "JsonContactLayer::toData(): No ContactLayer \"%s\" in the existing technology."
, name.c_str()
) << endl;
}
}
} else {
cerr << Error( "JsonContactLayer::toData(): Cannot find technology, aborting ContactLayer creation." ) << endl;
}
update( stack, layer );
ltraceout(51);
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -29,8 +29,9 @@
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
#include "hurricane/DBo.h"
#include "hurricane/Initializer.h" #include "hurricane/Initializer.h"
#include "hurricane/DBo.h"
#include "hurricane/Entity.h"
#include "hurricane/Property.h" #include "hurricane/Property.h"
#include "hurricane/Quark.h" #include "hurricane/Quark.h"
#include "hurricane/Error.h" #include "hurricane/Error.h"
@ -201,6 +202,11 @@ namespace Hurricane {
void DBo::toJson ( JsonWriter* w ) const void DBo::toJson ( JsonWriter* w ) const
{ {
w->startObject(); w->startObject();
const Entity* entity = dynamic_cast<const Entity*>( this );
if (w->issetFlags(JsonWriter::UseEntityReference) and entity) {
jsonWrite( w, "@typename", "&Entity" );
jsonWrite( w, "_id" , entity->getId() );
} else {
std::string tname = _getTypeName(); std::string tname = _getTypeName();
if (w->issetFlags(JsonWriter::UsePlugReference) and (tname == "Plug")) { if (w->issetFlags(JsonWriter::UsePlugReference) and (tname == "Plug")) {
tname.insert( 0, "&" ); tname.insert( 0, "&" );
@ -208,6 +214,7 @@ namespace Hurricane {
jsonWrite( w, "@typename", tname ); jsonWrite( w, "@typename", tname );
_toJson( w ); _toJson( w );
_toJsonCollections( w ); _toJsonCollections( w );
}
w->endObject(); w->endObject();
} }

View File

@ -258,6 +258,10 @@ void DataBase::_toJson(JsonWriter* w) const
{ {
Inherit::_toJson( w ); Inherit::_toJson( w );
jsonWrite( w, "_precision" , DbU::getPrecision() );
jsonWrite( w, "_gridsPerLambda" , DbU::getGridsPerLambda() );
jsonWrite( w, "_physicalsPerGrid", DbU::getPhysicalsPerGrid() );
jsonWrite( w, "_technology" , _technology );
jsonWrite( w, "_rootLibrary" , _rootLibrary ); jsonWrite( w, "_rootLibrary" , _rootLibrary );
w->key( "+cellsOrderedByDepth" ); w->key( "+cellsOrderedByDepth" );
@ -282,7 +286,11 @@ JsonDataBase::JsonDataBase(unsigned long flags)
// ******************************************** // ********************************************
: JsonDBo(flags) : JsonDBo(flags)
{ {
add( "_rootLibrary", typeid(Library*) ); add( "_precision" , typeid(int64_t ) );
add( "_gridsPerLambda" , typeid(double ) );
add( "_physicalsPerGrid", typeid(double ) );
add( "_technology" , typeid(Technology*) );
add( "_rootLibrary" , typeid(Library* ) );
} }
string JsonDataBase::getTypeName() const string JsonDataBase::getTypeName() const
@ -303,6 +311,9 @@ void JsonDataBase::toData(JsonStack& stack)
check( stack, "JsonDataBase::toData" ); check( stack, "JsonDataBase::toData" );
DataBase* db = DataBase::getDB(); DataBase* db = DataBase::getDB();
DbU::setPrecision ( get<int64_t>(stack,"_precision" ), DbU::NoTechnoUpdate );
DbU::setGridsPerLambda ( get<double >(stack,"_gridsPerLambda" ), DbU::NoTechnoUpdate );
DbU::setPhysicalsPerGrid( get<double >(stack,"_physicalsPerGrid"), DbU::Unity );
update( stack, db ); update( stack, db );
} }

View File

@ -144,7 +144,7 @@ namespace Hurricane {
{ return _resolution; } { return _resolution; }
void DbU::setPrecision ( unsigned int precision ) void DbU::setPrecision ( unsigned int precision, unsigned int flags )
{ {
if ( _maximalPrecision < precision) if ( _maximalPrecision < precision)
throw Error ( "DbU::Unit::setPrecision(): Precision %ud exceed maximal precision %ud." throw Error ( "DbU::Unit::setPrecision(): Precision %ud exceed maximal precision %ud."
@ -159,6 +159,7 @@ namespace Hurricane {
_resolution = 1; _resolution = 1;
while ( precision-- ) _resolution /= 10; while ( precision-- ) _resolution /= 10;
if (not (flags & NoTechnoUpdate))
DataBase::getDB()->getTechnology()->_onDbuChange ( scale ); DataBase::getDB()->getTechnology()->_onDbuChange ( scale );
setSymbolicSnapGridStep ( DbU::lambda( 1.0) ); setSymbolicSnapGridStep ( DbU::lambda( 1.0) );
@ -197,7 +198,7 @@ namespace Hurricane {
{ return ( physical * getUnitPower(p) ) / _physicalsPerGrid; } { return ( physical * getUnitPower(p) ) / _physicalsPerGrid; }
void DbU::setGridsPerLambda ( double gridsPerLambda ) void DbU::setGridsPerLambda ( double gridsPerLambda, unsigned int flags )
{ {
if ( ( rint(gridsPerLambda) != gridsPerLambda ) if ( ( rint(gridsPerLambda) != gridsPerLambda )
|| ( remainder(gridsPerLambda,2.0) != 0.0 ) ) || ( remainder(gridsPerLambda,2.0) != 0.0 ) )
@ -209,6 +210,7 @@ namespace Hurricane {
_gridsPerLambda = gridsPerLambda; _gridsPerLambda = gridsPerLambda;
if (not (flags & NoTechnoUpdate))
DataBase::getDB()->getTechnology()->_onDbuChange ( scale ); DataBase::getDB()->getTechnology()->_onDbuChange ( scale );
setSymbolicSnapGridStep ( DbU::lambda(1) ); setSymbolicSnapGridStep ( DbU::lambda(1) );

View File

@ -163,8 +163,6 @@ namespace Hurricane {
{ {
ltracein(51); ltracein(51);
_stack = &stack;
check( stack, "JsonDeepNet::toData" ); check( stack, "JsonDeepNet::toData" );
presetId( stack ); presetId( stack );

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
@ -32,15 +26,13 @@
// | E-mail : Jean-Paul.Chaput@lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./DiffusionLayer.cpp" | // | C++ Module : "./DiffusionLayer.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/DataBase.h"
#include "hurricane/Technology.h"
#include "hurricane/BasicLayer.h" #include "hurricane/BasicLayer.h"
#include "hurricane/DiffusionLayer.h" #include "hurricane/DiffusionLayer.h"
#include "hurricane/Technology.h"
#include "hurricane/Error.h" #include "hurricane/Error.h"
@ -227,4 +219,149 @@ namespace Hurricane {
} }
void DiffusionLayer::_toJson ( JsonWriter* w ) const
{
Super::_toJson( w );
jsonWrite( w, "_active" , _basicLayers[0]->getName() );
jsonWrite( w, "_diffusion", _basicLayers[1]->getName() );
if (_basicLayers.size() == 3) jsonWrite( w, "_well", _basicLayers[2]->getName() );
else jsonWrite( w, "_well", "no_well_layer" );
jsonWrite( w, "_extentionCap.active" , _extentionCaps[0] );
jsonWrite( w, "_extentionCap.diffusion", _extentionCaps[1] );
jsonWrite( w, "_extentionCap.well" , (_basicLayers.size() == 3) ? _extentionCaps[2] : 0 );
jsonWrite( w, "_extentionWidth.active" , _extentionWidths[0] );
jsonWrite( w, "_extentionWidth.diffusion", _extentionWidths[1] );
jsonWrite( w, "_extentionWidth.well" , (_basicLayers.size() == 3) ? _extentionWidths[2] : 0 );
}
// -------------------------------------------------------------------
// Class : "Hurricane::JsonDiffusionLayer".
Initializer<JsonDiffusionLayer> jsonDiffusionLayerInit ( 0 );
void JsonDiffusionLayer::initialize ()
{ JsonTypes::registerType( new JsonDiffusionLayer (JsonWriter::RegisterMode) ); }
JsonDiffusionLayer::JsonDiffusionLayer ( unsigned long flags )
: JsonLayer(flags)
{
if (flags & JsonWriter::RegisterMode) return;
ltrace(51) << "JsonDiffusionLayer::JsonDiffusionLayer()" << endl;
add( "_active" , typeid(string) );
add( "_diffusion" , typeid(string) );
add( "_well" , typeid(string) );
add( "_extentionCap.active" , typeid(int64_t) );
add( "_extentionCap.diffusion" , typeid(int64_t) );
add( "_extentionCap.well" , typeid(int64_t) );
add( "_extentionWidth.active" , typeid(int64_t) );
add( "_extentionWidth.diffusion", typeid(int64_t) );
add( "_extentionWidth.well" , typeid(int64_t) );
}
JsonDiffusionLayer::~JsonDiffusionLayer ()
{ }
string JsonDiffusionLayer::getTypeName () const
{ return "DiffusionLayer"; }
JsonDiffusionLayer* JsonDiffusionLayer::clone ( unsigned long flags ) const
{ return new JsonDiffusionLayer ( flags ); }
void JsonDiffusionLayer::toData(JsonStack& stack)
{
ltracein(51);
check( stack, "JsonDiffusionLayer::toData" );
Technology* techno = lookupTechnology( stack, "JsonDiffusionLayer::toData" );
DiffusionLayer* layer = NULL;
if (techno) {
string name = get<string> ( stack, "_name" );
string smask = get<string> ( stack, "_mask" );
//DbU::Unit minimalSize = get<int64_t>( stack, "_minimalSize" );
//DbU::Unit minimalSpacing = get<int64_t>( stack, "_minimalSpacing" );
bool isWorking = get<bool> ( stack, "_working" );
BasicLayer* active = techno->getBasicLayer( get<string>(stack,"_active" ) );
BasicLayer* diffusion = techno->getBasicLayer( get<string>(stack,"_diffusion" ) );
BasicLayer* well = techno->getBasicLayer( get<string>(stack,"_well" ) );
DbU::Unit eCapActive = get<int64_t>( stack, "_extentionCap.active" );
DbU::Unit eCapDiffusion = get<int64_t>( stack, "_extentionCap.diffusion" );
DbU::Unit eCapWell = get<int64_t>( stack, "_extentionCap.well" );
DbU::Unit eWidthActive = get<int64_t>( stack, "_extentionWidth.active" );
DbU::Unit eWidthDiffusion = get<int64_t>( stack, "_extentionWidth.diffusion" );
DbU::Unit eWidthWell = get<int64_t>( stack, "_extentionWidth.well" );
Layer::Mask mask = Layer::Mask::fromString( smask );
if (stack.issetFlags(JsonWriter::TechnoMode)) {
// Actual creation.
layer = DiffusionLayer::create( techno
, name
, active
, diffusion
, well
);
layer->setWorking ( isWorking );
layer->setExtentionCap ( active , eCapActive );
layer->setExtentionCap ( diffusion, eCapDiffusion );
layer->setExtentionWidth( active , eWidthActive );
layer->setExtentionWidth( diffusion, eWidthDiffusion );
if (well) {
layer->setExtentionCap ( well, eCapWell );
layer->setExtentionWidth( well, eWidthWell );
}
if (layer->getMask() != mask) {
cerr << Error( "JsonDiffusionLayer::toData(): Layer mask re-creation discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(layer->getMask()).c_str()
) << endl;
}
// Add here association with blockage layer...
} else {
// Check coherency with existing layer.
layer = dynamic_cast<DiffusionLayer*>( techno->getLayer(name) );
if (layer) {
if (layer->getMask() != mask) {
cerr << Error( "JsonDiffusionLayer::toData(): Layer mask discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(layer->getMask()).c_str()
) << endl;
}
} else {
cerr << Error( "JsonDiffusionLayer::toData(): No DiffusionLayer \"%s\" in the existing technology."
, name.c_str()
) << endl;
}
}
} else {
cerr << Error( "JsonDiffusionLayer::toData(): Cannot find technology, aborting DiffusionLayer creation." ) << endl;
}
update( stack, layer );
ltraceout(51);
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -195,6 +195,58 @@ namespace Hurricane {
} }
// -------------------------------------------------------------------
// Class : "JsonEntityRef".
Initializer<JsonEntityRef> jsonEntityRefInit ( 0 );
void JsonEntityRef::initialize ()
{ JsonTypes::registerType( new JsonEntityRef (JsonWriter::RegisterMode) ); }
JsonEntityRef::JsonEntityRef ( unsigned long flags )
: JsonObject(flags)
{
if (flags & JsonWriter::RegisterMode) return;
add( "_id", typeid(int64_t) );
}
string JsonEntityRef::getTypeName () const
{ return "&Entity"; }
JsonEntityRef* JsonEntityRef::clone( unsigned long flags ) const
{ return new JsonEntityRef ( flags ); }
void JsonEntityRef::toData ( JsonStack& stack )
{
ltracein(51);
check( stack, "JsonEntityRef::toData" );
unsigned int jsonId = get<int64_t>( stack, "_id" );
Entity* entity = stack.getEntity<Entity*>( jsonId );
ltrace(51) << "jsonId:" << jsonId << " entity:" << entity << endl;
if (entity) {
JsonBaseArray<Entity*>* array = jget< JsonBaseArray<Entity*> >( stack );
if (array) array->push_back( entity );
else
cerr << Error( "JsonEntityRef::toData(): Missing JsonBaseArray in stack context." ) << endl;
} else {
cerr << Error( "JsonEntityRef::toData(): No Entity id:%u in stack LUT.", jsonId ) << endl;
}
update( stack, NULL );
ltraceout(51);
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -247,9 +247,14 @@ void JsonHorizontal::toData(JsonStack& stack)
, DbU::fromDb( get<int64_t>(stack,"_dxTarget") ) , DbU::fromDb( get<int64_t>(stack,"_dxTarget") )
); );
stack.addHookLink( horizontal->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) ); JsonNet* jnet = jget<JsonNet>( stack );
stack.addHookLink( horizontal->getSourceHook(), jsonId, get<string>(stack,"_sourceHook") ); if (jnet) {
stack.addHookLink( horizontal->getTargetHook(), jsonId, get<string>(stack,"_targetHook") ); jnet->addHookLink( horizontal->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) );
jnet->addHookLink( horizontal->getSourceHook(), jsonId, get<string>(stack,"_sourceHook") );
jnet->addHookLink( horizontal->getTargetHook(), jsonId, get<string>(stack,"_targetHook") );
} else {
cerr << Error( "JsonHorizontal::toData(): Missing (Json)Net in stack context." ) << endl;
}
// Hook/Ring rebuild are done as a post-process. // Hook/Ring rebuild are done as a post-process.
update( stack, horizontal ); update( stack, horizontal );

View File

@ -0,0 +1,287 @@
// -*- C++ -*-
//
// Copyright (c) BULL S.A. 2015-2016, 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
// <http://www.gnu.org/licenses/>.
//
// +-----------------------------------------------------------------+
// | 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 |
// | |
// | Author : Jean-Paul Chaput |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./JsonObject.cpp" |
// +-----------------------------------------------------------------+
// Needed for registering. May be deleted later.
#include "hurricane/Initializer.h"
#include "hurricane/DebugSession.h"
#include "hurricane/Warning.h"
#include "hurricane/Library.h"
#include "hurricane/Cell.h"
namespace Hurricane {
using namespace std;
// -------------------------------------------------------------------
// Class : "JsonObject".
JsonObject::JsonObject ( unsigned long flags )
: _flags (flags)
, _name ()
, _stackeds ()
, _attributes ()
, _collections()
, _object ()
{ }
JsonObject::~JsonObject ()
{ }
bool JsonObject::isDummy () const
{ return false; }
void JsonObject::add ( const string& key, type_index tid )
{
if (key.empty()) {
cerr << "[ERROR] JsonObject::add(): Attempt to add attribute with an empty name, ignored."
<< endl;
return;
}
if (has(key)) {
cerr << "[ERROR] JsonObject::add(): Attempt to add attribute \"" << key << "\" twice, cancelled."
<< endl;
return;
}
switch ( key[0] ) {
case '.': _stackeds .push_back( JsonAttribute(key,tid) ); return;
case '_': _attributes .push_back( JsonAttribute(key,tid) ); return;
case '+': _collections.push_back( JsonAttribute(key,tid) ); return;
default: break;
}
cerr << "[ERROR] JsonObject::add(): Key name \"" << key
<< "\" do not follow naming convention, cancelled." << endl;
}
void JsonObject::remove ( const std::string& key )
{
if (key.empty()) {
cerr << Error( "JsonObject::remove(): Attempt to remove attribute with an empty name, ignored." ) << endl;
return;
}
switch ( key[0] ) {
case '.':
for ( auto it = _stackeds.begin() ; it != _stackeds.end() ; ++it )
if (key == (*it).key()) { _stackeds.erase(it); break; }
break;
case '_':
for ( auto it = _attributes.begin() ; it != _attributes.end() ; ++it )
if (key == (*it).key()) { _attributes.erase(it); break; }
break;
case '+':
for ( auto it = _collections.begin() ; it != _collections.end() ; ++it )
if (key == (*it).key()) { _collections.erase(it); break; }
break;
}
}
bool JsonObject::has ( const std::string& key ) const
{
if (key.empty()) return false;
switch ( key[0] ) {
case '.':
for ( size_t i=0 ; i<_stackeds.size() ; ++i )
if (key == _stackeds[i].key()) return true;
break;
case '_':
for ( size_t i=0 ; i<_attributes.size() ; ++i )
if (key == _attributes[i].key()) return true;
break;
case '+':
for ( size_t i=0 ; i<_collections.size() ; ++i )
if (key == _collections[i].key()) return true;
break;
}
return false;
}
bool JsonObject::check ( JsonStack& stack, string fname ) const
{
for ( size_t i=0 ; i<_stackeds.size() ; ++i ) {
if (not stack.rhas(_stackeds[i].key())) {
cerr << Error( "%s(): Stack is missing context element with key \"%s\""
, fname.c_str(), _stackeds[i].key().c_str() ) << endl;
return false;
}
}
for ( size_t i=0 ; i<_attributes.size() ; ++i ) {
if (not stack.rhas(_attributes[i].key())) {
cerr << Error( "%s(): Stack is missing attribute element with key \"%s\""
, fname.c_str(), _attributes[i].key().c_str() ) << endl;
return false;
}
}
return true;
}
void JsonObject::toData ( JsonStack& )
{ }
unsigned int JsonObject::presetId ( JsonStack& stack )
{
unsigned int jsonId = get<int64_t>( stack, "_id" );
if (issetFlags(JsonWriter::DesignBlobMode)) {
Entity::setNextId( jsonId );
}
return jsonId;
}
void JsonObject::print ( ostream& o ) const
{
o << tab << "JsonObject for type: " << getTypeName() << endl;
for ( size_t i=0 ; i<_stackeds.size() ; ++i )
o << tab << "key:" << left << setw(20) << _stackeds[i].key()
<< " type:" << _stackeds[i].tid().name() << endl;
for ( size_t i=0 ; i<_attributes.size() ; ++i )
o << tab << "key:" << left << setw(20) << _attributes[i].key()
<< " type:" << _attributes[i].tid().name() << endl;
for ( size_t i=0 ; i<_collections.size() ; ++i )
o << tab << "key:" << left << setw(20) << _collections[i].key()
<< " type:" << _collections[i].tid().name() << endl;
}
// -------------------------------------------------------------------
// Class : "JsonKey".
JsonKey::JsonKey ( const string& key )
: JsonObject(0)
, _key (key)
{ }
string JsonKey::getTypeName () const { return _key; }
JsonKey* JsonKey::clone ( unsigned long ) const { return new JsonKey ( *this ); }
// -------------------------------------------------------------------
// Class : "JsonDummy".
JsonDummy::JsonDummy ()
: JsonObject(0)
, _typename ("dummy")
{ }
bool JsonDummy::isDummy () const { return true; }
string JsonDummy::getTypeName () const { return _typename; }
void JsonDummy::setTypeName ( const string& name ) { _typename=name; }
JsonDummy* JsonDummy::clone ( unsigned long ) const { return new JsonDummy ( *this ); }
// -------------------------------------------------------------------
// Class : "JsonTypes".
Initializer<JsonTypes> jsonTypesInitialize ( 10 );
JsonTypes* JsonTypes::_jsonTypes = NULL;
JsonTypes::JsonTypes ()
: _jsonObjects()
{ }
JsonTypes::~JsonTypes ()
{
for ( JsonObject* object : _jsonObjects ) delete object;
}
void JsonTypes::_registerType ( JsonObject* object )
{
if (_find(object->getTypeName())) {
throw Error( "JsonTypes::_registerType(): Attempt to register <%s> twice.", object->getTypeName().c_str() );
}
_jsonObjects.insert( object );
}
JsonObject* JsonTypes::_find ( const string& tname )
{
JsonKey key( tname );
set<JsonObject*>::iterator it = _jsonObjects.find( &key );
if (it != _jsonObjects.end()) return (*it);
return NULL;
}
void JsonTypes::registerType ( JsonObject* object )
{
if (not _jsonTypes) initialize();
_jsonTypes->_registerType( object );
}
JsonObject* JsonTypes::find ( const string& tname )
{
if (not _jsonTypes) initialize();
return _jsonTypes->_find( tname );
}
void JsonTypes::initialize ()
{ if (not _jsonTypes) _jsonTypes = new JsonTypes (); }
// -------------------------------------------------------------------
// Class : "JsonStack".
void JsonStack::addEntity ( unsigned int jsonId, Entity* entity )
{ _entities.insert( std::make_pair(jsonId,entity) ); }
void JsonStack::print ( ostream& o ) const
{
o << tab << "JsonStack::print() Stack contains " << _stack.size() << " elements." << endl;
for ( size_t i=0 ; i<_stack.size() ; ++i ) {
o << "[" << right << setw(2) << i << "] key: \"" << left << setw(20) << _stack[i].first
<< "\", type: \"" << demangle(_stack[i].second.type()) << "\"." << endl;
}
}
} // Hurricane namespace.

View File

@ -29,35 +29,19 @@
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
#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/DebugSession.h"
#include "hurricane/Error.h"
#include "hurricane/Warning.h" #include "hurricane/Warning.h"
#include "hurricane/Signature.h"
#include "hurricane/JsonReader.h" #include "hurricane/JsonReader.h"
#include "hurricane/Library.h" #include "hurricane/Entity.h"
#include "hurricane/Cell.h" #include "hurricane/Property.h"
#include "hurricane/Net.h"
#include "hurricane/DeepNet.h"
#include "hurricane/Instance.h"
#include "hurricane/RoutingPad.h"
#include "hurricane/Contact.h"
#include "hurricane/Vertical.h"
#include "hurricane/Horizontal.h"
#include "hurricane/Pad.h"
#include "hurricane/UpdateSession.h"
#include "hurricane/DesignBlob.h"
namespace { namespace Hurricane {
using namespace std; using namespace std;
using namespace rapidjson; using namespace rapidjson;
using namespace Hurricane;
class JsonReader;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -83,6 +67,8 @@ namespace {
inline bool isDummy () const; inline bool isDummy () const;
inline bool doCallToData () const; inline bool doCallToData () const;
inline JsonStack& stack (); inline JsonStack& stack ();
inline vector<JsonObject*>& objects ();
inline vector<JsonObject*>& objects () const;
inline unsigned long flags (); inline unsigned long flags ();
private: private:
enum Flags { TypenameKey = (1<<0) enum Flags { TypenameKey = (1<<0)
@ -91,40 +77,10 @@ namespace {
unsigned long _state; unsigned long _state;
string _key; string _key;
string _objectName; string _objectName;
vector<JsonObject*> _objects;
JsonReader& _reader; JsonReader& _reader;
}; };
// -------------------------------------------------------------------
// Class : "JsonReader" (declaration).
class JsonReader {
public:
JsonReader ( unsigned long flags );
~JsonReader ();
inline JsonReader* setFlags ( unsigned long mask );
inline JsonReader* resetFlags ( unsigned long mask );
inline bool issetFlags ( unsigned long mask ) const;
inline unsigned long getFlags () const;
inline JsonStack& getStack ();
void parse ( std::string fileName );
void close ();
private:
JsonReader ( const JsonReader& );
JsonReader& operator= ( const JsonReader& ) const;
private:
unsigned long _flags;
size_t _bufferSize;
char* _buffer;
FILE* _file;
FileReadGzStream* _stream;
JsonStack _stack;
Reader _reader;
HurricaneHandler _handler;
};
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "HurricaneHandler" (definition). // Class : "HurricaneHandler" (definition).
@ -132,21 +88,22 @@ namespace {
: _state (0) : _state (0)
, _key () , _key ()
, _objectName() , _objectName()
, _objects ()
, _reader (reader) , _reader (reader)
{ } { }
inline JsonStack& HurricaneHandler::stack () { return _reader.getStack(); } inline JsonStack& HurricaneHandler::stack () { return _reader.getStack(); }
inline unsigned long HurricaneHandler::flags () { return _reader.getFlags(); } inline vector<JsonObject*>& HurricaneHandler::objects () { return _reader.getStack().jobjects(); }
inline vector<JsonObject*>& HurricaneHandler::objects () const { return _reader.getStack().jobjects(); }
inline unsigned long HurricaneHandler::flags () { return _reader.getStack().getFlags(); }
inline bool HurricaneHandler::isDummy () const inline bool HurricaneHandler::isDummy () const
{ return _objects.empty() or _objects.back()->isDummy(); } { return objects().empty() or objects().back()->isDummy(); }
inline bool HurricaneHandler::doCallToData () const inline bool HurricaneHandler::doCallToData () const
{ return not _objects.empty() and _objects.back() and not _objects.back()->isBound(); } { return not objects().empty() and objects().back() and not objects().back()->isBound(); }
bool HurricaneHandler::Null () bool HurricaneHandler::Null ()
@ -234,14 +191,14 @@ namespace {
// Keep the dummy object on top of the stack. // Keep the dummy object on top of the stack.
cerr << Warning( "JsonReader::parse(): Do not know how to parse type \"%s\" (ignored)." cerr << Warning( "JsonReader::parse(): Do not know how to parse type \"%s\" (ignored)."
, value ) << endl; , value ) << endl;
dynamic_cast<JsonDummy*>(_objects.back())->setTypeName( value ); dynamic_cast<JsonDummy*>(objects().back())->setTypeName( value );
} else { } else {
// Replace the dummy object on top of the stack. // Replace the dummy object on top of the stack.
delete _objects.back(); delete objects().back();
_objects[_objects.size()-1] = object->clone( flags() ); objects()[objects().size()-1] = object->clone( flags() );
_objects.back()->setName( _objectName ); objects().back()->setName( _objectName );
signature = dynamic_cast<JsonSignature*>( _objects.back() ); signature = dynamic_cast<JsonSignature*>( objects().back() );
if (signature) { if (signature) {
size_t dot = svalue.find('.'); size_t dot = svalue.find('.');
signature->setSubType( svalue.substr(dot+1) ); signature->setSubType( svalue.substr(dot+1) );
@ -266,15 +223,15 @@ namespace {
_key = key; _key = key;
if (_state & TypenameKey) return true; if (_state & TypenameKey) return true;
//ltrace(51) << "HurricaneHandler::Key() key:" << _key << " _objects.size():" << _objects.size() << endl; //ltrace(51) << "HurricaneHandler::Key() key:" << _key << " objects().size():" << objects().size() << endl;
if (_objects.back()) { if (objects().back()) {
if ( doCallToData() and not _key.empty() and (_key[0] != '_') ) { if ( doCallToData() and not _key.empty() and (_key[0] != '_') ) {
// The key is no longer a simple attribute of the object. // The key is no longer a simple attribute of the object.
// Triggers it's creation in the Json stack. // Triggers it's creation in the Json stack.
ltrace(51) << "HurricaneHandler::key() Calling " ltrace(51) << "HurricaneHandler::key() Calling "
<< _objects.back()->getTypeName() << "::toData(JsonStack&)." << endl; << objects().back()->getTypeName() << "::toData(JsonStack&)." << endl;
_objects.back()->toData( stack() ); objects().back()->toData( stack() );
} }
} }
@ -289,9 +246,9 @@ namespace {
_state |= TypenameKey; _state |= TypenameKey;
_objectName = _key; _objectName = _key;
_objects.push_back( new JsonDummy() ); objects().push_back( new JsonDummy() );
_key.clear(); _key.clear();
ltrace(51) << "_objects.push_back(NULL), size():" << _objects.size() << "." << endl; ltrace(51) << "objects().push_back(NULL), size():" << objects().size() << "." << endl;
ltracein(50); ltracein(50);
return true; return true;
@ -307,20 +264,20 @@ namespace {
_objectName.clear(); _objectName.clear();
if (not isDummy()) { if (not isDummy()) {
if (doCallToData()) { if (doCallToData()) {
ltrace(51) << "Calling " << _objects.back()->getTypeName() << "::toData(JsonStack&)." << endl; ltrace(51) << "Calling " << objects().back()->getTypeName() << "::toData(JsonStack&)." << endl;
_objects.back()->toData( stack() ); objects().back()->toData( stack() );
} }
if (stack().size() > 1) { if (stack().size() > 1) {
if (stack()[-1].first[0] != '_') stack().pop_back(); if (stack()[-1].first[0] != '_') stack().pop_back();
} }
} }
ltrace(51) << "_objects.pop_back(), size():" << _objects.size() << "." << endl; ltrace(51) << "objects().pop_back(), size():" << objects().size() << "." << endl;
if (_objects.back()->issetFlags(JsonWriter::DBoObject)) if (objects().back()->issetFlags(JsonWriter::DBoObject))
stack().pop_back_dbo(); stack().pop_back_dbo();
delete _objects.back(); delete objects().back();
_objects.pop_back(); objects().pop_back();
ltraceout(50); ltraceout(50);
return true; return true;
@ -355,15 +312,15 @@ namespace {
// Class : "JsonReader" (definition). // Class : "JsonReader" (definition).
JsonReader::JsonReader ( unsigned long flags ) JsonReader::JsonReader ( unsigned long flags )
: _flags (flags) : _bufferSize(65536)
, _bufferSize(65536)
, _buffer (new char [_bufferSize]) , _buffer (new char [_bufferSize])
, _file (NULL) , _file (NULL)
, _stream (NULL) , _stream (NULL)
, _stack () , _stack ()
, _reader () , _reader ()
, _handler (*this) , _handler (new HurricaneHandler(*this))
{ {
_stack.setFlags( flags );
} }
@ -371,6 +328,7 @@ namespace {
{ {
close(); close();
delete _buffer; delete _buffer;
delete _handler;
} }
@ -381,13 +339,6 @@ namespace {
} }
inline JsonReader* JsonReader::setFlags ( unsigned long mask ) { _flags |= mask; return this; }
inline JsonReader* JsonReader::resetFlags ( unsigned long mask ) { _flags &= ~mask; return this; }
inline bool JsonReader::issetFlags ( unsigned long mask ) const { return _flags & mask; }
inline unsigned long JsonReader::getFlags () const { return _flags; }
inline JsonStack& JsonReader::getStack () { return _stack; }
void JsonReader::parse ( string fileName ) void JsonReader::parse ( string fileName )
{ {
close(); close();
@ -407,8 +358,11 @@ namespace {
if (issetFlags(JsonWriter::DesignBlobMode)) if (issetFlags(JsonWriter::DesignBlobMode))
Entity::enableForcedIdMode(); Entity::enableForcedIdMode();
_reader.Parse( *_stream, _handler ); _reader.Parse( *_stream, *_handler );
if (_stack.size() != 1) {
cerr << Error( "JsonReader::parse(): Stack must contain exatly one element upon completion." ) << endl;
_stack.print( cerr ); _stack.print( cerr );
}
if (issetFlags(JsonWriter::DesignBlobMode)) if (issetFlags(JsonWriter::DesignBlobMode))
Entity::disableForcedIdMode(); Entity::disableForcedIdMode();
@ -419,395 +373,4 @@ namespace {
} }
} // local namespace.
namespace Hurricane {
using namespace std;
// -------------------------------------------------------------------
// Class : "JsonObject".
JsonObject::JsonObject ( unsigned long flags )
: _flags (flags)
, _name ()
, _stackeds ()
, _attributes ()
, _collections()
, _object ()
{ }
JsonObject::~JsonObject ()
{ }
bool JsonObject::isDummy () const
{ return false; }
void JsonObject::add ( const string& key, type_index tid )
{
if (key.empty()) {
cerr << "[ERROR] JsonObject::add(): Attempt to add attribute with an empty name, ignored."
<< endl;
return;
}
if (has(key)) {
cerr << "[ERROR] JsonObject::add(): Attempt to add attribute \"" << key << "\" twice, cancelled."
<< endl;
return;
}
switch ( key[0] ) {
case '.': _stackeds .push_back( JsonAttribute(key,tid) ); return;
case '_': _attributes .push_back( JsonAttribute(key,tid) ); return;
case '+': _collections.push_back( JsonAttribute(key,tid) ); return;
default: break;
}
cerr << "[ERROR] JsonObject::add(): Key name \"" << key
<< "\" do not follow naming convention, cancelled." << endl;
}
void JsonObject::remove ( const std::string& key )
{
if (key.empty()) {
cerr << Error( "JsonObject::remove(): Attempt to remove attribute with an empty name, ignored." ) << endl;
return;
}
switch ( key[0] ) {
case '.':
for ( auto it = _stackeds.begin() ; it != _stackeds.end() ; ++it )
if (key == (*it).key()) { _stackeds.erase(it); break; }
break;
case '_':
for ( auto it = _attributes.begin() ; it != _attributes.end() ; ++it )
if (key == (*it).key()) { _attributes.erase(it); break; }
break;
case '+':
for ( auto it = _collections.begin() ; it != _collections.end() ; ++it )
if (key == (*it).key()) { _collections.erase(it); break; }
break;
}
}
bool JsonObject::has ( const std::string& key ) const
{
if (key.empty()) return false;
switch ( key[0] ) {
case '.':
for ( size_t i=0 ; i<_stackeds.size() ; ++i )
if (key == _stackeds[i].key()) return true;
break;
case '_':
for ( size_t i=0 ; i<_attributes.size() ; ++i )
if (key == _attributes[i].key()) return true;
break;
case '+':
for ( size_t i=0 ; i<_collections.size() ; ++i )
if (key == _collections[i].key()) return true;
break;
}
return false;
}
bool JsonObject::check ( JsonStack& stack, string fname ) const
{
for ( size_t i=0 ; i<_stackeds.size() ; ++i ) {
if (not stack.rhas(_stackeds[i].key())) {
cerr << Error( "%s(): Stack is missing context element with key \"%s\""
, fname.c_str(), _stackeds[i].key().c_str() ) << endl;
return false;
}
}
for ( size_t i=0 ; i<_attributes.size() ; ++i ) {
if (not stack.rhas(_attributes[i].key())) {
cerr << Error( "%s(): Stack is missing attribute element with key \"%s\""
, fname.c_str(), _attributes[i].key().c_str() ) << endl;
return false;
}
}
return true;
}
void JsonObject::toData ( JsonStack& )
{ }
unsigned int JsonObject::presetId ( JsonStack& stack )
{
unsigned int jsonId = get<int64_t>( stack, "_id" );
if (issetFlags(JsonWriter::DesignBlobMode)) {
Entity::setNextId( jsonId );
}
return jsonId;
}
void JsonObject::print ( ostream& o ) const
{
o << tab << "JsonObject for type: " << getTypeName() << endl;
for ( size_t i=0 ; i<_stackeds.size() ; ++i )
o << tab << "key:" << left << setw(20) << _stackeds[i].key()
<< " type:" << _stackeds[i].tid().name() << endl;
for ( size_t i=0 ; i<_attributes.size() ; ++i )
o << tab << "key:" << left << setw(20) << _attributes[i].key()
<< " type:" << _attributes[i].tid().name() << endl;
for ( size_t i=0 ; i<_collections.size() ; ++i )
o << tab << "key:" << left << setw(20) << _collections[i].key()
<< " type:" << _collections[i].tid().name() << endl;
}
// -------------------------------------------------------------------
// Class : "JsonKey".
JsonKey::JsonKey ( const string& key )
: JsonObject(0)
, _key (key)
{ }
string JsonKey::getTypeName () const { return _key; }
JsonKey* JsonKey::clone ( unsigned long ) const { return new JsonKey ( *this ); }
// -------------------------------------------------------------------
// Class : "JsonDummy".
JsonDummy::JsonDummy ()
: JsonObject(0)
, _typename ("dummy")
{ }
bool JsonDummy::isDummy () const { return true; }
string JsonDummy::getTypeName () const { return _typename; }
void JsonDummy::setTypeName ( const string& name ) { _typename=name; }
JsonDummy* JsonDummy::clone ( unsigned long ) const { return new JsonDummy ( *this ); }
// -------------------------------------------------------------------
// Class : "JsonTypes".
Initializer<JsonTypes> jsonTypesInitialize ( 10 );
JsonTypes* JsonTypes::_jsonTypes = NULL;
JsonTypes::JsonTypes ()
: _jsonObjects()
{ }
JsonTypes::~JsonTypes ()
{
for ( JsonObject* object : _jsonObjects ) delete object;
}
void JsonTypes::_registerType ( JsonObject* object )
{
if (_find(object->getTypeName())) {
throw Error( "JsonTypes::_registerType(): Attempt to register <%s> twice.", object->getTypeName().c_str() );
}
_jsonObjects.insert( object );
}
JsonObject* JsonTypes::_find ( const string& tname )
{
JsonKey key( tname );
set<JsonObject*>::iterator it = _jsonObjects.find( &key );
if (it != _jsonObjects.end()) return (*it);
return NULL;
}
void JsonTypes::registerType ( JsonObject* object )
{
if (not _jsonTypes) initialize();
_jsonTypes->_registerType( object );
}
JsonObject* JsonTypes::find ( const string& tname )
{
if (not _jsonTypes) initialize();
return _jsonTypes->_find( tname );
}
void JsonTypes::initialize ()
{ if (not _jsonTypes) _jsonTypes = new JsonTypes (); }
// -------------------------------------------------------------------
// Class : "JsonStack".
void JsonStack::addEntity ( unsigned int jsonId, Entity* entity )
{ _entities.insert( std::make_pair(jsonId,entity) ); }
void JsonStack::addHookLink ( Hook* hook, unsigned int jsonId, const string& jsonNext )
{
if (jsonNext.empty()) return;
unsigned int id = jsonId;
string tname = hook->_getTypeName();
auto ielement = _hooks.find( HookKey(id,tname) );
if (ielement == _hooks.end()) {
auto r = _hooks.insert( make_pair( HookKey(id,tname), HookElement(hook) ) );
ielement = r.first;
(*ielement).second.setFlags( HookElement::OpenRingStart );
}
HookElement* current = &((*ielement).second);
if (not current->hook()) current->setHook( hook );
hookFromString( jsonNext, id, tname );
ielement = _hooks.find( HookKey(id,tname) );
if (ielement == _hooks.end()) {
auto r = _hooks.insert( make_pair( HookKey(id,tname), HookElement(NULL) ) );
ielement = r.first;
} else {
(*ielement).second.resetFlags( HookElement::OpenRingStart );
}
current->setNext( &((*ielement).second) );
}
Hook* JsonStack::getHook ( unsigned int jsonId, const std::string& tname ) const
{
auto ihook = _hooks.find( HookKey(jsonId,tname) );
if (ihook == _hooks.end()) return NULL;
return (*ihook).second.hook();
}
bool JsonStack::hookFromString ( std::string s, unsigned int& id, std::string& tname )
{
size_t dot = s.rfind('.');
if (dot == string::npos) return false;
tname = s.substr( 0, dot );
id = stoul( s.substr(dot+1) );
return true;
}
bool JsonStack::checkRings () const
{
bool status = true;
for ( auto kv : _hooks ) {
HookElement* ringStart = &(kv.second);
if (ringStart->issetFlags(HookElement::ClosedRing)) continue;
if (ringStart->issetFlags(HookElement::OpenRingStart)) {
cerr << Error( "JsonStack::checkRing(): Open ring found, starting with %s.\n"
" Closing the ring..."
, getString(ringStart->hook()).c_str() ) << endl;
status = false;
HookElement* element = ringStart;
while ( true ) {
if (not element->next()) {
// The ring is open: close it (loop on ringStart).
element->setNext( ringStart );
element->setFlags( HookElement::ClosedRing );
cerr << Error( "Simple open ring." ) << endl;
break;
}
if (element->next()->issetFlags(HookElement::ClosedRing)) {
// The ring is half merged with itself, or another ring.
// (i.e. *multiple* hooks pointing the *same* next element)
element->setNext( ringStart );
element->setFlags( HookElement::ClosedRing );
cerr << Error( "Complex fault: ring partially merged (convergent)." ) << endl;
break;
}
element = element->next();
}
}
}
return status;
}
void JsonStack::buildRings () const
{
for ( auto kv : _hooks ) {
kv.second.hook()->_setNextHook( kv.second.next()->hook() );
}
}
void JsonStack::print ( ostream& o ) const
{
o << tab << "JsonStack::print() Stack contains " << _stack.size() << " elements." << endl;
for ( size_t i=0 ; i<_stack.size() ; ++i ) {
o << "[" << right << setw(2) << i << "] key: \"" << left << setw(20) << _stack[i].first
<< "\", type: \"" << demangle(_stack[i].second.type()) << "\"." << endl;
}
}
// -------------------------------------------------------------------
// Function : Json Cell parser.
Cell* jsonCellParse ( string filename )
{
UpdateSession::open();
JsonReader reader ( JsonWriter::CellMode );
reader.parse( filename );
UpdateSession::close();
const JsonStack& stack = reader.getStack();
if (stack.rhas(".Cell")) return stack.as<Cell*>(".Cell");
return NULL;
}
// -------------------------------------------------------------------
// Function : Json Blob parser.
Cell* jsonBlobParse ( string filename )
{
UpdateSession::open();
JsonReader reader ( JsonWriter::DesignBlobMode );
reader.parse( filename );
UpdateSession::close();
const JsonStack& stack = reader.getStack();
if (stack.rhas(".DesignBlob")) {
DesignBlob* blob = stack.as<DesignBlob*>(".DesignBlob");
Cell* cell = blob->getTopCell();
delete blob;
return cell;
}
return NULL;
}
} // Hurricane namespace. } // Hurricane namespace.

View File

@ -94,6 +94,10 @@
void JsonWriter::write ( unsigned int v ) { _WRITER->Uint ( v); } void JsonWriter::write ( unsigned int v ) { _WRITER->Uint ( v); }
void JsonWriter::write ( const unsigned long* v ) { _WRITER->Uint64(*v); } void JsonWriter::write ( const unsigned long* v ) { _WRITER->Uint64(*v); }
void JsonWriter::write ( unsigned long v ) { _WRITER->Uint64( v); } void JsonWriter::write ( unsigned long v ) { _WRITER->Uint64( v); }
void JsonWriter::write ( const float* v ) { _WRITER->Double((double)*v); }
void JsonWriter::write ( float v ) { _WRITER->Double((double) v); }
void JsonWriter::write ( const double* v ) { _WRITER->Double(*v); }
void JsonWriter::write ( double v ) { _WRITER->Double( v); }
JsonWriter* JsonWriter::setFlags ( unsigned long mask ) { _flags |= mask; return this; } JsonWriter* JsonWriter::setFlags ( unsigned long mask ) { _flags |= mask; return this; }
JsonWriter* JsonWriter::resetFlags ( unsigned long mask ) { _flags &= ~mask; return this; } JsonWriter* JsonWriter::resetFlags ( unsigned long mask ) { _flags &= ~mask; return this; }
bool JsonWriter::issetFlags ( unsigned long mask ) const { return _flags & mask; } bool JsonWriter::issetFlags ( unsigned long mask ) const { return _flags & mask; }

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
@ -32,16 +26,14 @@
// | E-mail : Jean-Paul.Chaput@lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./Layer.cpp" | // | C++ Module : "./Layer.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
# include "hurricane/Layer.h" #include "hurricane/DataBase.h"
# include "hurricane/BasicLayer.h" #include "hurricane/Technology.h"
# include "hurricane/Technology.h" #include "hurricane/Layer.h"
# include "hurricane/Error.h" #include "hurricane/BasicLayer.h"
#include "hurricane/Error.h"
namespace Hurricane { namespace Hurricane {
@ -50,7 +42,6 @@ namespace Hurricane {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::Layer". // Class : "Hurricane::Layer".
Layer::Layer ( Technology* technology Layer::Layer ( Technology* technology
, const Name& name , const Name& name
, const DbU::Unit& minimalSize , const DbU::Unit& minimalSize
@ -245,4 +236,46 @@ namespace Hurricane {
const Name& Layer::_sgetName ( const Layer* layer ) const Name& Layer::_sgetName ( const Layer* layer )
{ return layer->getName(); } { return layer->getName(); }
} // End of Hurricane namespace.
void Layer::_toJson ( JsonWriter* writer ) const
{
Super::_toJson( writer );
jsonWrite( writer, "_name" , getName() );
jsonWrite( writer, "_mask" , getString(_mask) );
jsonWrite( writer, "_extractMask" , getString(_extractMask) );
jsonWrite( writer, "_minimalSize" , _minimalSize );
jsonWrite( writer, "_minimalSpacing", _minimalSpacing );
jsonWrite( writer, "_working" , _working );
}
// -------------------------------------------------------------------
// Class : "Hurricane::JsonLayer".
JsonLayer::JsonLayer ( unsigned long flags )
: JsonDBo(flags)
{
add( "_name" , typeid(string) );
add( "_mask" , typeid(string) );
add( "_extractMask" , typeid(string) );
add( "_minimalSize" , typeid(uint64_t) );
add( "_minimalSpacing", typeid(uint64_t) );
add( "_working" , typeid(uint64_t) );
}
Technology* JsonLayer::lookupTechnology ( JsonStack& stack, const string& fname ) const
{
Technology* techno = get<Technology*>( stack, ".Technology" );
if (not techno) {
techno = get<Technology*>( stack, "_technology" );
}
if (not techno) {
cerr << Error( "%s(): .Technology/_technology missing in the stack.", fname.c_str() ) << endl;
techno = DataBase::getDB()->getTechnology();
}
return techno;
}
} // Hurricane namespace.

View File

@ -18,6 +18,7 @@
// **************************************************************************************************** // ****************************************************************************************************
#include "hurricane/Warning.h" #include "hurricane/Warning.h"
#include "hurricane/Error.h"
#include "hurricane/Net.h" #include "hurricane/Net.h"
#include "hurricane/Cell.h" #include "hurricane/Cell.h"
#include "hurricane/Instance.h" #include "hurricane/Instance.h"
@ -30,7 +31,7 @@
#include "hurricane/Horizontal.h" #include "hurricane/Horizontal.h"
#include "hurricane/Pad.h" #include "hurricane/Pad.h"
#include "hurricane/UpdateSession.h" #include "hurricane/UpdateSession.h"
#include "hurricane/Error.h" #include "hurricane/NetExternalComponents.h"
namespace Hurricane { namespace Hurricane {
@ -765,6 +766,9 @@ void Net::_toJsonCollections(JsonWriter* writer) const
jsonWrite( writer, "+componentSet", getComponents() ); jsonWrite( writer, "+componentSet", getComponents() );
writer->resetFlags( JsonWriter::UsePlugReference ); writer->resetFlags( JsonWriter::UsePlugReference );
writer->key( "+externalComponents" );
NetExternalComponents::toJson( writer, this );
Inherit::_toJsonCollections( writer ); Inherit::_toJsonCollections( writer );
} }
@ -1059,24 +1063,23 @@ string Net_SlavePlugs::Locator::_getString() const
} }
// -------------------------------------------------------------------
// Class : "JsonNet".
// ****************************************************************************************************
// JsonNet implementation
// ****************************************************************************************************
Initializer<JsonNet> jsonNetInit ( 0 ); Initializer<JsonNet> jsonNetInit ( 0 );
void JsonNet::initialize()
// **************************
{ JsonTypes::registerType( new JsonNet (JsonWriter::RegisterMode) ); }
JsonNet::JsonNet(unsigned long flags) void JsonNet::initialize ()
// ********************************** { JsonTypes::registerType( new JsonNet (JsonWriter::RegisterMode) ); }
JsonNet::JsonNet ( unsigned long flags )
: JsonEntity (flags) : JsonEntity (flags)
, _autoMaterialize(not Go::autoMaterializationIsDisabled()) , _autoMaterialize(not Go::autoMaterializationIsDisabled())
, _net (NULL) , _net (NULL)
, _stack (NULL) , _hooks ()
{ {
if (flags & JsonWriter::RegisterMode) return; if (flags & JsonWriter::RegisterMode) return;
ltrace(51) << "JsonNet::JsonNet()" << endl; ltrace(51) << "JsonNet::JsonNet()" << endl;
@ -1088,18 +1091,19 @@ JsonNet::JsonNet(unsigned long flags)
add( "_type" , typeid(string) ); add( "_type" , typeid(string) );
add( "_direction" , typeid(string) ); add( "_direction" , typeid(string) );
add( "+aliases" , typeid(JsonArray) ); add( "+aliases" , typeid(JsonArray) );
add( "+componentSet", typeid(JsonArray) ); add( "+componentSet" , typeid(JsonArray) );
add( "+externalComponents", typeid(JsonArray) );
ltrace(51) << "Disabling auto-materialization (" << _autoMaterialize << ")." << endl; ltrace(51) << "Disabling auto-materialization (" << _autoMaterialize << ")." << endl;
Go::disableAutoMaterialization(); Go::disableAutoMaterialization();
} }
JsonNet::~JsonNet()
// **************** JsonNet::~JsonNet ()
{ {
_stack->checkRings(); checkRings();
_stack->buildRings(); buildRings();
_stack->clearHookLinks(); clearHookLinks();
_net->materialize(); _net->materialize();
@ -1107,23 +1111,21 @@ JsonNet::~JsonNet()
Go::enableAutoMaterialization(); Go::enableAutoMaterialization();
ltrace(51) << "Enabling auto-materialization." << endl; ltrace(51) << "Enabling auto-materialization." << endl;
} }
} }
string JsonNet::getTypeName() const
// *********************************
{ return "Net"; }
JsonNet* JsonNet::clone(unsigned long flags) const string JsonNet::getTypeName () const
// *********************************************** { return "Net"; }
{ return new JsonNet ( flags ); }
void JsonNet::toData(JsonStack& stack)
// *********************************** JsonNet* JsonNet::clone( unsigned long flags ) const
{ { return new JsonNet ( flags ); }
void JsonNet::toData ( JsonStack& stack )
{
ltracein(51); ltracein(51);
_stack = &stack;
check( stack, "JsonNet::toData" ); check( stack, "JsonNet::toData" );
presetId( stack ); presetId( stack );
@ -1137,9 +1139,108 @@ void JsonNet::toData(JsonStack& stack)
update( stack, _net ); update( stack, _net );
ltraceout(51); ltraceout(51);
} }
} // End of Hurricane namespace.
void JsonNet::addHookLink ( Hook* hook, unsigned int jsonId, const string& jsonNext )
{
if (jsonNext.empty()) return;
unsigned int id = jsonId;
string tname = hook->_getTypeName();
auto ielement = _hooks.find( HookKey(id,tname) );
if (ielement == _hooks.end()) {
auto r = _hooks.insert( make_pair( HookKey(id,tname), HookElement(hook) ) );
ielement = r.first;
(*ielement).second.setFlags( HookElement::OpenRingStart );
}
HookElement* current = &((*ielement).second);
if (not current->hook()) current->setHook( hook );
hookFromString( jsonNext, id, tname );
ielement = _hooks.find( HookKey(id,tname) );
if (ielement == _hooks.end()) {
auto r = _hooks.insert( make_pair( HookKey(id,tname), HookElement(NULL) ) );
ielement = r.first;
} else {
(*ielement).second.resetFlags( HookElement::OpenRingStart );
}
current->setNext( &((*ielement).second) );
}
Hook* JsonNet::getHook ( unsigned int jsonId, const std::string& tname ) const
{
auto ihook = _hooks.find( HookKey(jsonId,tname) );
if (ihook == _hooks.end()) return NULL;
return (*ihook).second.hook();
}
bool JsonNet::hookFromString ( std::string s, unsigned int& id, std::string& tname )
{
size_t dot = s.rfind('.');
if (dot == string::npos) return false;
tname = s.substr( 0, dot );
id = stoul( s.substr(dot+1) );
return true;
}
bool JsonNet::checkRings () const
{
bool status = true;
for ( auto kv : _hooks ) {
HookElement* ringStart = &(kv.second);
if (ringStart->issetFlags(HookElement::ClosedRing)) continue;
if (ringStart->issetFlags(HookElement::OpenRingStart)) {
cerr << Error( "JsonNet::checkRing(): Open ring found, starting with %s.\n"
" Closing the ring..."
, getString(ringStart->hook()).c_str() ) << endl;
status = false;
HookElement* element = ringStart;
while ( true ) {
if (not element->next()) {
// The ring is open: close it (loop on ringStart).
element->setNext( ringStart );
element->setFlags( HookElement::ClosedRing );
cerr << Error( "Simple open ring." ) << endl;
break;
}
if (element->next()->issetFlags(HookElement::ClosedRing)) {
// The ring is half merged with itself, or another ring.
// (i.e. *multiple* hooks pointing the *same* next element)
element->setNext( ringStart );
element->setFlags( HookElement::ClosedRing );
cerr << Error( "Complex fault: ring partially merged (convergent)." ) << endl;
break;
}
element = element->next();
}
}
}
return status;
}
void JsonNet::buildRings () const
{
for ( auto kv : _hooks ) {
kv.second.hook()->_setNextHook( kv.second.next()->hook() );
}
}
} // Hurricane namespace.
// **************************************************************************************************** // ****************************************************************************************************

View File

@ -212,6 +212,15 @@ namespace Hurricane {
} }
void NetAliasName::toJson ( JsonWriter* w ) const
{
w->startObject();
jsonWrite( w, "@typename", "NetAlias" );
jsonWrite( w, "_name" , _name );
w->endObject();
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::AliasList" (Collection). // Class : "Hurricane::AliasList" (Collection).
@ -263,4 +272,47 @@ namespace Hurricane {
} }
// -------------------------------------------------------------------
// Class : "Hurricane::JsonNetAlias".
Initializer<JsonNetAlias> jsonNetAliasInit ( 0 );
void JsonNetAlias::initialize ()
{ JsonTypes::registerType( new JsonNetAlias (JsonWriter::RegisterMode) ); }
JsonNetAlias::JsonNetAlias( unsigned long flags )
: JsonObject(flags)
{
add( ".Net" , typeid(Net*) );
add( "_name", typeid(string) );
}
string JsonNetAlias::getTypeName () const
{ return "NetAlias"; }
JsonNetAlias* JsonNetAlias::clone ( unsigned long flags ) const
{ return new JsonNetAlias ( flags ); }
void JsonNetAlias::toData ( JsonStack& stack )
{
check( stack, "JsonNetAlias::toData" );
Net* net = get<Net*>( stack, ".Net" );
if (net) {
string name = get<string>( stack, "_name" );
if (not name.empty()) {
net->addAlias( name );
}
} else {
cerr << Error( "JsonNetAlias::toData(): Missing \".Net\" in stack context." ) << endl;
}
update( stack, NULL );
}
} // Hurricane namespace. } // Hurricane namespace.

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
@ -32,10 +26,7 @@
// | E-mail : Jean-Paul.Chaput@lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./NetExternalComponents.cpp" | // | C++ Module : "./NetExternalComponents.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/Error.h" #include "hurricane/Error.h"
@ -45,6 +36,8 @@
namespace Hurricane { namespace Hurricane {
// -------------------------------------------------------------------
// Class : "NetExternalComponents".
const Name NetExternalComponents::_name = "ExternalComponentsRelation"; const Name NetExternalComponents::_name = "ExternalComponentsRelation";
@ -96,4 +89,73 @@ namespace Hurricane {
} }
void NetExternalComponents::toJson ( JsonWriter* w, const Net* net )
{
w->startObject();
jsonWrite( w, "@typename", "NetExternalComponents" );
w->setFlags( JsonWriter::UseEntityReference );
if (net->isExternal()) {
jsonWrite( w, "+entities", get(net) );
} else {
w->key( "+entities" );
w->startArray();
w->endArray();
}
w->resetFlags( JsonWriter::UseEntityReference );
w->endObject();
}
// -------------------------------------------------------------------
// Class : "JsonNetExternalComponents".
Initializer<JsonNetExternalComponents> jsonNetExternalComponentsInit ( 0 );
void JsonNetExternalComponents::initialize ()
{ JsonTypes::registerType( new JsonNetExternalComponents (JsonWriter::RegisterMode) ); }
JsonNetExternalComponents::JsonNetExternalComponents ( unsigned long flags )
: JsonBaseArray<Entity*>(flags)
{
if (flags & JsonWriter::RegisterMode) return;
add( "+entities", typeid(JsonArray) );
}
JsonNetExternalComponents::~JsonNetExternalComponents ()
{
for ( Entity* entity : array() ) {
Component* component = dynamic_cast<Component*>( entity );
if (component) NetExternalComponents::setExternal( component );
else {
cerr << Error( "JsonNetExternalComponents(): %s in not a Component."
, getString(entity).c_str() ) << endl;
}
}
}
string JsonNetExternalComponents::getTypeName () const
{ return "NetExternalComponents"; }
JsonNetExternalComponents* JsonNetExternalComponents::clone( unsigned long flags ) const
{ return new JsonNetExternalComponents ( flags ); }
void JsonNetExternalComponents::toData ( JsonStack& stack )
{
ltracein(51);
check ( stack, "JsonNetExternalComponents::toData" );
update( stack, NULL );
ltraceout(51);
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -188,7 +188,12 @@ void JsonPad::toData(JsonStack& stack)
, get<Box>(stack,".Box") , get<Box>(stack,".Box")
); );
stack.addHookLink( pad->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) ); JsonNet* jnet = jget<JsonNet>( stack );
if (jnet) {
jnet->addHookLink( pad->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) );
} else {
cerr << Error( "JsonPad::toData(): Missing (Json)Net in stack context." ) << endl;
}
// Hook/Ring rebuild are done as a post-process. // Hook/Ring rebuild are done as a post-process.
update( stack, pad ); update( stack, pad );

View File

@ -197,6 +197,7 @@ void Plug::_toJson(JsonWriter* writer) const
if (writer->issetFlags(JsonWriter::UsePlugReference)) { if (writer->issetFlags(JsonWriter::UsePlugReference)) {
jsonWrite( writer, "_id" , getId() ); jsonWrite( writer, "_id" , getId() );
jsonWrite( writer, "_instance", getInstance()->getName() ); jsonWrite( writer, "_instance", getInstance()->getName() );
jsonWrite( writer, "_bodyHook", (const_cast<Plug*>(this)->getBodyHook())->getNextHook()->toJson() );
} else { } else {
Inherit::_toJson( writer ); Inherit::_toJson( writer );
jsonWrite( writer, "_masterNet", getMasterNet()->getName() ); jsonWrite( writer, "_masterNet", getMasterNet()->getName() );
@ -285,7 +286,6 @@ void JsonPlug::toData(JsonStack& stack)
plug = instance->getPlug( masterNet ); plug = instance->getPlug( masterNet );
if (issetFlags(JsonWriter::DesignBlobMode)) if (issetFlags(JsonWriter::DesignBlobMode))
plug->forceId( jsonId ); plug->forceId( jsonId );
stack.addHookLink( plug->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) );
} }
} else { } else {
cerr << Error( "JsonPlug::toData(): Cannot find \".Instance\" in stack, skipping." ) << endl; cerr << Error( "JsonPlug::toData(): Cannot find \".Instance\" in stack, skipping." ) << endl;
@ -314,6 +314,7 @@ JsonPlugRef::JsonPlugRef(unsigned long flags)
add( ".Net" , typeid(Net*) ); add( ".Net" , typeid(Net*) );
add( "_id" , typeid(uint64_t) ); add( "_id" , typeid(uint64_t) );
add( "_instance", typeid(string) ); add( "_instance", typeid(string) );
add( "_bodyHook", typeid(string) );
} }
string JsonPlugRef::getTypeName() const string JsonPlugRef::getTypeName() const
@ -337,6 +338,13 @@ void JsonPlugRef::toData(JsonStack& stack)
Plug* plug = stack.getEntity<Plug*>(id); Plug* plug = stack.getEntity<Plug*>(id);
if (plug) { if (plug) {
plug->setNet( net ); plug->setNet( net );
JsonNet* jnet = jget<JsonNet>( stack );
if (jnet) {
jnet->addHookLink( plug->getBodyHook (), id, get<string>(stack,"_bodyHook" ) );
} else {
cerr << Error( "JsonPlug::toData(): Missing (Json)Net in stack context." ) << endl;
}
} else { } else {
cerr << Error( "JsonPlugRef::toData(): No Plug id:%u in instance %s, while building net %s." cerr << Error( "JsonPlugRef::toData(): No Plug id:%u in instance %s, while building net %s."
, id, getString(instance->getName()).c_str(), getString(net->getName()).c_str() , id, getString(instance->getName()).c_str(), getString(net->getName()).c_str()

View File

@ -29,6 +29,7 @@
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
#include "hurricane/DataBase.h"
#include "hurricane/BasicLayer.h" #include "hurricane/BasicLayer.h"
#include "hurricane/RegularLayer.h" #include "hurricane/RegularLayer.h"
#include "hurricane/Technology.h" #include "hurricane/Technology.h"
@ -323,4 +324,123 @@ namespace Hurricane {
} }
void RegularLayer::_toJson ( JsonWriter* writer ) const
{
Super::_toJson( writer );
jsonWrite( writer, "_basicLayer" , _basicLayer->getName() );
jsonWrite( writer, "_enclosure" , _enclosure );
jsonWrite( writer, "_extentionCap" , _extentionCap );
jsonWrite( writer, "_extentionWidth" , _extentionWidth );
}
// -------------------------------------------------------------------
// Class : "Hurricane::JsonRegularLayer".
Initializer<JsonRegularLayer> jsonRegularLayerInit ( 0 );
void JsonRegularLayer::initialize ()
{ JsonTypes::registerType( new JsonRegularLayer (JsonWriter::RegisterMode) ); }
JsonRegularLayer::JsonRegularLayer ( unsigned long flags )
: JsonLayer(flags)
{
if (flags & JsonWriter::RegisterMode) return;
ltrace(51) << "JsonRegularLayer::JsonRegularLayer()" << endl;
add( "_basicLayer" , typeid(string) );
add( "_enclosure" , typeid(int64_t) );
add( "_extentionCap" , typeid(int64_t) );
add( "_extentionWidth", typeid(int64_t) );
}
JsonRegularLayer::~JsonRegularLayer ()
{ }
string JsonRegularLayer::getTypeName () const
{ return "RegularLayer"; }
JsonRegularLayer* JsonRegularLayer::clone ( unsigned long flags ) const
{ return new JsonRegularLayer ( flags ); }
void JsonRegularLayer::toData( JsonStack& stack )
{
ltracein(51);
check( stack, "JsonRegularLayer::toData" );
Technology* techno = lookupTechnology( stack, "JsonRegularLayer::toData" );
RegularLayer* layer = NULL;
if (techno) {
string name = get<string> ( stack, "_name" );
string smask = get<string> ( stack, "_mask" );
DbU::Unit minimalSize = get<int64_t>( stack, "_minimalSize" );
DbU::Unit minimalSpacing = get<int64_t>( stack, "_minimalSpacing" );
bool isWorking = get<bool> ( stack, "_working" );
BasicLayer* basicLayer = techno->getBasicLayer( get<string>(stack,"_basicLayer" ) );
DbU::Unit enclosure = get<int64_t>( stack, "_enclosure" );
DbU::Unit extensionCap = get<int64_t>( stack, "_extentionCap" );
DbU::Unit extensionWidth = get<int64_t>( stack, "_extentionWidth" );
Layer::Mask mask = Layer::Mask::fromString( smask );
if (stack.issetFlags(JsonWriter::TechnoMode)) {
// Actual creation.
layer = RegularLayer::create( techno, name );
layer->setBasicLayer ( basicLayer );
layer->setWorking ( isWorking );
layer->setMinimalSize ( minimalSize );
layer->setMinimalSpacing( minimalSpacing );
layer->setEnclosure ( basicLayer, enclosure );
layer->setExtentionCap ( basicLayer, extensionCap );
layer->setExtentionWidth( basicLayer, extensionWidth );
if (layer->getMask() != mask) {
cerr << Error( "JsonRegularLayer::toData(): Layer mask re-creation discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(layer->getMask()).c_str()
) << endl;
}
// Add here association with blockage layer...
} else {
// Check coherency with existing layer.
layer = dynamic_cast<RegularLayer*>( techno->getLayer(name) );
if (layer) {
if (layer->getMask() != mask) {
cerr << Error( "JsonRegularLayer::toData(): Layer mask discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(layer->getMask()).c_str()
) << endl;
}
} else {
cerr << Error( "JsonRegularLayer::toData(): No RegularLayer \"%s\" in the existing technology."
, name.c_str()
) << endl;
}
}
} else {
cerr << Error( "JsonRegularLayer::toData(): Cannot find technology, aborting RegularLayer creation." ) << endl;
}
update( stack, layer );
ltraceout(51);
}
} // Hurricane namespace. } // Hurricane namespace.

View File

@ -434,7 +434,12 @@ namespace Hurricane {
, get<Occurrence>(stack,"_occurrence") , get<Occurrence>(stack,"_occurrence")
); );
stack.addHookLink( rp->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) ); JsonNet* jnet = jget<JsonNet>( stack );
if (jnet) {
jnet->addHookLink( rp->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) );
} else {
cerr << Error( "JsonRoutingPad::toData(): Missing (Json)Net in stack context." ) << endl;
}
update( stack, rp ); update( stack, rp );
} }

View File

@ -17,6 +17,8 @@
// not, see <http://www.gnu.org/licenses/>. // not, see <http://www.gnu.org/licenses/>.
// **************************************************************************************************** // ****************************************************************************************************
#include "hurricane/Warning.h"
#include "hurricane/Error.h"
#include "hurricane/SharedName.h" #include "hurricane/SharedName.h"
#include "hurricane/Technology.h" #include "hurricane/Technology.h"
#include "hurricane/DataBase.h" #include "hurricane/DataBase.h"
@ -27,6 +29,21 @@
#include "hurricane/Error.h" #include "hurricane/Error.h"
namespace {
class CompareByMask {
public:
bool operator() ( const Hurricane::Layer* lhs, const Hurricane::Layer* rhs )
{
if (not lhs) return rhs;
if (not rhs) return false;
return lhs->getMask() < rhs->getMask();
}
};
} // Anonymous namespace.
namespace Hurricane { namespace Hurricane {
@ -363,14 +380,12 @@ void Technology::_removeFromLayerMaskMap ( Layer* layer )
} }
} }
string Technology::_getTypeName () const string Technology::_getTypeName () const
// **************************************
{ {
return _TName("Technology"); return _TName("Technology");
} }
string Technology::_getString() const string Technology::_getString() const
// ********************************** // **********************************
{ {
@ -393,6 +408,38 @@ Record* Technology::_getRecord() const
return record; return record;
} }
void Technology::_toJson(JsonWriter* writer) const
// ***********************************************
{
Inherit::_toJson( writer );
jsonWrite( writer, "_name", getName() );
}
void Technology::_toJsonCollections(JsonWriter* writer) const
// ***********************************************************
{
writer->key( "+layers" );
writer->startArray();
vector<BasicLayer*> basicLayers;
vector<Layer*> layers;
for ( Layer* layer : getLayers() ) {
BasicLayer* basicLayer = dynamic_cast<BasicLayer*>( layer );
if (basicLayer) basicLayers.push_back( basicLayer );
else layers .push_back( layer );
}
sort( basicLayers.begin(), basicLayers.end(), CompareByMask() );
sort( layers .begin(), layers .end(), CompareByMask() );
for ( BasicLayer* basicLayer : basicLayers ) jsonWrite( writer, basicLayer );
for ( Layer* layer : layers ) jsonWrite( writer, layer );
writer->endArray();
}
// **************************************************************************************************** // ****************************************************************************************************
// Technology::LayerMap implementation // Technology::LayerMap implementation
// **************************************************************************************************** // ****************************************************************************************************
@ -575,6 +622,96 @@ string Technology_BasicLayers::Locator::_getString() const
return s; return s;
} }
// ****************************************************************************************************
// JsonTechnology implementation
// ****************************************************************************************************
Initializer<JsonTechnology> jsonTechnologyInit ( 0 );
void JsonTechnology::initialize()
// *******************************
{ JsonTypes::registerType( new JsonTechnology (JsonWriter::RegisterMode) ); }
JsonTechnology::JsonTechnology(unsigned long flags)
// ************************************************
: JsonDBo (flags)
, _blockagesMap()
{
if (flags & JsonWriter::RegisterMode) return;
ltrace(51) << "JsonTechnology::JsonTechnology()" << endl;
add( "_name" , typeid(string) );
add( "+layers", typeid(JsonArray) );
}
JsonTechnology::~JsonTechnology()
// ******************************
{
const Technology* techno = getObject<Technology*>();
for ( auto element : _blockagesMap ) {
BasicLayer* blockage = techno->getBasicLayer( element.first );
if (blockage) {
for ( BasicLayer* layer : element.second ) {
layer->setBlockageLayer( blockage );
}
}
}
}
string JsonTechnology::getTypeName() const
// ****************************************
{ return "Technology"; }
JsonTechnology* JsonTechnology::clone(unsigned long flags) const
// *************************************************************
{ return new JsonTechnology ( flags ); }
void JsonTechnology::addBlockageRef(const string& blockageLayer, BasicLayer* layer )
// *********************************************************************************
{
map< string, vector<BasicLayer*> >::iterator im = _blockagesMap.find( blockageLayer );
if (im != _blockagesMap.end()) {
(*im).second.push_back( layer );
} else {
_blockagesMap.insert( make_pair( blockageLayer, vector<BasicLayer*>(1,layer) ) );
}
}
void JsonTechnology::toData(JsonStack& stack)
// ******************************************
{
ltracein(51);
check( stack, "JsonTechnology::toData" );
string technoName = get<string>( stack, "_name" );
Technology* techno = DataBase::getDB()->getTechnology();
if (techno) {
if (techno->getName() == technoName) {
cerr << Warning( "JsonTechnology::toData(): A technology with the same name (%s) is already loaded."
, technoName.c_str()
) << endl;
} else {
cerr << Error( "JsonTechnology::toData(): Try to load \"%s\", but \"%s\" is already loaded."
, technoName.c_str()
, getString(techno->getName()).c_str()
) << endl;
}
} else {
techno = Technology::create( DataBase::getDB(), technoName );
stack.setFlags( JsonWriter::TechnoMode );
}
update( stack, techno );
ltraceout(51);
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
@ -32,15 +26,13 @@
// | E-mail : Jean-Paul.Chaput@lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./TransistorLayer.cpp" | // | C++ Module : "./TransistorLayer.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/DataBase.h"
#include "hurricane/Technology.h"
#include "hurricane/BasicLayer.h" #include "hurricane/BasicLayer.h"
#include "hurricane/TransistorLayer.h" #include "hurricane/TransistorLayer.h"
#include "hurricane/Technology.h"
#include "hurricane/Error.h" #include "hurricane/Error.h"
@ -229,4 +221,161 @@ namespace Hurricane {
} }
void TransistorLayer::_toJson ( JsonWriter* w ) const
{
Super::_toJson( w );
jsonWrite( w, "_gate" , _basicLayers[0]->getName() );
jsonWrite( w, "_active" , _basicLayers[1]->getName() );
jsonWrite( w, "_diffusion", _basicLayers[2]->getName() );
if (_basicLayers.size() == 4) jsonWrite( w, "_well" , _basicLayers[3]->getName() );
else jsonWrite( w, "_well", "no_well_layer" );
jsonWrite( w, "_extentionCap.gate" , _extentionCaps[0] );
jsonWrite( w, "_extentionCap.active" , _extentionCaps[1] );
jsonWrite( w, "_extentionCap.diffusion", _extentionCaps[2] );
jsonWrite( w, "_extentionCap.well" , (_basicLayers.size() == 4) ? _extentionCaps[3] : 0 );
jsonWrite( w, "_extentionWidth.gate" , _extentionWidths[0] );
jsonWrite( w, "_extentionWidth.active" , _extentionWidths[1] );
jsonWrite( w, "_extentionWidth.diffusion", _extentionWidths[2] );
jsonWrite( w, "_extentionWidth.well" , (_basicLayers.size() == 4) ? _extentionWidths[3] : 0 );
}
// -------------------------------------------------------------------
// Class : "Hurricane::JsonTransistorLayer".
Initializer<JsonTransistorLayer> jsonTransistorLayerInit ( 0 );
void JsonTransistorLayer::initialize ()
{ JsonTypes::registerType( new JsonTransistorLayer (JsonWriter::RegisterMode) ); }
JsonTransistorLayer::JsonTransistorLayer ( unsigned long flags )
: JsonLayer(flags)
{
if (flags & JsonWriter::RegisterMode) return;
ltrace(51) << "JsonTransistorLayer::JsonTransistorLayer()" << endl;
add( "_gate" , typeid(string) );
add( "_active" , typeid(string) );
add( "_diffusion" , typeid(string) );
add( "_well" , typeid(string) );
add( "_extentionCap.gate" , typeid(int64_t) );
add( "_extentionCap.active" , typeid(int64_t) );
add( "_extentionCap.diffusion" , typeid(int64_t) );
add( "_extentionCap.well" , typeid(int64_t) );
add( "_extentionWidth.gate" , typeid(int64_t) );
add( "_extentionWidth.active" , typeid(int64_t) );
add( "_extentionWidth.diffusion", typeid(int64_t) );
add( "_extentionWidth.well" , typeid(int64_t) );
}
JsonTransistorLayer::~JsonTransistorLayer ()
{ }
string JsonTransistorLayer::getTypeName () const
{ return "TransistorLayer"; }
JsonTransistorLayer* JsonTransistorLayer::clone ( unsigned long flags ) const
{ return new JsonTransistorLayer ( flags ); }
void JsonTransistorLayer::toData ( JsonStack& stack )
{
ltracein(51);
check( stack, "JsonTransistorLayer::toData" );
Technology* techno = lookupTechnology( stack, "JsonTransistorLayer::toData" );
TransistorLayer* layer = NULL;
if (techno) {
string name = get<string> ( stack, "_name" );
string smask = get<string> ( stack, "_mask" );
//DbU::Unit minimalSize = get<int64_t>( stack, "_minimalSize" );
//DbU::Unit minimalSpacing = get<int64_t>( stack, "_minimalSpacing" );
bool isWorking = get<bool> ( stack, "_working" );
BasicLayer* gate = techno->getBasicLayer( get<string>(stack,"_gate" ) );
BasicLayer* active = techno->getBasicLayer( get<string>(stack,"_active" ) );
BasicLayer* diffusion = techno->getBasicLayer( get<string>(stack,"_diffusion" ) );
BasicLayer* well = techno->getBasicLayer( get<string>(stack,"_well" ) );
DbU::Unit eCapGate = get<int64_t>( stack, "_extentionCap.gate" );
DbU::Unit eCapActive = get<int64_t>( stack, "_extentionCap.active" );
DbU::Unit eCapDiffusion = get<int64_t>( stack, "_extentionCap.diffusion" );
DbU::Unit eCapWell = get<int64_t>( stack, "_extentionCap.well" );
DbU::Unit eWidthGate = get<int64_t>( stack, "_extentionWidth.gate" );
DbU::Unit eWidthActive = get<int64_t>( stack, "_extentionWidth.active" );
DbU::Unit eWidthDiffusion = get<int64_t>( stack, "_extentionWidth.diffusion" );
DbU::Unit eWidthWell = get<int64_t>( stack, "_extentionWidth.well" );
Layer::Mask mask = Layer::Mask::fromString( smask );
if (stack.issetFlags(JsonWriter::TechnoMode)) {
// Actual creation.
layer = TransistorLayer::create( techno
, name
, gate
, active
, diffusion
, well
);
layer->setWorking ( isWorking );
layer->setExtentionCap ( gate , eCapGate );
layer->setExtentionCap ( active , eCapActive );
layer->setExtentionCap ( diffusion, eCapDiffusion );
layer->setExtentionWidth( gate , eWidthGate );
layer->setExtentionWidth( active , eWidthActive );
layer->setExtentionWidth( diffusion, eWidthDiffusion );
if (well) {
layer->setExtentionCap ( well, eCapWell );
layer->setExtentionWidth( well, eWidthWell );
}
if (layer->getMask() != mask) {
cerr << Error( "JsonTransistorLayer::toData(): Layer mask re-creation discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(layer->getMask()).c_str()
) << endl;
}
// Add here association with blockage layer...
} else {
// Check coherency with existing layer.
layer = dynamic_cast<TransistorLayer*>( techno->getLayer(name) );
if (layer) {
if (layer->getMask() != mask) {
cerr << Error( "JsonTransistorLayer::toData(): Layer mask discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(layer->getMask()).c_str()
) << endl;
}
} else {
cerr << Error( "JsonTransistorLayer::toData(): No TransistorLayer \"%s\" in the existing technology."
, name.c_str()
) << endl;
}
}
} else {
cerr << Error( "JsonTransistorLayer::toData(): Cannot find technology, aborting TransistorLayer creation." ) << endl;
}
update( stack, layer );
ltraceout(51);
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -250,9 +250,14 @@ void JsonVertical::toData(JsonStack& stack)
, DbU::fromDb( get<int64_t>(stack,"_dyTarget") ) , DbU::fromDb( get<int64_t>(stack,"_dyTarget") )
); );
stack.addHookLink( vertical->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) ); JsonNet* jnet = jget<JsonNet>( stack );
stack.addHookLink( vertical->getSourceHook(), jsonId, get<string>(stack,"_sourceHook") ); if (jnet) {
stack.addHookLink( vertical->getTargetHook(), jsonId, get<string>(stack,"_targetHook") ); jnet->addHookLink( vertical->getBodyHook (), jsonId, get<string>(stack,"_bodyHook" ) );
jnet->addHookLink( vertical->getSourceHook(), jsonId, get<string>(stack,"_sourceHook") );
jnet->addHookLink( vertical->getTargetHook(), jsonId, get<string>(stack,"_targetHook") );
} else {
cerr << Error( "JsonVertical::toData(): Missing (Json)Net in stack context." ) << endl;
}
// Hook/Ring rebuild are done as a post-process. // Hook/Ring rebuild are done as a post-process.
update( stack, vertical ); update( stack, vertical );

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
@ -32,16 +26,14 @@
// | E-mail : Jean-Paul.Chaput@lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./ViaLayer.cpp" | // | C++ Module : "./ViaLayer.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
# include "hurricane/BasicLayer.h" #include "hurricane/DataBase.h"
# include "hurricane/ViaLayer.h" #include "hurricane/Technology.h"
# include "hurricane/Technology.h" #include "hurricane/BasicLayer.h"
# include "hurricane/Error.h" #include "hurricane/ViaLayer.h"
#include "hurricane/Error.h"
namespace { namespace {
@ -65,7 +57,6 @@ namespace Hurricane {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::ViaLayer". // Class : "Hurricane::ViaLayer".
ViaLayer::ViaLayer ( Technology* technology ViaLayer::ViaLayer ( Technology* technology
, const Name& name , const Name& name
, BasicLayer* bottomLayer , BasicLayer* bottomLayer
@ -210,4 +201,133 @@ namespace Hurricane {
} }
void ViaLayer::_toJson ( JsonWriter* w ) const
{
Super::_toJson( w );
jsonWrite( w, "_bottom", _basicLayers[0]->getName() );
jsonWrite( w, "_cut" , _basicLayers[1]->getName() );
jsonWrite( w, "_top" , _basicLayers[2]->getName() );
jsonWrite( w, "_enclosure.bottom", _enclosures[0] );
jsonWrite( w, "_enclosure.cut" , _enclosures[1] );
jsonWrite( w, "_enclosure.top" , _enclosures[2] );
}
// -------------------------------------------------------------------
// Class : "Hurricane::JsonViaLayer".
Initializer<JsonViaLayer> jsonViaLayerInit ( 0 );
void JsonViaLayer::initialize ()
{ JsonTypes::registerType( new JsonViaLayer (JsonWriter::RegisterMode) ); }
JsonViaLayer::JsonViaLayer ( unsigned long flags )
: JsonLayer(flags)
{
if (flags & JsonWriter::RegisterMode) return;
ltrace(51) << "JsonViaLayer::JsonViaLayer()" << endl;
add( "_bottom" , typeid(string) );
add( "_cut" , typeid(string) );
add( "_top" , typeid(string) );
add( "_enclosure.bottom", typeid(int64_t) );
add( "_enclosure.cut" , typeid(int64_t) );
add( "_enclosure.top" , typeid(int64_t) );
}
JsonViaLayer::~JsonViaLayer ()
{ }
string JsonViaLayer::getTypeName () const
{ return "ViaLayer"; }
JsonViaLayer* JsonViaLayer::clone ( unsigned long flags ) const
{ return new JsonViaLayer ( flags ); }
void JsonViaLayer::toData(JsonStack& stack)
{
ltracein(51);
check( stack, "JsonViaLayer::toData" );
Technology* techno = lookupTechnology( stack, "JsonViaLayer::toData" );
ViaLayer* layer = NULL;
if (techno) {
string name = get<string> ( stack, "_name" );
string smask = get<string> ( stack, "_mask" );
//DbU::Unit minimalSize = get<int64_t>( stack, "_minimalSize" );
//DbU::Unit minimalSpacing = get<int64_t>( stack, "_minimalSpacing" );
bool isWorking = get<bool> ( stack, "_working" );
BasicLayer* bottom = techno->getBasicLayer( get<string>(stack,"_bottom" ) );
BasicLayer* cut = techno->getBasicLayer( get<string>(stack,"_cut" ) );
BasicLayer* top = techno->getBasicLayer( get<string>(stack,"_top" ) );
DbU::Unit bottomEncl = get<int64_t>( stack, "_enclosure.bottom" );
DbU::Unit cutEncl = get<int64_t>( stack, "_enclosure.cut" );
DbU::Unit topEncl = get<int64_t>( stack, "_enclosure.top" );
Layer::Mask mask = Layer::Mask::fromString( smask );
if (stack.issetFlags(JsonWriter::TechnoMode)) {
// Actual creation.
layer = ViaLayer::create( techno
, name
, bottom
, cut
, top
);
layer->setWorking ( isWorking );
layer->setEnclosure( bottom, bottomEncl );
layer->setEnclosure( cut , cutEncl );
layer->setEnclosure( top , topEncl );
if (layer->getMask() != mask) {
cerr << Error( "JsonViaLayer::toData(): Layer mask re-creation discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(layer->getMask()).c_str()
) << endl;
}
// Add here association with blockage layer...
} else {
// Check coherency with existing layer.
layer = dynamic_cast<ViaLayer*>( techno->getLayer(name) );
if (layer) {
if (layer->getMask() != mask) {
cerr << Error( "JsonViaLayer::toData(): Layer mask discrepency on \"%s\":\n"
" Blob: %s\n"
" DataBase: %s"
, name.c_str()
, getString(mask).c_str()
, getString(layer->getMask()).c_str()
) << endl;
}
} else {
cerr << Error( "JsonViaLayer::toData(): No ViaLayer \"%s\" in the existing technology."
, name.c_str()
) << endl;
}
}
} else {
cerr << Error( "JsonViaLayer::toData(): Cannot find technology, aborting ViaLayer creation." ) << endl;
}
update( stack, layer );
ltraceout(51);
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -42,6 +42,8 @@ namespace Hurricane {
class BasicLayer : public Layer { class BasicLayer : public Layer {
public:
typedef Layer Super;
public: public:
// Subclass: Material. // Subclass: Material.
@ -66,6 +68,7 @@ namespace Hurricane {
Material& operator= ( const Material& material ); Material& operator= ( const Material& material );
inline operator const Code& () const; inline operator const Code& () const;
inline const Code& getCode () const; inline const Code& getCode () const;
static Material fromString ( const string& );
inline string _getTypeName () const; inline string _getTypeName () const;
string _getString () const; string _getString () const;
Record* _getRecord () const; Record* _getRecord () const;
@ -95,6 +98,7 @@ namespace Hurricane {
inline void setExtractNumber ( unsigned int ); inline void setExtractNumber ( unsigned int );
inline void setRealName ( const char* realName); inline void setRealName ( const char* realName);
// Hurricane Managment. // Hurricane Managment.
virtual void _toJson ( JsonWriter* writer ) const;
virtual BasicLayer* _getSymbolicBasicLayer (); virtual BasicLayer* _getSymbolicBasicLayer ();
virtual string _getTypeName () const; virtual string _getTypeName () const;
virtual string _getString () const; virtual string _getString () const;
@ -135,6 +139,20 @@ namespace Hurricane {
inline void BasicLayer::setRealName ( const char* realName) { _realName = realName; } inline void BasicLayer::setRealName ( const char* realName) { _realName = realName; }
// -------------------------------------------------------------------
// Class : "Hurricane::JsonBasicLayer".
class JsonBasicLayer : public JsonLayer {
public:
static void initialize ();
JsonBasicLayer ( unsigned long flags );
~JsonBasicLayer ();
virtual string getTypeName () const;
virtual JsonBasicLayer* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -333,6 +333,7 @@ class Cell : public Entity {
// ************ // ************
public: static Cell* create(Library* library, const Name& name); public: static Cell* create(Library* library, const Name& name);
public: static Cell* fromJson(const string& filename);
// Accessors // Accessors
// ********* // *********

View File

@ -742,7 +742,7 @@ inline Hurricane::Record* getRecord ( const std::multiset<Element,Compare>* s )
#include "hurricane/Initializer.h" #include "hurricane/Initializer.h"
#include "hurricane/Tabulation.h" #include "hurricane/Tabulation.h"
#include "hurricane/JsonWriter.h" #include "hurricane/JsonWriter.h"
#include "hurricane/JsonReader.h" #include "hurricane/JsonObject.h"
#endif // HURRICANE_COMMONS_H #endif // HURRICANE_COMMONS_H

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | 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 | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./hurricane/ContactLayer.h" | // | C++ Header : "./hurricane/ContactLayer.h" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_CONTACT_LAYER__ #ifndef HURRICANE_CONTACT_LAYER_H
#define __HURRICANE_CONTACT_LAYER__ #define HURRICANE_CONTACT_LAYER_H
#include <vector> #include <vector>
@ -49,7 +40,12 @@
namespace Hurricane { namespace Hurricane {
// -------------------------------------------------------------------
// Class : "Hurricane::ContactLayer".
class ContactLayer : public Layer { class ContactLayer : public Layer {
public:
typedef Layer Super;
public: public:
// Constructor. // Constructor.
@ -68,6 +64,7 @@ namespace Hurricane {
// Updators. // Updators.
virtual void setEnclosure ( const BasicLayer* layer, DbU::Unit enclosure ); virtual void setEnclosure ( const BasicLayer* layer, DbU::Unit enclosure );
// Hurricane Managment. // Hurricane Managment.
virtual void _toJson ( JsonWriter* ) const;
virtual void _onDbuChange ( float scale ); virtual void _onDbuChange ( float scale );
virtual string _getTypeName () const; virtual string _getTypeName () const;
virtual string _getString () const; virtual string _getString () const;
@ -91,6 +88,20 @@ namespace Hurricane {
}; };
// -------------------------------------------------------------------
// Class : "Hurricane::JsonContactLayer".
class JsonContactLayer : public JsonLayer {
public:
static void initialize ();
JsonContactLayer ( unsigned long flags );
~JsonContactLayer ();
virtual string getTypeName () const;
virtual JsonContactLayer* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -42,6 +42,9 @@ namespace Hurricane {
class DbU { class DbU {
public: public:
enum FunctionFlags { NoFlags = 0
, NoTechnoUpdate = (1<<0)
};
enum UnitPower { Pico = 1 enum UnitPower { Pico = 1
, Nano , Nano
, Micro , Micro
@ -49,9 +52,6 @@ namespace Hurricane {
, Unity , Unity
, Kilo , Kilo
}; };
public:
typedef long Unit;
public:
enum StringMode { Db = (1<<0) enum StringMode { Db = (1<<0)
, Grid = (1<<1) , Grid = (1<<1)
, Symbolic = (1<<2) , Symbolic = (1<<2)
@ -62,6 +62,8 @@ namespace Hurricane {
, Superior = 2 , Superior = 2
, Nearest = 4 , Nearest = 4
}; };
public:
typedef long Unit;
public: public:
static void checkGridBound ( double value ); static void checkGridBound ( double value );
@ -81,14 +83,14 @@ namespace Hurricane {
static unsigned int getPrecision (); static unsigned int getPrecision ();
static unsigned int getMaximalPrecision (); static unsigned int getMaximalPrecision ();
static double getResolution (); static double getResolution ();
static void setPrecision ( unsigned int precision ); static void setPrecision ( unsigned int precision, unsigned int flags=NoFlags );
// Founder Grid Managment. // Founder Grid Managment.
static double getUnitPower ( UnitPower p ); static double getUnitPower ( UnitPower p );
static void setPhysicalsPerGrid ( double gridsPerLambda, UnitPower p ); static void setPhysicalsPerGrid ( double gridsPerLambda, UnitPower p );
static double getPhysicalsPerGrid (); static double getPhysicalsPerGrid ();
static double physicalToGrid ( double physical, UnitPower p ); static double physicalToGrid ( double physical, UnitPower p );
// Lamba Managment. // Lamba Managment.
static void setGridsPerLambda ( double gridsPerLambda ); static void setGridsPerLambda ( double gridsPerLambda, unsigned int flags=NoFlags );
static double getGridsPerLambda (); static double getGridsPerLambda ();
// Snap Grid Managment. // Snap Grid Managment.
static DbU::Unit getRealSnapGridStep (); static DbU::Unit getRealSnapGridStep ();

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | 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 | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./hurricane/DiffusionLayer.h" | // | C++ Header : "./hurricane/DiffusionLayer.h" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_DIFFUSION_LAYER__ #ifndef HURRICANE_DIFFUSION_LAYER_H
#define __HURRICANE_DIFFUSION_LAYER__ #define HURRICANE_DIFFUSION_LAYER_H
#include <vector> #include <vector>
@ -48,8 +39,12 @@
namespace Hurricane { namespace Hurricane {
// -------------------------------------------------------------------
// Class : "Hurricane::DiffusionLayer".
class DiffusionLayer : public Layer { class DiffusionLayer : public Layer {
public:
typedef Layer Super;
public: public:
// Constructor. // Constructor.
@ -69,6 +64,7 @@ namespace Hurricane {
virtual void setExtentionCap ( const BasicLayer* layer, DbU::Unit cap ); virtual void setExtentionCap ( const BasicLayer* layer, DbU::Unit cap );
virtual void setExtentionWidth ( const BasicLayer* layer, DbU::Unit width ); virtual void setExtentionWidth ( const BasicLayer* layer, DbU::Unit width );
// Hurricane Managment. // Hurricane Managment.
virtual void _toJson ( JsonWriter* ) const;
virtual void _onDbuChange ( float scale ); virtual void _onDbuChange ( float scale );
virtual string _getTypeName () const; virtual string _getTypeName () const;
virtual string _getString () const; virtual string _getString () const;
@ -93,10 +89,24 @@ namespace Hurricane {
}; };
// -------------------------------------------------------------------
// Class : "Hurricane::JsonDiffusionLayer".
class JsonDiffusionLayer : public JsonLayer {
public:
static void initialize ();
JsonDiffusionLayer ( unsigned long flags );
~JsonDiffusionLayer ();
virtual string getTypeName () const;
virtual JsonDiffusionLayer* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // End of Hurricane namespace. } // End of Hurricane namespace.
INSPECTOR_P_SUPPORT(Hurricane::DiffusionLayer); INSPECTOR_P_SUPPORT(Hurricane::DiffusionLayer);
# endif #endif

View File

@ -98,6 +98,20 @@ namespace Hurricane {
stack.addEntity( jsonId, hobject ); stack.addEntity( jsonId, hobject );
} }
// -------------------------------------------------------------------
// Class : "JsonEntityRef".
class JsonEntityRef : public JsonObject {
public:
static void initialize ();
JsonEntityRef ( unsigned long flags );
virtual string getTypeName () const;
virtual JsonEntityRef* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // Hurricane namespace. } // Hurricane namespace.

View File

@ -0,0 +1,424 @@
// -*- C++ -*-
//
// Copyright (c) BULL S.A. 2015-2016, 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
// <http://www.gnu.org/licenses/>.
//
// +-----------------------------------------------------------------+
// | 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 |
// | |
// | Author : Jean-Paul Chaput |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./hurricane/JsonObject.h" |
// +-----------------------------------------------------------------+
#ifndef HURRICANE_JSON_OBJECT_H
#define HURRICANE_JSON_OBJECT_H
#ifndef HURRICANE_SLOT_H
#error "JsonObject.h must be included through Commons.h"
#endif
#include <iostream>
#include <typeinfo>
#include <typeindex>
#include <type_traits>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <boost/any.hpp>
namespace Hurricane {
class DBo;
class Hook;
class Entity;
class Cell;
class Component;
class JsonStack;
class JsonArray { };
// -------------------------------------------------------------------
// Class : "JsonAttribute".
class JsonAttribute {
public:
inline JsonAttribute ( const std::string& key, std::type_index tid );
inline std::string key () const;
inline std::type_index tid () const;
private:
std::string _key;
std::type_index _tid;
};
inline JsonAttribute::JsonAttribute ( const std::string& key, std::type_index tid ) : _key(key), _tid(tid) { }
inline std::string JsonAttribute::key () const { return _key; }
inline std::type_index JsonAttribute::tid () const { return _tid; }
// -------------------------------------------------------------------
// Class : "JsonObject".
class JsonObject {
public:
JsonObject ( unsigned long flags );
virtual ~JsonObject ();
virtual bool isDummy () const;
virtual std::string getTypeName () const = 0;
inline std::string getStackName () 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 );
void remove ( const std::string& key );
template<typename T> inline T get ( JsonStack&, const std::string& key ) const;
template<typename T> inline T* jget ( JsonStack& ) const;
inline void copyAttrs ( const JsonObject*, bool reset=false );
inline void clear ();
inline std::string getName () const;
inline void setName ( const std::string& );
template<typename T> inline T getObject () const;
template<typename T> inline void setObject ( T ) ;
inline bool isBound () const;
virtual JsonObject* clone ( unsigned long flags ) const = 0;
virtual void toData ( JsonStack& );
unsigned int presetId ( JsonStack& );
template<typename T> inline void update ( JsonStack&, T );
inline JsonObject* setFlags ( unsigned long mask );
inline JsonObject* resetFlags ( unsigned long mask );
inline bool issetFlags ( unsigned long mask ) const;
protected:
unsigned long _flags;
std::string _name;
std::vector<JsonAttribute> _stackeds;
std::vector<JsonAttribute> _attributes;
std::vector<JsonAttribute> _collections;
boost::any _object;
};
inline bool JsonObject::isBound () const { return not _object.empty(); }
inline std::string JsonObject::getName () const { return _name; }
inline void JsonObject::setName ( const string& name ) { _name=name; }
inline JsonObject* JsonObject::setFlags ( unsigned long mask ) { _flags |= mask; return this; }
inline JsonObject* JsonObject::resetFlags ( unsigned long mask ) { _flags &= ~mask; return this; }
inline bool JsonObject::issetFlags ( unsigned long mask ) const { return _flags & mask; }
inline std::string JsonObject::getStackName () const
{ return (_name.empty()) ? std::string(".")+getTypeName(): _name; }
template<typename T> inline T JsonObject::getObject () const
{ return boost::any_cast<T>(_object); }
template<typename T> inline void JsonObject::setObject ( T t )
{ _object = t; }
inline void JsonObject::copyAttrs ( const JsonObject* other, bool reset )
{
if (reset) _attributes.clear();
for ( size_t i=0 ; i<other->_attributes.size() ; ++i )
_attributes.push_back( other->_attributes[i] );
}
void JsonObject::clear ()
{
_stackeds.clear();
_attributes.clear();
_collections.clear();
boost::any emptyAny;
_object.swap( emptyAny );
}
// -------------------------------------------------------------------
// Class : "JsonKey".
class JsonKey : public JsonObject {
public:
inline JsonKey ( const std::string& );
virtual std::string getTypeName () const;
virtual JsonKey* clone ( unsigned long ) const;
private:
std::string _key;
};
// -------------------------------------------------------------------
// Class : "JsonDummy".
class JsonDummy : public JsonObject {
public:
JsonDummy ();
virtual bool isDummy () const;
virtual std::string getTypeName () const;
void setTypeName ( const std::string& name );
virtual JsonDummy* clone ( unsigned long ) const;
private:
std::string _typename;
};
// -------------------------------------------------------------------
// Class : "JsonBaseArray".
template<typename T>
class JsonBaseArray : public JsonObject {
public:
inline JsonBaseArray ( unsigned long flags );
inline const std::vector<T>& array () const;
inline void push_back ( T );
private:
std::vector<T> _array;
};
template<typename T>
inline JsonBaseArray<T>::JsonBaseArray ( unsigned long flags )
: JsonObject(flags)
, _array()
{ }
template<typename T>
inline const std::vector<T>& JsonBaseArray<T>::array () const { return _array; }
template<typename T>
inline void JsonBaseArray<T>::push_back ( T element )
{ _array.push_back(element); }
} // Hurricane namespace.
namespace std {
template<>
struct less<Hurricane::JsonObject*> {
inline bool operator() ( const Hurricane::JsonObject* lhs, const Hurricane::JsonObject* rhs )
{ return lhs->getTypeName() < rhs->getTypeName(); }
};
} // std namespace.
namespace Hurricane {
// -------------------------------------------------------------------
// Class : "JsonTypes".
class JsonTypes {
public:
static void initialize ();
static void registerType ( JsonObject* );
static JsonObject* find ( const std::string& tname );
private:
JsonTypes ();
~JsonTypes ();
JsonTypes ( const JsonTypes& );
void _registerType ( JsonObject* );
JsonObject* _find ( const std::string& tname );
private:
static JsonTypes* _jsonTypes;
std::set<JsonObject*> _jsonObjects;
};
// -------------------------------------------------------------------
// Class : "JsonStack".
class JsonStack {
public:
typedef std::pair<std::string, boost::any> Element;
public:
inline JsonStack ();
inline size_t size () const;
template<typename T> inline void push_back ( const std::string&, T );
inline void pop_back ( size_t count=1 );
inline int rhas ( const std::string& ) const;
template<typename T> inline T as ( const std::string& ) const;
template<typename T> inline T as ( int ) const;
inline void push_back_dbo ( DBo* );
inline void pop_back_dbo ();
inline DBo* back_dbo () const;
inline vector<JsonObject*>& jobjects ();
template<typename T> inline T getEntity ( unsigned int ) const;
void addEntity ( unsigned int jsonId, Entity* );
void print ( std::ostream& ) const;
inline unsigned long getFlags () const;
inline JsonStack* setFlags ( unsigned long mask );
inline JsonStack* resetFlags ( unsigned long mask );
inline bool issetFlags ( unsigned long mask ) const;
inline const Element& operator[] ( int index ) const;
private:
unsigned long _flags;
vector<Element> _stack;
vector<JsonObject*> _jstack;
vector<DBo*> _dbos;
std::map<unsigned int,Entity*> _entities;
};
inline JsonStack::JsonStack ()
: _flags(0), _stack(), _jstack(), _dbos(), _entities()
{ }
template<typename T> inline void JsonStack::push_back ( const std::string& key, T 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)));
}
inline void JsonStack::pop_back ( size_t count )
{
while (count--) {
if (_stack.empty()) {
std::cerr << "[ERROR] JsonStack::pop_back(): Stack is empty, but "
<< (count+1) << " elements remains to pop." << std::endl;
break;
}
ltrace(51) << "| _stack.pop_back() \"" << _stack.back().first
<< "\", size:" << _stack.size() << ", dbos:" << _dbos.size() << endl;
_stack.pop_back();
}
}
inline const JsonStack::Element& JsonStack::operator[] ( int index ) const
{
if (index < 0) return _stack[_stack.size()+index];
return _stack[index];
}
inline int JsonStack::rhas ( const std::string& key ) const
{
if (_stack.empty()) return 0;
int i = _stack.size()-1;
do {
if (_stack[i].first == key) {
ltrace(51) << "JsonStack::rhas(): key \"" << key << "\" found at index:"
<< (i-(int)_stack.size()) << " (i:" << i << ") "
<< "(" << demangle(_stack[i].second.type().name()) << ")."
<< endl;
return i-(int)_stack.size();
}
if (i == 0) break;
--i;
} while ( true );
ltrace(51) << "JsonStack::rhas(): key \"" << key << "\" not found (returning index: 0)." << endl;
return 0;
}
template<typename T> inline T JsonStack::as ( const std::string& key ) const
{
if (not _stack.empty()) {
int i = _stack.size()-1;
do {
if (_stack[i].first == key) {
ltrace(51) << "JsonStack::as<T>() k:" << key
<< " value:" << demangle(_stack[i].second.type().name()) << std::endl;
return boost::any_cast<T>( _stack[i].second );
}
if (i == 0) break;
--i;
} while ( true );
std::cerr << "[ERROR] JsonStack::as<T>(key): No element with key \""
<< key << "\" in stack." << std::endl;
} else {
std::cerr << "[ERROR] JsonStack::as<T>(key): Stack is empty while searching for key \""
<< key << "\"." << std::endl;
}
return T();
}
template<typename T> inline T JsonStack::as ( int index ) const
{
size_t i = (index >= 0) ? index : (_stack.size()+index);
return boost::any_cast<T>( _stack[i].second );
}
template<typename T> inline T JsonStack::getEntity ( unsigned int id ) const
{
std::map<unsigned int,Entity*>::const_iterator it = _entities.find(id);
if (it == _entities.end()) return NULL;
return dynamic_cast<T>((*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 vector<JsonObject*>& JsonStack::jobjects () { return _jstack; }
inline size_t JsonStack::size () const { return _stack.size(); }
inline unsigned long JsonStack::getFlags () const { return _flags; }
inline JsonStack* JsonStack::setFlags ( unsigned long mask ) { _flags |= mask; return this; }
inline JsonStack* JsonStack::resetFlags ( unsigned long mask ) { _flags &= ~mask; return this; }
inline bool JsonStack::issetFlags ( unsigned long mask ) const { return _flags & mask; }
template<typename T>
T JsonObject::get ( JsonStack& stack, const std::string& key ) const
{
int index = stack.rhas(key);
if (index == 0) return T();;
if (stack[index].second.type() == typeid(void*)) return T();
return stack.as<T>( index );
}
template<typename T>
T* JsonObject::jget ( JsonStack& stack ) const
{
vector<JsonObject*>& jobjects = stack.jobjects();
vector<JsonObject*>::reverse_iterator rit = jobjects.rbegin();
for ( ; rit != jobjects.rend() ; ++rit ) {
T* jobject = dynamic_cast<T*>( *rit );
if (jobject) return jobject;
}
return NULL;
}
template<typename T>
inline void JsonObject::update ( JsonStack& stack, T hobject )
{
ltrace(51) << "JsonObject::update<T>()" << endl;
stack.pop_back( _attributes.size() );
stack.push_back<T>( getStackName(), hobject );
setObject<T>( hobject );
}
// -------------------------------------------------------------------
// Function : Json Parsers.
Cell* jsonCellParse ( std::string filename );
Cell* jsonBlobParse ( std::string filename );
} // Hurricane namespace.
#endif // HURRICANE_JSON_OBJECT_H

View File

@ -32,421 +32,53 @@
#ifndef HURRICANE_JSON_READER_H #ifndef HURRICANE_JSON_READER_H
#define HURRICANE_JSON_READER_H #define HURRICANE_JSON_READER_H
#ifndef HURRICANE_SLOT_H #include <stdio.h>
#error "JsonWriter.h must be included through Commons.h"
#endif
#include <iostream>
#include <typeinfo>
#include <typeindex>
#include <type_traits>
#include <set>
#include <map>
#include <string> #include <string>
#include <functional> #include "rapidjson/filereadstream.h"
#include <boost/any.hpp> #include "rapidjson/reader.h"
#include "hurricane/Commons.h"
#include "hurricane/FileReadGzStream.h"
namespace Hurricane { namespace Hurricane {
class DBo; using rapidjson::Reader;
class Hook; class HurricaneHandler;
class Entity;
class Cell;
class Component;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "JsonObject". // Class : "JsonReader".
class JsonStack; class JsonReader {
class JsonArray { };
// -------------------------------------------------------------------
// Class : "JsonAttribute".
class JsonAttribute {
public: public:
inline JsonAttribute ( const std::string& key, std::type_index tid ); JsonReader ( unsigned long flags );
inline std::string key () const; ~JsonReader ();
inline std::type_index tid () const; inline JsonReader* setFlags ( unsigned long mask );
private: inline JsonReader* resetFlags ( unsigned long mask );
std::string _key;
std::type_index _tid;
};
inline JsonAttribute::JsonAttribute ( const std::string& key, std::type_index tid ) : _key(key), _tid(tid) { }
inline std::string JsonAttribute::key () const { return _key; }
inline std::type_index JsonAttribute::tid () const { return _tid; }
// -------------------------------------------------------------------
// Class : "JsonObject".
class JsonObject {
public:
JsonObject ( unsigned long flags );
virtual ~JsonObject ();
virtual bool isDummy () const;
virtual std::string getTypeName () const = 0;
inline std::string getStackName () 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 );
void remove ( const std::string& key );
template<typename T> inline T get ( JsonStack&, const std::string& key ) const;
inline void copyAttrs ( const JsonObject*, bool reset=false );
inline void clear ();
inline std::string getName () const;
inline void setName ( const std::string& );
template<typename T> inline T& getObject () const;
template<typename T> inline void setObject ( T ) ;
inline bool isBound () const;
virtual JsonObject* clone ( unsigned long flags ) const = 0;
virtual void toData ( JsonStack& );
unsigned int presetId ( JsonStack& );
template<typename T> inline void update ( JsonStack&, T );
inline JsonObject* setFlags ( unsigned long mask );
inline JsonObject* resetFlags ( unsigned long mask );
inline bool issetFlags ( unsigned long mask ) const; inline bool issetFlags ( unsigned long mask ) const;
protected: inline unsigned long getFlags () const;
unsigned long _flags; inline JsonStack& getStack ();
std::string _name; void parse ( std::string fileName );
std::vector<JsonAttribute> _stackeds; void close ();
std::vector<JsonAttribute> _attributes;
std::vector<JsonAttribute> _collections;
boost::any _object;
};
inline bool JsonObject::isBound () const { return not _object.empty(); }
inline std::string JsonObject::getName () const { return _name; }
inline void JsonObject::setName ( const string& name ) { _name=name; }
inline JsonObject* JsonObject::setFlags ( unsigned long mask ) { _flags |= mask; return this; }
inline JsonObject* JsonObject::resetFlags ( unsigned long mask ) { _flags &= ~mask; return this; }
inline bool JsonObject::issetFlags ( unsigned long mask ) const { return _flags & mask; }
inline std::string JsonObject::getStackName () const
{ return (_name.empty()) ? std::string(".")+getTypeName(): _name; }
template<typename T> inline T& JsonObject::getObject () const
{ return boost::any_cast<T>(_object); }
template<typename T> inline void JsonObject::setObject ( T t )
{ _object = t; }
inline void JsonObject::copyAttrs ( const JsonObject* other, bool reset )
{
if (reset) _attributes.clear();
for ( size_t i=0 ; i<other->_attributes.size() ; ++i )
_attributes.push_back( other->_attributes[i] );
}
void JsonObject::clear ()
{
_stackeds.clear();
_attributes.clear();
_collections.clear();
boost::any emptyAny;
_object.swap( emptyAny );
}
// -------------------------------------------------------------------
// Class : "JsonKey".
class JsonKey : public JsonObject {
public:
inline JsonKey ( const std::string& );
virtual std::string getTypeName () const;
virtual JsonKey* clone ( unsigned long ) const;
private: private:
std::string _key; JsonReader ( const JsonReader& );
}; JsonReader& operator= ( const JsonReader& ) const;
// -------------------------------------------------------------------
// Class : "JsonDummy".
class JsonDummy : public JsonObject {
public:
inline JsonDummy ();
virtual bool isDummy () const;
virtual std::string getTypeName () const;
void setTypeName ( const std::string& name );
virtual JsonDummy* clone ( unsigned long ) const;
private: private:
std::string _typename; size_t _bufferSize;
char* _buffer;
FILE* _file;
FileReadGzStream* _stream;
JsonStack _stack;
Reader _reader;
HurricaneHandler* _handler;
}; };
} // Hurricane namespace. inline JsonReader* JsonReader::setFlags ( unsigned long mask ) { _stack.setFlags(mask); return this; }
inline JsonReader* JsonReader::resetFlags ( unsigned long mask ) { _stack.resetFlags(mask); return this; }
inline bool JsonReader::issetFlags ( unsigned long mask ) const { return _stack.issetFlags(mask); }
namespace std { inline unsigned long JsonReader::getFlags () const { return _stack.getFlags(); }
inline JsonStack& JsonReader::getStack () { return _stack; }
template<>
struct less<Hurricane::JsonObject*> {
inline bool operator() ( const Hurricane::JsonObject* lhs, const Hurricane::JsonObject* rhs )
{ return lhs->getTypeName() < rhs->getTypeName(); }
};
} // std namespace.
namespace Hurricane {
// -------------------------------------------------------------------
// Class : "JsonTypes".
class JsonTypes {
public:
static void initialize ();
static void registerType ( JsonObject* );
static JsonObject* find ( const std::string& tname );
private:
JsonTypes ();
~JsonTypes ();
JsonTypes ( const JsonTypes& );
void _registerType ( JsonObject* );
JsonObject* _find ( const std::string& tname );
private:
static JsonTypes* _jsonTypes;
std::set<JsonObject*> _jsonObjects;
};
// -------------------------------------------------------------------
// Class : "HookKey".
class HookKey {
public:
inline HookKey ( unsigned int id, const std::string& tname );
inline unsigned int id () const;
inline std::string tname () const;
private:
unsigned int _id;
std::string _tname;
};
inline HookKey::HookKey ( unsigned int id, const std::string& tname ) : _id(id), _tname(tname) { }
inline unsigned int HookKey::id () const { return _id; }
inline std::string HookKey::tname () const { return _tname; }
inline bool operator< ( const HookKey& lhs, const HookKey& rhs )
{
if (lhs.id() != rhs.id()) return lhs.id() < rhs.id();
return lhs.tname() < rhs.tname();
}
// -------------------------------------------------------------------
// Class : "HookElement".
class HookElement {
public:
enum Flags { OpenRingStart = (1<<0)
, ClosedRing = (1<<1)
};
public:
inline HookElement ( Hook*, unsigned long flags=0 );
inline Hook* hook () const;
inline HookElement* next () const;
inline void setHook ( Hook* );
inline void setNext ( HookElement* );
inline unsigned long flags () const;
inline HookElement& setFlags ( unsigned long mask );
inline HookElement& resetFlags ( unsigned long mask );
inline bool issetFlags ( unsigned long mask ) const;
private:
Hook* _hook;
HookElement* _next;
unsigned long _flags;
};
inline HookElement::HookElement ( Hook* hook, unsigned long flags ) : _hook(hook), _next(NULL), _flags(flags) { }
inline Hook* HookElement::hook () const { return _hook; }
inline HookElement* HookElement::next () const { return _next; }
inline void HookElement::setHook ( Hook* hook ) { _hook = hook; }
inline void HookElement::setNext ( HookElement* element ) { _next = element; }
inline unsigned long HookElement::flags () const { return _flags; }
inline HookElement& HookElement::setFlags ( unsigned long mask ) { _flags |= mask; return *this; }
inline HookElement& HookElement::resetFlags ( unsigned long mask ) { _flags &= ~mask; return *this; }
inline bool HookElement::issetFlags ( unsigned long mask ) const { return _flags & mask; }
typedef map<HookKey,HookElement> HookLut;
// -------------------------------------------------------------------
// Class : "JsonStack".
class JsonStack {
public:
typedef std::pair<std::string, boost::any> Element;
public:
static bool hookFromString ( std::string s, unsigned int& id, std::string& tname );
public:
inline JsonStack ();
inline size_t size () const;
template<typename T> inline void push_back ( const std::string&, T );
inline void pop_back ( size_t count=1 );
inline int rhas ( const std::string& ) const;
template<typename T> inline T as ( const std::string& ) const;
template<typename T> inline T as ( int ) const;
inline void push_back_dbo ( DBo* );
inline void pop_back_dbo ();
inline DBo* back_dbo () const;
template<typename T> inline T getEntity ( unsigned int ) const;
void addEntity ( unsigned int jsonId, Entity* );
void addHookLink ( Hook*, unsigned int jsonId, const std::string& jsonNext );
Hook* getHook ( unsigned int jsonId, const std::string& tname ) const;
bool checkRings () const;
void buildRings () const;
inline void clearHookLinks ();
void print ( std::ostream& ) const;
inline JsonStack* setFlags ( unsigned long mask );
inline JsonStack* resetFlags ( unsigned long mask );
inline bool issetFlags ( unsigned long mask ) const;
inline const Element& operator[] ( int index ) const;
private:
unsigned long _flags;
vector<Element> _stack;
vector<DBo*> _dbos;
std::map<unsigned int,Entity*> _entities;
HookLut _hooks;
};
inline JsonStack::JsonStack ()
: _flags(0), _stack(), _dbos(), _entities(), _hooks()
{ }
template<typename T> inline void JsonStack::push_back ( const std::string& key, T 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)));
}
inline void JsonStack::pop_back ( size_t count )
{
while (count--) {
if (_stack.empty()) {
std::cerr << "[ERROR] JsonStack::pop_back(): Stack is empty, but "
<< (count+1) << " elements remains to pop." << std::endl;
break;
}
ltrace(51) << "| _stack.pop_back() \"" << _stack.back().first
<< "\", size:" << _stack.size() << ", dbos:" << _dbos.size() << endl;
_stack.pop_back();
}
}
inline const JsonStack::Element& JsonStack::operator[] ( int index ) const
{
if (index < 0) return _stack[_stack.size()+index];
return _stack[index];
}
inline int JsonStack::rhas ( const std::string& key ) const
{
if (_stack.empty()) return 0;
int i = _stack.size()-1;
do {
if (_stack[i].first == key) {
ltrace(51) << "JsonStack::rhas(): key \"" << key << "\" found at index:"
<< (i-(int)_stack.size()) << " (i:" << i << ") "
<< "(" << demangle(_stack[i].second.type().name()) << ")."
<< endl;
return i-(int)_stack.size();
}
if (i == 0) break;
--i;
} while ( true );
ltrace(51) << "JsonStack::rhas(): key \"" << key << "\" not found (returning index: 0)." << endl;
return 0;
}
template<typename T> inline T JsonStack::as ( const std::string& key ) const
{
if (not _stack.empty()) {
int i = _stack.size()-1;
do {
if (_stack[i].first == key) {
ltrace(51) << "JsonStack::as<T>() k:" << key
<< " value:" << demangle(_stack[i].second.type().name()) << std::endl;
return boost::any_cast<T>( _stack[i].second );
}
if (i == 0) break;
--i;
} while ( true );
std::cerr << "[ERROR] JsonStack::as<T>(key): No element with key \""
<< key << "\" in stack." << std::endl;
} else {
std::cerr << "[ERROR] JsonStack::as<T>(key): Stack is empty while searching for key \""
<< key << "\"." << std::endl;
}
return T();
}
template<typename T> inline T JsonStack::as ( int index ) const
{
size_t i = (index >= 0) ? index : (_stack.size()+index);
return boost::any_cast<T>( _stack[i].second );
}
template<typename T> inline T JsonStack::getEntity ( unsigned int id ) const
{
std::map<unsigned int,Entity*>::const_iterator it = _entities.find(id);
if (it == _entities.end()) return NULL;
return dynamic_cast<T>((*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; }
inline JsonStack* JsonStack::resetFlags ( unsigned long mask ) { _flags &= ~mask; return this; }
inline bool JsonStack::issetFlags ( unsigned long mask ) const { return _flags & mask; }
template<typename T>
T JsonObject::get ( JsonStack& stack, const std::string& key ) const
{
int index = stack.rhas(key);
if (index == 0) return T();;
if (stack[index].second.type() == typeid(void*)) return T();
return stack.as<T>( index );
}
template<typename T>
inline void JsonObject::update ( JsonStack& stack, T hobject )
{
ltrace(51) << "JsonObject::update<T>()" << endl;
stack.pop_back( _attributes.size() );
stack.push_back<T>( getStackName(), hobject );
setObject<T>( hobject );
}
// -------------------------------------------------------------------
// Function : Json Parsers.
Cell* jsonCellParse ( std::string filename );
Cell* jsonBlobParse ( std::string filename );
} // Hurricane namespace. } // Hurricane namespace.

View File

@ -38,6 +38,8 @@
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <vector>
#include <map>
namespace rapidjson { namespace rapidjson {
class FileWriteStream; class FileWriteStream;
@ -54,15 +56,17 @@ namespace Hurricane {
class JsonWriter { class JsonWriter {
public: public:
enum Mode { UsePlugReference = (1<<0) enum Mode { UsePlugReference = (1<< 0)
, DesignBlobMode = (1<<1) , UseEntityReference = (1<< 1)
, CellMode = (1<<2) , DesignBlobMode = (1<< 2)
, RegisterMode = (1<<3) , CellMode = (1<< 3)
, RegisterStatus = (1<<4) , TechnoMode = (1<< 4)
, RegisterType = (1<<5) , RegisterMode = (1<< 5)
, UnregisterType = (1<<6) , RegisterStatus = (1<< 6)
, CellObject = (1<<7) , RegisterType = (1<< 7)
, DBoObject = (1<<8) , UnregisterType = (1<< 8)
, CellObject = (1<< 9)
, DBoObject = (1<<10)
}; };
public: public:
JsonWriter ( std::string fileName ); JsonWriter ( std::string fileName );
@ -87,6 +91,10 @@ namespace Hurricane {
void write ( const unsigned int* ); void write ( const unsigned int* );
void write ( unsigned long ); void write ( unsigned long );
void write ( const unsigned long* ); void write ( const unsigned long* );
void write ( float );
void write ( const float* );
void write ( double );
void write ( const double* );
void close (); void close ();
JsonWriter* setFlags ( unsigned long mask ); JsonWriter* setFlags ( unsigned long mask );
JsonWriter* resetFlags ( unsigned long mask ); JsonWriter* resetFlags ( unsigned long mask );
@ -126,6 +134,10 @@ inline void jsonWrite ( JsonWriter* w, const unsigned int* v ) { w->write(v);
inline void jsonWrite ( JsonWriter* w, unsigned int v ) { w->write(v); } inline void jsonWrite ( JsonWriter* w, unsigned int v ) { w->write(v); }
inline void jsonWrite ( JsonWriter* w, const unsigned long* v ) { w->write(v); } inline void jsonWrite ( JsonWriter* w, const unsigned long* v ) { w->write(v); }
inline void jsonWrite ( JsonWriter* w, unsigned long v ) { w->write(v); } inline void jsonWrite ( JsonWriter* w, unsigned long v ) { w->write(v); }
inline void jsonWrite ( JsonWriter* w, const float* v ) { w->write(v); }
inline void jsonWrite ( JsonWriter* w, float v ) { w->write(v); }
inline void jsonWrite ( JsonWriter* w, const double* v ) { w->write(v); }
inline void jsonWrite ( JsonWriter* w, double v ) { w->write(v); }
//template<typename Type> //template<typename Type>
@ -181,11 +193,27 @@ inline void jsonWrite ( JsonWriter* w, const std::string& key, const std::strin
{ w->key( key ); w->write( value ); } { w->key( key ); w->write( value ); }
inline void jsonWrite ( JsonWriter* w, const std::string& key, const float* value )
{ w->key( key ); w->write( value ); }
inline void jsonWrite ( JsonWriter* w, const std::string& key, float value )
{ w->key( key ); w->write( value ); }
inline void jsonWrite ( JsonWriter* w, const std::string& key, const double* value )
{ w->key( key ); w->write( value ); }
inline void jsonWrite ( JsonWriter* w, const std::string& key, double value )
{ w->key( key ); w->write( value ); }
template<typename C> template<typename C>
inline void jsonWrite ( JsonWriter* w, const std::string& key, const C& ) inline void jsonWrite ( JsonWriter* w, const std::string& key, const C& )
{ {
w->key( key ); w->key( key );
std::string message = "Unsupported type " + Hurricane::demangle(typeid(C).name()); std::string message = "JSON unsupported type " + Hurricane::demangle(typeid(C).name());
w->write( message.c_str() ); w->write( message.c_str() );
} }
@ -222,11 +250,52 @@ inline void jsonWrite ( JsonWriter* w, const std::string& key, const C* object
Hurricane::ltracein(50); Hurricane::ltracein(50);
w->key( key ); w->key( key );
if (object) object->toJson( w ); if (object) jsonWrite( w, object );
else jsonWrite(w); else jsonWrite(w);
Hurricane::ltraceout(50); Hurricane::ltraceout(50);
} }
template<typename Element>
inline void jsonWrite ( JsonWriter* w, const std::string& key, const std::vector<Element>& v )
{
if (Hurricane::inltrace(50))
std::cerr << Hurricane::tab
<< "jsonWrite< vector<" << Hurricane::demangle(typeid(Element).name())
<< "> >(w,key,v)" << " key:\"" << key << "\"" << std::endl;
Hurricane::ltracein(50);
w->key( key );
w->startArray();
for ( Element element : v ) jsonWrite( w, element );
w->endArray();
Hurricane::ltraceout(50);
}
template<typename Key, typename Element, typename Compare, typename Allocator>
inline void jsonWrite ( JsonWriter* w
, const std::string& key
, const std::map<Key,Element,Compare,Allocator>& m )
{
if (Hurricane::inltrace(50))
std::cerr << Hurricane::tab
<< "jsonWrite< map<"
<< Hurricane::demangle(typeid(Key ).name()) << ","
<< Hurricane::demangle(typeid(Element).name()) << ","
<< Hurricane::demangle(typeid(Compare).name())
<< "> >(w,key,m)" << " key:\"" << key << "\"" << std::endl;
Hurricane::ltracein(50);
w->key( key );
w->startArray();
for ( auto mapElement : m ) jsonWrite( w, mapElement.second );
w->endArray();
Hurricane::ltraceout(50);
}
#endif // HURRICANE_JSON_WRITER_H #endif // HURRICANE_JSON_WRITER_H

View File

@ -30,8 +30,8 @@
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
#ifndef __HURRICANE_LAYER__ #ifndef HURRICANE_LAYER_H
#define __HURRICANE_LAYER__ #define HURRICANE_LAYER_H
#include "hurricane/Mask.h" #include "hurricane/Mask.h"
#include "hurricane/DBo.h" #include "hurricane/DBo.h"
@ -46,7 +46,12 @@ namespace Hurricane {
class Technology; class Technology;
// -------------------------------------------------------------------
// Class : "Hurricane::Layer".
class Layer : public DBo { class Layer : public DBo {
public:
typedef DBo Super;
public: public:
// Types. // Types.
@ -88,6 +93,7 @@ namespace Hurricane {
virtual void setExtentionCap ( const BasicLayer* layer, DbU::Unit ); virtual void setExtentionCap ( const BasicLayer* layer, DbU::Unit );
virtual void setExtentionWidth ( const BasicLayer* layer, DbU::Unit ); virtual void setExtentionWidth ( const BasicLayer* layer, DbU::Unit );
// Hurricane Managment. // Hurricane Managment.
virtual void _toJson ( JsonWriter* ) const;
virtual string _getString () const; virtual string _getString () const;
virtual Record* _getRecord () const; virtual Record* _getRecord () const;
inline Layer* _getNextOfTechnologyLayerMap () const; inline Layer* _getNextOfTechnologyLayerMap () const;
@ -146,12 +152,21 @@ namespace Hurricane {
{ return (lhs?lhs->getMask():Layer::Mask()) < (rhs?rhs->getMask():Layer::Mask()); } { return (lhs?lhs->getMask():Layer::Mask()) < (rhs?rhs->getMask():Layer::Mask()); }
// -------------------------------------------------------------------
// Class : "Hurricane::JsonLayer".
} // End of Hurricane namespace. class JsonLayer : public JsonDBo {
public:
JsonLayer ( unsigned long flags );
Technology* lookupTechnology ( JsonStack&, const string& fname ) const;
};
} // Hurricane namespace.
INSPECTOR_P_SUPPORT(Hurricane::Layer); INSPECTOR_P_SUPPORT(Hurricane::Layer);
INSPECTOR_PV_SUPPORT(Hurricane::Layer::Mask); INSPECTOR_PV_SUPPORT(Hurricane::Layer::Mask);
# endif #endif // HURRICANE_LAYER_H

View File

@ -33,6 +33,7 @@
#define HURRICANE_MASK_H #define HURRICANE_MASK_H
#include <iomanip> #include <iomanip>
#include <sstream>
#include "hurricane/Commons.h" #include "hurricane/Commons.h"
@ -57,6 +58,7 @@ namespace Hurricane {
inline Mask operator xor ( const Mask mask ) const; inline Mask operator xor ( const Mask mask ) const;
inline Mask lshift ( unsigned int ) const; inline Mask lshift ( unsigned int ) const;
inline Mask rshift ( unsigned int ) const; inline Mask rshift ( unsigned int ) const;
inline Mask& operator += ( unsigned int );
inline Mask& operator |= ( const Mask mask ); inline Mask& operator |= ( const Mask mask );
inline Mask& operator &= ( const Mask mask ); inline Mask& operator &= ( const Mask mask );
inline bool operator == ( const Mask mask ) const; inline bool operator == ( const Mask mask ) const;
@ -64,6 +66,7 @@ namespace Hurricane {
inline bool operator < ( const Mask mask ) const; inline bool operator < ( const Mask mask ) const;
inline bool operator > ( const Mask mask ) const; inline bool operator > ( const Mask mask ) const;
inline operator IntType () const; inline operator IntType () const;
static inline Mask fromString ( const string& );
// Hurricane Managment. // Hurricane Managment.
inline string _getTypeName () const; inline string _getTypeName () const;
inline string _getString () const; inline string _getString () const;
@ -138,6 +141,10 @@ namespace Hurricane {
inline Mask<IntType> Mask<IntType>::rshift ( unsigned int s ) const inline Mask<IntType> Mask<IntType>::rshift ( unsigned int s ) const
{ return _mask >> s; } { return _mask >> s; }
template<typename IntType>
inline Mask<IntType>& Mask<IntType>::operator += ( unsigned int v )
{ _mask += v; return *this; }
template<typename IntType> template<typename IntType>
inline Mask<IntType>& Mask<IntType>::operator |= ( const Mask<IntType> mask ) inline Mask<IntType>& Mask<IntType>::operator |= ( const Mask<IntType> mask )
{ _mask |= mask._mask; return *this; } { _mask |= mask._mask; return *this; }
@ -189,6 +196,58 @@ namespace Hurricane {
size_t Mask<IntType>::_width = sizeof(IntType)<<2; size_t Mask<IntType>::_width = sizeof(IntType)<<2;
template<typename IntType>
inline Mask<IntType> Mask<IntType>::fromString ( const string& s )
{
IntType value;
istringstream iss ( s );
iss >> hex >> value;
Mask<IntType> mask ( value );
#if NO_ISTRINGSTREAM
if ( (s.size() > 2) and (s.size() <= _width+2) and (s.substr(0,2) == "0x") ) {
for ( size_t i=2 ; i<s.size() ; ++i ) {
mask.lshift( 4 );
switch ( s[i] ) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
mask += (unsigned int)(s[i] - '0'); break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
mask += (unsigned int)(s[i] - 'a')+10; break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
mask += (unsigned int)(s[i] - 'A')+10; break;
default:
break;
}
}
}
#endif
return mask;
}
} // Hurricane namespace. } // Hurricane namespace.
# endif // HURRICANE_MASK_H # endif // HURRICANE_MASK_H

View File

@ -259,25 +259,99 @@ class Net : public Entity {
}; };
class JsonNet : public JsonEntity {
// ********************************
public: static void initialize(); // -------------------------------------------------------------------
public: JsonNet(unsigned long flags); // Class : "HookKey".
public: virtual ~JsonNet();
public: virtual string getTypeName() const;
public: virtual JsonNet* clone(unsigned long) const;
public: virtual void toData(JsonStack&);
// Attributes class HookKey {
// ********** public:
inline HookKey ( unsigned int id, const std::string& tname );
inline unsigned int id () const;
inline std::string tname () const;
private:
unsigned int _id;
std::string _tname;
};
protected: bool _autoMaterialize;
protected: Net* _net;
protected: JsonStack* _stack;
};
} // End of Hurricane namespace. inline HookKey::HookKey ( unsigned int id, const std::string& tname ) : _id(id), _tname(tname) { }
inline unsigned int HookKey::id () const { return _id; }
inline std::string HookKey::tname () const { return _tname; }
inline bool operator< ( const HookKey& lhs, const HookKey& rhs )
{
if (lhs.id() != rhs.id()) return lhs.id() < rhs.id();
return lhs.tname() < rhs.tname();
}
// -------------------------------------------------------------------
// Class : "HookElement".
class HookElement {
public:
enum Flags { OpenRingStart = (1<<0)
, ClosedRing = (1<<1)
};
public:
inline HookElement ( Hook*, unsigned long flags=0 );
inline Hook* hook () const;
inline HookElement* next () const;
inline void setHook ( Hook* );
inline void setNext ( HookElement* );
inline unsigned long flags () const;
inline HookElement& setFlags ( unsigned long mask );
inline HookElement& resetFlags ( unsigned long mask );
inline bool issetFlags ( unsigned long mask ) const;
private:
Hook* _hook;
HookElement* _next;
unsigned long _flags;
};
inline HookElement::HookElement ( Hook* hook, unsigned long flags ) : _hook(hook), _next(NULL), _flags(flags) { }
inline Hook* HookElement::hook () const { return _hook; }
inline HookElement* HookElement::next () const { return _next; }
inline void HookElement::setHook ( Hook* hook ) { _hook = hook; }
inline void HookElement::setNext ( HookElement* element ) { _next = element; }
inline unsigned long HookElement::flags () const { return _flags; }
inline HookElement& HookElement::setFlags ( unsigned long mask ) { _flags |= mask; return *this; }
inline HookElement& HookElement::resetFlags ( unsigned long mask ) { _flags &= ~mask; return *this; }
inline bool HookElement::issetFlags ( unsigned long mask ) const { return _flags & mask; }
typedef map<HookKey,HookElement> HookLut;
// -------------------------------------------------------------------
// Class : "JsonNet".
class JsonNet : public JsonEntity {
public:
static bool hookFromString ( std::string s, unsigned int& id, std::string& tname );
static void initialize ();
JsonNet ( unsigned long flags );
virtual ~JsonNet ();
virtual string getTypeName () const;
virtual JsonNet* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
void addHookLink ( Hook*, unsigned int jsonId, const std::string& jsonNext );
Hook* getHook ( unsigned int jsonId, const std::string& tname ) const;
bool checkRings () const;
void buildRings () const;
inline void clearHookLinks ();
protected:
bool _autoMaterialize;
Net* _net;
HookLut _hooks;
};
inline void JsonNet::clearHookLinks () { _hooks.clear(); }
} // Hurricane namespace.
// ------------------------------------------------------------------- // -------------------------------------------------------------------

View File

@ -110,6 +110,7 @@ namespace Hurricane {
virtual bool isSlave () const; virtual bool isSlave () const;
virtual Name getName () const; virtual Name getName () const;
virtual Net* getNet () const; virtual Net* getNet () const;
virtual void toJson ( JsonWriter* ) const;
virtual std::string _getString () const; virtual std::string _getString () const;
virtual Record* _getRecord () const; virtual Record* _getRecord () const;
public: public:
@ -182,6 +183,19 @@ namespace Hurricane {
{ } { }
// -------------------------------------------------------------------
// Class : "JsonNetAlias".
class JsonNetAlias : public JsonObject {
public:
static void initialize ();
JsonNetAlias ( unsigned long flags );
virtual string getTypeName () const;
virtual JsonNetAlias* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // Namespace Hurricane. } // Namespace Hurricane.

View File

@ -38,12 +38,15 @@
namespace Hurricane { namespace Hurricane {
// -------------------------------------------------------------------
// Class : "NetExternalComponents".
class NetExternalComponents { class NetExternalComponents {
public: public:
static Components get ( const Net* ); static Components get ( const Net* );
static void setExternal ( Component* ); static void setExternal ( Component* );
static bool isExternal ( Component* ); static bool isExternal ( Component* );
static void toJson ( JsonWriter*, const Net* );
protected: protected:
static StandardRelation* getRelation ( const Net* ); static StandardRelation* getRelation ( const Net* );
private: private:
@ -51,6 +54,20 @@ namespace Hurricane {
}; };
// -------------------------------------------------------------------
// Class : "JsonNetExternalComponents".
class JsonNetExternalComponents : public JsonBaseArray<Entity*> {
public:
static void initialize ();
JsonNetExternalComponents ( unsigned long flags );
virtual ~JsonNetExternalComponents ();
virtual string getTypeName () const;
virtual JsonNetExternalComponents* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // Hurricane namespace. } // Hurricane namespace.
#endif // HURRICANE_NET_EXTERNAL_COMPONENTS_H #endif // HURRICANE_NET_EXTERNAL_COMPONENTS_H

View File

@ -39,8 +39,12 @@
namespace Hurricane { namespace Hurricane {
// -------------------------------------------------------------------
// Class : "Hurricane::RegularLayer".
class RegularLayer : public Layer { class RegularLayer : public Layer {
public:
typedef Layer Super;
public: public:
// Constructor. // Constructor.
@ -66,6 +70,7 @@ namespace Hurricane {
virtual void setExtentionCap ( const BasicLayer* layer, DbU::Unit cap ); virtual void setExtentionCap ( const BasicLayer* layer, DbU::Unit cap );
virtual void setExtentionWidth ( const BasicLayer* layer, DbU::Unit width ); virtual void setExtentionWidth ( const BasicLayer* layer, DbU::Unit width );
// Hurricane Managment. // Hurricane Managment.
virtual void _toJson ( JsonWriter* ) const;
virtual void _onDbuChange ( float scale ); virtual void _onDbuChange ( float scale );
virtual string _getTypeName () const; virtual string _getTypeName () const;
virtual string _getString () const; virtual string _getString () const;
@ -90,6 +95,20 @@ namespace Hurricane {
inline BasicLayer* RegularLayer::getBasicLayer () const { return _basicLayer; } inline BasicLayer* RegularLayer::getBasicLayer () const { return _basicLayer; }
// -------------------------------------------------------------------
// Class : "Hurricane::JsonRegularLayer".
class JsonRegularLayer : public JsonLayer {
public:
static void initialize ();
JsonRegularLayer ( unsigned long flags );
~JsonRegularLayer ();
virtual string getTypeName () const;
virtual JsonRegularLayer* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // Hurricane namespace. } // Hurricane namespace.
INSPECTOR_P_SUPPORT(Hurricane::RegularLayer); INSPECTOR_P_SUPPORT(Hurricane::RegularLayer);

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | 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 | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./hurricane/Technology.h" | // | C++ Header : "./hurricane/Technology.h" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_TECHNOLOGY__ #ifndef HURRICANE_TECHNOLOGY_H
#define __HURRICANE_TECHNOLOGY__ #define HURRICANE_TECHNOLOGY_H
#include <map> #include <map>
#include "hurricane/Mask.h" #include "hurricane/Mask.h"
@ -64,7 +55,6 @@ namespace Hurricane {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::Technology". // Class : "Hurricane::Technology".
class Technology : public DBo { class Technology : public DBo {
public: public:
@ -120,6 +110,8 @@ namespace Hurricane {
inline Layer::Mask& _getMetalMask (); inline Layer::Mask& _getMetalMask ();
void _onDbuChange ( float scale ); void _onDbuChange ( float scale );
// Hurricane Managment. // Hurricane Managment.
virtual void _toJson ( JsonWriter* ) const;
virtual void _toJsonCollections ( JsonWriter* ) const;
virtual string _getTypeName () const; virtual string _getTypeName () const;
virtual string _getString () const; virtual string _getString () const;
virtual Record* _getRecord () const; virtual Record* _getRecord () const;
@ -153,10 +145,27 @@ namespace Hurricane {
inline Layer::Mask& Technology::_getMetalMask () { return _metalMask; } inline Layer::Mask& Technology::_getMetalMask () { return _metalMask; }
} // End of Hurricane namespace. // -------------------------------------------------------------------
// Class : "Hurricane::JsonTechnology".
class JsonTechnology : public JsonDBo {
public:
static void initialize ();
JsonTechnology ( unsigned long flags );
virtual ~JsonTechnology ();
virtual string getTypeName () const;
virtual JsonTechnology* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
void addBlockageRef ( const std::string&, BasicLayer* );
private:
std::map< string, vector<BasicLayer*> > _blockagesMap;
};
} // Hurricane namespace.
INSPECTOR_P_SUPPORT(Hurricane::Technology); INSPECTOR_P_SUPPORT(Hurricane::Technology);
#endif // __HURRICANE_TECHNOLOGY__ #endif // HURRICANE_TECHNOLOGY_H

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | 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 | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./hurricane/TransistorLayer.h" | // | C++ Header : "./hurricane/TransistorLayer.h" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_TRANSISTOR_LAYER__ #ifndef HURRICANE_TRANSISTOR_LAYER_H
#define __HURRICANE_TRANSISTOR_LAYER__ #define HURRICANE_TRANSISTOR_LAYER_H
#include <vector> #include <vector>
@ -49,8 +40,12 @@
namespace Hurricane { namespace Hurricane {
// -------------------------------------------------------------------
// Class : "Hurricane::TransistorLayer".
class TransistorLayer : public Layer { class TransistorLayer : public Layer {
public:
typedef Layer Super;
public: public:
// Constructor. // Constructor.
@ -71,6 +66,7 @@ namespace Hurricane {
virtual void setExtentionCap ( const BasicLayer* layer, DbU::Unit cap ); virtual void setExtentionCap ( const BasicLayer* layer, DbU::Unit cap );
virtual void setExtentionWidth ( const BasicLayer* layer, DbU::Unit width ); virtual void setExtentionWidth ( const BasicLayer* layer, DbU::Unit width );
// Hurricane Managment. // Hurricane Managment.
virtual void _toJson ( JsonWriter* ) const;
virtual void _onDbuChange ( float scale ); virtual void _onDbuChange ( float scale );
virtual string _getTypeName () const; virtual string _getTypeName () const;
virtual string _getString () const; virtual string _getString () const;
@ -96,6 +92,20 @@ namespace Hurricane {
}; };
// -------------------------------------------------------------------
// Class : "Hurricane::JsonTransistorLayer".
class JsonTransistorLayer : public JsonLayer {
public:
static void initialize ();
JsonTransistorLayer ( unsigned long flags );
~JsonTransistorLayer ();
virtual string getTypeName () const;
virtual JsonTransistorLayer* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (c) BULL S.A. 2000-2016, All Rights Reserved // Copyright (c) BULL S.A. 2000-2016, All Rights Reserved
@ -19,12 +18,7 @@
// License along with Hurricane. If not, see // License along with Hurricane. If not, see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | 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 | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./hurricane/ViaLayer.h" | // | C++ Header : "./hurricane/ViaLayer.h" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_VIA_LAYER__ #ifndef HURRICANE_VIA_LAYER_H
#define __HURRICANE_VIA_LAYER__ #define HURRICANE_VIA_LAYER_H
#include <vector> #include <vector>
@ -49,8 +40,12 @@
namespace Hurricane { namespace Hurricane {
// -------------------------------------------------------------------
// Class : "Hurricane::ViaLayer".
class ViaLayer : public Layer { class ViaLayer : public Layer {
public:
typedef Layer Super;
public: public:
// Constructor. // Constructor.
@ -70,6 +65,7 @@ namespace Hurricane {
// Updators. // Updators.
virtual void setEnclosure ( const BasicLayer* layer, DbU::Unit enclosure ); virtual void setEnclosure ( const BasicLayer* layer, DbU::Unit enclosure );
// Hurricane Managment. // Hurricane Managment.
virtual void _toJson ( JsonWriter* ) const;
virtual void _onDbuChange ( float scale ); virtual void _onDbuChange ( float scale );
virtual string _getTypeName () const; virtual string _getTypeName () const;
virtual string _getString () const; virtual string _getString () const;
@ -92,6 +88,20 @@ namespace Hurricane {
}; };
// -------------------------------------------------------------------
// Class : "Hurricane::JsonViaLayer".
class JsonViaLayer : public JsonLayer {
public:
static void initialize ();
JsonViaLayer ( unsigned long flags );
~JsonViaLayer ();
virtual string getTypeName () const;
virtual JsonViaLayer* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -1,8 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2013, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | C O R I O L I S | // | C O R I O L I S |
@ -149,5 +148,5 @@ extern "C" {
} // End of extern "C". } // End of extern "C".
} // End of Isobar namespace. } // Isobar namespace.

View File

@ -1,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2016, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | C O R I O L I S | // | C O R I O L I S |

View File

@ -1,11 +1,9 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved // Copyright (c) UPMC 2010-2016, All Rights Reserved
// //
// x-----------------------------------------------------------------x // +-----------------------------------------------------------------+
// | |
// | C O R I O L I S | // | C O R I O L I S |
// | I s o b a r - Hurricane / Python Interface | // | I s o b a r - Hurricane / Python Interface |
// | | // | |
@ -13,18 +11,11 @@
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./PyNetExternalComponents.h" | // | C++ Header : "./PyNetExternalComponents.h" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef PY_NET_EXTERNAL_COMPONENTS_H
#define PY_NET_EXTERNAL_COMPONENTS_H
# ifndef __PY_NET_EXTERNAL_COMPONENTS__
# define __PY_NET_EXTERNAL_COMPONENTS__
#include "hurricane/isobar/PyHurricane.h" #include "hurricane/isobar/PyHurricane.h"
#include "hurricane/NetExternalComponents.h" #include "hurricane/NetExternalComponents.h"
@ -43,8 +34,6 @@ extern "C" {
} PyNetExternalComponents; } PyNetExternalComponents;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Functions & Types exported to "PyHurricane.cpp". // Functions & Types exported to "PyHurricane.cpp".
@ -59,13 +48,9 @@ extern "C" {
#define PYNETEXTERNALCOMPONENTS_O(v) ( PY_NET_EXTERNAL_COMPONENTS(v)->_object ) #define PYNETEXTERNALCOMPONENTS_O(v) ( PY_NET_EXTERNAL_COMPONENTS(v)->_object )
} // End of extern "C". } // extern "C".
} // Isobar namespace.
} // End of Isobar namespace. #endif // PY_NET_EXTERNAL_COMPONENTS_H
# endif

View File

@ -58,6 +58,8 @@
hurricane/viewer/HierarchyCommand.h hurricane/viewer/HierarchyCommand.h
hurricane/viewer/SelectorCriterion.h hurricane/viewer/SelectorCriterion.h
hurricane/viewer/CellWidgets.h hurricane/viewer/CellWidgets.h
hurricane/viewer/DesignBlob.h
hurricane/viewer/JsonConfiguration.h
) )
set( pyIncludes hurricane/viewer/PyHSVr.h set( pyIncludes hurricane/viewer/PyHSVr.h
hurricane/viewer/PyDrawingStyle.h hurricane/viewer/PyDrawingStyle.h
@ -114,6 +116,8 @@
DisplayFilterWidget.cpp DisplayFilterWidget.cpp
ControllerWidget.cpp ControllerWidget.cpp
ScriptWidget.cpp ScriptWidget.cpp
DesignBlob.cpp
JsonConfiguration.cpp
) )
set( pyCpps PyHSVr.cpp set( pyCpps PyHSVr.cpp
PyDrawingStyle.cpp PyDrawingStyle.cpp

View File

@ -69,7 +69,7 @@ namespace Hurricane {
setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea ); setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
setCentralWidget( _cellWidget ); setCentralWidget( _cellWidget );
_palette->build (); _palette->readGraphics ();
_cellWidget->bindToPalette( _palette ); _cellWidget->bindToPalette( _palette );
_cellWidget->refresh(); _cellWidget->refresh();

View File

@ -76,7 +76,7 @@ namespace Hurricane {
setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea ); setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
setCentralWidget( _cellWidget ); setCentralWidget( _cellWidget );
_palette->build (); _palette->readGraphics ();
_cellWidget->bindToPalette( _palette ); _cellWidget->bindToPalette( _palette );
_cellWidget->refresh(); _cellWidget->refresh();

View File

@ -36,7 +36,6 @@
#include "hurricane/DataBase.h" #include "hurricane/DataBase.h"
#include "hurricane/Library.h" #include "hurricane/Library.h"
#include "hurricane/Cell.h" #include "hurricane/Cell.h"
#include "hurricane/DesignBlob.h"
//#include "MapView.h" //#include "MapView.h"
#include "hurricane/isobar/PyCell.h" #include "hurricane/isobar/PyCell.h"
#include "hurricane/viewer/Script.h" #include "hurricane/viewer/Script.h"
@ -49,6 +48,7 @@
#include "hurricane/viewer/ScriptWidget.h" #include "hurricane/viewer/ScriptWidget.h"
#include "hurricane/viewer/ExceptionWidget.h" #include "hurricane/viewer/ExceptionWidget.h"
#include "hurricane/viewer/GotoWidget.h" #include "hurricane/viewer/GotoWidget.h"
#include "hurricane/viewer/DesignBlob.h"
#include "hurricane/viewer/OpenBlobDialog.h" #include "hurricane/viewer/OpenBlobDialog.h"
#include "hurricane/viewer/SelectCommand.h" #include "hurricane/viewer/SelectCommand.h"
#include "hurricane/viewer/PyCellViewer.h" #include "hurricane/viewer/PyCellViewer.h"
@ -727,9 +727,15 @@ namespace Hurricane {
QString blobName; QString blobName;
if (OpenBlobDialog::runDialog(this,blobName)) { if (OpenBlobDialog::runDialog(this,blobName)) {
string fileName = blobName.toStdString() + ".blob"; string fileName = blobName.toStdString() + ".blob";
DebugSession::open( 50 ); //DebugSession::open( 50 );
Cell* topCell = jsonBlobParse( fileName );
DebugSession::close(); Cell* topCell = NULL;
DesignBlob* blob = DesignBlob::fromJson( fileName );
if (blob) topCell = blob->getTopCell();
delete blob;
//DebugSession::close();
setCell ( topCell ); setCell ( topCell );
emit cellLoadedFromDisk( topCell ); emit cellLoadedFromDisk( topCell );

View File

@ -1080,9 +1080,6 @@ namespace Hurricane {
setMouseTracking ( true ); setMouseTracking ( true );
//_mapView = new MapView ( this ); //_mapView = new MapView ( this );
DataBase* database = DataBase::getDB();
if ( database )
_technology = database->getTechnology ();
QFont font = Graphics::getNormalFont(); QFont font = Graphics::getNormalFont();
_textFontHeight = QFontMetrics(font).ascent(); _textFontHeight = QFontMetrics(font).ascent();
@ -1270,17 +1267,21 @@ namespace Hurricane {
void CellWidget::_redraw ( QRect redrawArea ) void CellWidget::_redraw ( QRect redrawArea )
{ {
// cerr << "CellWidget::redraw() - start " //cerr << "CellWidget::redraw() - start "
// << _selectionHasChanged << " filter:" // << _selectionHasChanged << " filter:"
// << _state->getQueryFilter() << endl; // << _state->getQueryFilter() << endl;
// static bool timedout; //static bool timedout;
// static Timer timer; //static Timer timer;
if ( not isVisible() ) return; if ( not isVisible() ) return;
// timer.start (); DataBase* database = DataBase::getDB();
// timedout = false; if ( database ) _technology = database->getTechnology ();
//timer.start ();
//timedout = false;
_cellChanged = false; _cellChanged = false;
_redrawRectCount = 0; _redrawRectCount = 0;
@ -1409,26 +1410,26 @@ namespace Hurricane {
popCursor (); popCursor ();
repaint (); repaint ();
// timer.stop (); //timer.stop ();
// cerr << "CellWidget::redraw() - " << _redrawRectCount //cerr << "CellWidget::redraw() - " << _redrawRectCount
// << " in " << timer.getCombTime() << "s (" // << " in " << timer.getCombTime() << "s ("
// << setprecision(3) << (timer.getCombTime()/_redrawRectCount) << " s/r)"; // << setprecision(3) << (timer.getCombTime()/_redrawRectCount) << " s/r)";
// if ( _drawingQuery.getGoCount() ) //if ( _drawingQuery.getGoCount() )
// cerr << " " << _drawingQuery.getGoCount() // cerr << " " << _drawingQuery.getGoCount()
// << " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getGoCount()) << " s/go)"; // << " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getGoCount()) << " s/go)";
// else //else
// cerr << " 0 Gos"; // cerr << " 0 Gos";
// if ( _drawingQuery.getExtensionGoCount() ) //if ( _drawingQuery.getExtensionGoCount() )
// cerr << " " << _drawingQuery.getExtensionGoCount() // cerr << " " << _drawingQuery.getExtensionGoCount()
// << " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getExtensionGoCount()) << " s/ego)"; // << " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getExtensionGoCount()) << " s/ego)";
// else //else
// cerr << " 0 eGos"; // cerr << " 0 eGos";
// if ( _drawingQuery.getInstanceCount() ) //if ( _drawingQuery.getInstanceCount() )
// cerr << " " << _drawingQuery.getInstanceCount() // cerr << " " << _drawingQuery.getInstanceCount()
// << " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getInstanceCount()) << " s/inst)"; // << " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getInstanceCount()) << " s/inst)";
// else //else
// cerr << " 0 Instances"; // cerr << " 0 Instances";
// cerr << endl; //cerr << endl;
} }

View File

@ -73,6 +73,10 @@ namespace Hurricane {
{ } { }
void ControllerTab::graphicsUpdated ()
{ }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::TabGraphics". // Class : "Hurricane::TabGraphics".
@ -99,6 +103,10 @@ namespace Hurricane {
} }
void TabGraphics::graphicsUpdated ()
{ _graphics->rereadGraphics(); }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::TabDisplayFilter". // Class : "Hurricane::TabDisplayFilter".
@ -135,7 +143,6 @@ namespace Hurricane {
{ {
//_palette->setOneColumn (); //_palette->setOneColumn ();
_palette->setObjectName ( "controller.tabPalette.palette" ); _palette->setObjectName ( "controller.tabPalette.palette" );
_palette->build ();
//_palette->setSectionVisible ( "Viewer", false ); //_palette->setSectionVisible ( "Viewer", false );
QVBoxLayout* wLayout = new QVBoxLayout (); QVBoxLayout* wLayout = new QVBoxLayout ();
@ -159,6 +166,10 @@ namespace Hurricane {
} }
void TabPalette::graphicsUpdated ()
{ _palette->rereadGraphics(); }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "Hurricane::TabNetlist". // Class : "Hurricane::TabNetlist".
@ -489,6 +500,7 @@ namespace Hurricane {
TabSettings::TabSettings ( QWidget* parent ) TabSettings::TabSettings ( QWidget* parent )
: ControllerTab (parent) : ControllerTab (parent)
, _timestamp (0)
, _configuration(Configuration::get()->buildWidget(ConfigurationWidget::Embedded)) , _configuration(Configuration::get()->buildWidget(ConfigurationWidget::Embedded))
{ {
setContentsMargins ( 5, 0, 5, 5 ); setContentsMargins ( 5, 0, 5, 5 );
@ -506,6 +518,25 @@ namespace Hurricane {
{ } { }
void TabSettings::showEvent ( QShowEvent* )
{
Configuration* conf = Configuration::get();
if (_timestamp < conf->getLayout().getTimestamp()) {
_timestamp = conf->getLayout().getTimestamp();
QLayoutItem* child = NULL;
while ( (child = layout()->takeAt(0)) != 0 ) {
layout()->removeWidget( child->widget() );
delete child->widget();
}
_configuration = conf->buildWidget( ConfigurationWidget::Embedded );
layout()->addWidget ( _configuration );
}
}
// TabSettings::TabSettings ( QWidget* parent ) // TabSettings::TabSettings ( QWidget* parent )
// : ControllerTab(parent) // : ControllerTab(parent)
// , _settings(new QTabWidget()) // , _settings(new QTabWidget())
@ -527,6 +558,7 @@ namespace Hurricane {
ControllerWidget::ControllerWidget ( QWidget* parent ) ControllerWidget::ControllerWidget ( QWidget* parent )
: QTabWidget (parent) : QTabWidget (parent)
, _observer (this)
, _cellWidget (NULL) , _cellWidget (NULL)
, _tabGraphics (new TabGraphics()) , _tabGraphics (new TabGraphics())
, _tabPalette (new TabPalette()) , _tabPalette (new TabPalette())
@ -571,6 +603,8 @@ namespace Hurricane {
connect( _tabSelection->getSelection(), SIGNAL(inspect(Occurrence&)) connect( _tabSelection->getSelection(), SIGNAL(inspect(Occurrence&))
, _tabInspector , SLOT (setSelectionOccurrence(Occurrence&)) ); , _tabInspector , SLOT (setSelectionOccurrence(Occurrence&)) );
Graphics::getGraphics()->addObserver( &_observer );
resize( Graphics::toHighDpi(600), Graphics::toHighDpi(500) ); resize( Graphics::toHighDpi(600), Graphics::toHighDpi(500) );
} }
@ -617,4 +651,22 @@ namespace Hurricane {
} }
void ControllerWidget::graphicsUpdated ()
{
for ( int i=0 ; i<count() ; ++i )
(static_cast<ControllerTab*>(widget(i)))->graphicsUpdated ();
}
// -------------------------------------------------------------------
// Class : "ControllerWidget::GraphicsObserver".
void ControllerWidget::GraphicsObserver::notify ( unsigned int flags )
{
ControllerWidget* controller = getOwner();
if (flags & Graphics::ChangedDisplayStyles) {
controller->graphicsUpdated();
}
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -15,9 +15,13 @@
#include <iostream> #include <iostream>
#include "hurricane/JsonReader.h"
#include "hurricane/UpdateSession.h"
#include "hurricane/DataBase.h" #include "hurricane/DataBase.h"
#include "hurricane/Cell.h" #include "hurricane/Cell.h"
#include "hurricane/DesignBlob.h" #include "hurricane/viewer/Graphics.h"
#include "hurricane/viewer/DesignBlob.h"
#include "hurricane/viewer/JsonParameter.h"
namespace Hurricane { namespace Hurricane {
@ -32,13 +36,30 @@ namespace Hurricane {
void DesignBlob::toJson( JsonWriter* w ) const void DesignBlob::toJson( JsonWriter* w ) const
{ {
w->startObject(); w->startObject();
jsonWrite( w, "@typename", _getTypeName() ); jsonWrite( w, "@typename" , _getTypeName() );
jsonWrite( w, "_topCell" , getTopCell()->getHierarchicalName() ); jsonWrite( w, "_topCell" , getTopCell()->getHierarchicalName() );
jsonWrite( w, "_database", DataBase::getDB() ); jsonWrite( w, "_database" , DataBase::getDB() );
jsonWrite( w, "_graphics" , Graphics::getGraphics() );
jsonWrite( w, "_configuration", Cfg::Configuration::get() );
w->endObject(); w->endObject();
} }
DesignBlob* DesignBlob::fromJson ( const string& filename )
{
UpdateSession::open();
JsonReader reader ( JsonWriter::DesignBlobMode );
reader.parse( filename );
UpdateSession::close();
const JsonStack& stack = reader.getStack();
if (stack.rhas(".DesignBlob")) return stack.as<DesignBlob*>(".DesignBlob");
return NULL;
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Class : "JsonDesignBlob". // Class : "JsonDesignBlob".
@ -55,7 +76,9 @@ namespace Hurricane {
ltrace(51) << "JsonDesignblob::JsonDesignblob()" << endl; ltrace(51) << "JsonDesignblob::JsonDesignblob()" << endl;
add( "_topCell" , typeid(string) ); add( "_topCell" , typeid(string) );
add( "_database", typeid(DataBase*) ); add( "_database" , typeid(DataBase*) );
add( "_graphics" , typeid(Graphics*) );
add( "_configuration", typeid(Cfg::Configuration*) );
} }

View File

@ -1,8 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | H U R R I C A N E | // | H U R R I C A N E |
@ -49,6 +48,8 @@ namespace Hurricane {
const Name DisplayStyle::Undef = "undef"; const Name DisplayStyle::Undef = "undef";
// -------------------------------------------------------------------
// Class : "RawDrawingStyle".
RawDrawingStyle::RawDrawingStyle ( const Name& name RawDrawingStyle::RawDrawingStyle ( const Name& name
, const string& pattern , const string& pattern
@ -73,6 +74,15 @@ namespace Hurricane {
{ } { }
RawDrawingStyle::~RawDrawingStyle ()
{
if ( _color ) {
delete _color;
delete _pen;
delete _brush;
}
}
DrawingStyle RawDrawingStyle::create ( const Name& name DrawingStyle RawDrawingStyle::create ( const Name& name
, const string& pattern , const string& pattern
@ -149,15 +159,113 @@ namespace Hurricane {
} }
RawDrawingStyle::~RawDrawingStyle () void RawDrawingStyle::toJson ( JsonWriter* w ) const
{ {
if ( _color ) { w->startObject();
delete _color; jsonWrite( w, "@typename", "DrawingStyle" );
delete _pen; jsonWrite( w, "_name" , _name );
delete _brush; jsonWrite( w, "_red" , _red );
jsonWrite( w, "_green" , _green );
jsonWrite( w, "_blue" , _blue );
jsonWrite( w, "_borderWidth", _borderWidth );
jsonWrite( w, "_pattern" , _pattern );
jsonWrite( w, "_threshold" , _threshold );
jsonWrite( w, "_goMatched" , _goMatched );
w->endObject();
}
// -------------------------------------------------------------------
// Class : "JsonDrawingStyle".
Initializer<JsonDrawingStyle> jsonDrawingStyleInit ( 0 );
void JsonDrawingStyle::initialize ()
{ JsonTypes::registerType( new JsonDrawingStyle (JsonWriter::RegisterMode) ); }
JsonDrawingStyle::JsonDrawingStyle ( unsigned long flags )
: JsonObject(flags)
{
if (flags & JsonWriter::RegisterMode) return;
add( ".DrawingGroup", typeid(DrawingGroup) );
add( "_name" , typeid(string) );
add( "_red" , typeid(int64_t) );
add( "_green" , typeid(int64_t) );
add( "_blue" , typeid(int64_t) );
add( "_borderWidth" , typeid(int64_t) );
add( "_pattern" , typeid(string) );
add( "_threshold" , typeid(double) );
add( "_goMatched" , typeid(bool) );
}
JsonDrawingStyle::~JsonDrawingStyle ()
{ }
string JsonDrawingStyle::getTypeName () const
{ return "DrawingStyle"; }
JsonDrawingStyle* JsonDrawingStyle::clone ( unsigned long flags ) const
{ return new JsonDrawingStyle ( flags ); }
void JsonDrawingStyle::toData(JsonStack& stack)
{
ltracein(51);
check( stack, "JsonDrawingStyle::toData" );
DrawingGroup* dg = get<DrawingGroup*>( stack, ".DrawingGroup" );
DrawingStyle ds;
if (not dg) return;
string name = get<string> ( stack, "_name" );
int red = get<int64_t>( stack, "_red" );
int green = get<int64_t>( stack, "_green" );
int blue = get<int64_t>( stack, "_blue" );
int borderWidth = get<int64_t>( stack, "_borderWidth" );
string pattern = get<string> ( stack, "_pattern" );
float threshold = get<double> ( stack, "_threshold" );
bool goMatched = get<bool> ( stack, "_goMatched" );
if (stack.issetFlags(JsonWriter::TechnoMode)) {
// Actual creation.
ds = RawDrawingStyle::create( name
, pattern
, red
, green
, blue
, borderWidth
, threshold
, goMatched
);
dg->addDrawingStyle( ds );
if (Graphics::isEnabled()) dg->qtAllocate();
} else {
// Check coherency with existing DrawingStyle.
ds = dg->find( name );
if (ds == nullptr) {
cerr << Error( "JsonDrawingStyle::toData(): No DrawingStyle \"%s\" in the existing DisplayStyle."
, name.c_str()
) << endl;
} }
} }
update( stack, NULL );
ltraceout(51);
}
// -------------------------------------------------------------------
// Class : "DrawingGroup".
DrawingGroup::DrawingGroup ( const Name& name ) DrawingGroup::DrawingGroup ( const Name& name )
: _name (name) : _name (name)
@ -208,6 +316,17 @@ namespace Hurricane {
} }
void DrawingGroup::addDrawingStyle ( DrawingStyle ds )
{
size_t i = findIndex ( ds->getName() );
if ( i != InvalidIndex ) {
_drawingStyles[i] = ds;
} else {
_drawingStyles.push_back ( ds );
}
}
DrawingStyle DrawingGroup::addDrawingStyle ( const Name& key DrawingStyle DrawingGroup::addDrawingStyle ( const Name& key
, const string& pattern , const string& pattern
, int red , int red
@ -230,6 +349,91 @@ namespace Hurricane {
} }
void DrawingGroup::toJson ( JsonWriter* w ) const
{
w->startObject();
jsonWrite( w, "@typename", "DrawingGroup" );
jsonWrite( w, "_name", _name );
w->key( "+drawingStyles" );
w->startArray();
for ( DrawingStyle ds : _drawingStyles ) ds->toJson( w );
w->endArray();
w->endObject();
}
// -------------------------------------------------------------------
// Class : "JsonDrawingGroup".
Initializer<JsonDrawingGroup> jsonDrawingGroupInit ( 0 );
void JsonDrawingGroup::initialize ()
{ JsonTypes::registerType( new JsonDrawingGroup (JsonWriter::RegisterMode) ); }
JsonDrawingGroup::JsonDrawingGroup ( unsigned long flags )
: JsonObject(flags)
{
if (flags & JsonWriter::RegisterMode) return;
add( ".DisplayStyle" , typeid(DisplayStyle*) );
add( "_name" , typeid(string) );
add( "+drawingStyles", typeid(JsonArray) );
}
JsonDrawingGroup::~JsonDrawingGroup ()
{ }
string JsonDrawingGroup::getTypeName () const
{ return "DrawingGroup"; }
JsonDrawingGroup* JsonDrawingGroup::clone ( unsigned long flags ) const
{ return new JsonDrawingGroup ( flags ); }
void JsonDrawingGroup::toData(JsonStack& stack)
{
ltracein(51);
check( stack, "JsonDrawingGroup::toData" );
DisplayStyle* ds = get<DisplayStyle*>( stack, ".DisplayStyle" );
DrawingGroup* dg = NULL;
if (not ds) return;
string name = get<string>( stack, "_name" );
if (stack.issetFlags(JsonWriter::TechnoMode)) {
// Actual creation.
size_t gi = 0;
ds->findOrCreate( name, gi );
dg = ds->findGroup( name );
} else {
// Check coherency with existing DrawingGroup.
dg = ds->findGroup( name );
if (dg == NULL) {
cerr << Error( "JsonDrawingGroup::toData(): No DrawingGroup \"%s\" in the existing DisplayStyle."
, name.c_str()
) << endl;
}
}
update( stack, dg );
ltraceout(51);
}
// -------------------------------------------------------------------
// Class : "DisplayStyle".
QColor DisplayStyle::darken ( const QColor& color, const DisplayStyle::HSVr& darkening ) QColor DisplayStyle::darken ( const QColor& color, const DisplayStyle::HSVr& darkening )
{ {
QColor hsvColor = color.toHsv(); QColor hsvColor = color.toHsv();
@ -332,6 +536,16 @@ namespace Hurricane {
} }
DrawingGroup* DisplayStyle::findGroup ( const Name& groupKey )
{
for ( size_t gi=0 ; gi < _groups.size() ; gi++ ) {
if ( _groups[gi]->getName() == groupKey )
return _groups[gi];
}
return NULL;
}
void DisplayStyle::findOrCreate ( const Name& groupKey, size_t& gi ) void DisplayStyle::findOrCreate ( const Name& groupKey, size_t& gi )
{ {
for ( gi=0 ; gi < _groups.size() ; gi++ ) { for ( gi=0 ; gi < _groups.size() ; gi++ ) {
@ -428,4 +642,143 @@ namespace Hurricane {
} }
} void DisplayStyle::toJson ( JsonWriter* w ) const
{
w->startObject();
jsonWrite( w, "@typename", "DisplayStyle" );
jsonWrite( w, "_name" , _name );
jsonWrite( w, "_description", _description );
jsonWrite( w, "_darkening" , &_darkening );
w->key( "+groups" );
w->startArray();
for ( DrawingGroup* dg : _groups ) dg->toJson( w );
w->endArray();
w->endObject();
}
// -------------------------------------------------------------------
// Class : "JsonDisplayStyle".
Initializer<JsonDisplayStyle> jsonDisplayStyleInit ( 0 );
void JsonDisplayStyle::initialize ()
{ JsonTypes::registerType( new JsonDisplayStyle (JsonWriter::RegisterMode) ); }
JsonDisplayStyle::JsonDisplayStyle ( unsigned long flags )
: JsonObject(flags)
{
if (flags & JsonWriter::RegisterMode) return;
add( "_name" , typeid(string) );
add( "_description", typeid(string) );
add( "_darkening" , typeid(DisplayStyle::HSVr) );
add( "+groups" , typeid(JsonArray) );
}
JsonDisplayStyle::~JsonDisplayStyle ()
{ }
string JsonDisplayStyle::getTypeName () const
{ return "DisplayStyle"; }
JsonDisplayStyle* JsonDisplayStyle::clone ( unsigned long flags ) const
{ return new JsonDisplayStyle ( flags ); }
void JsonDisplayStyle::toData(JsonStack& stack)
{
ltracein(51);
check( stack, "JsonDisplayStyle::toData" );
Graphics* graphics = get<Graphics*>( stack, "_graphics" );
DisplayStyle* ds = NULL;
if (not graphics) return;
string name = get<string> ( stack, "_name" );
string description = get<string> ( stack, "_description" );
DisplayStyle::HSVr* darkening = get<DisplayStyle::HSVr*>( stack, "_darkening" );
if (stack.issetFlags(JsonWriter::TechnoMode)) {
// Actual creation.
ds = new DisplayStyle ( name );
ds->setDescription( description );
ds->setDarkening ( *darkening );
graphics->addStyle( ds );
} else {
// Check coherency with existing DisplayStyle.
ds = Graphics::getStyle( name );
if (ds == NULL) {
cerr << Error( "JsonDisplayStyle::toData(): No DisplayStyle \"%s\" in the existing DisplayStyle."
, name.c_str()
) << endl;
}
}
update( stack, ds );
ltraceout(51);
}
// -------------------------------------------------------------------
// Class : "JsonHSVr".
Initializer<JsonHSVr> jsonHSVrInit ( 0 );
void JsonHSVr::initialize ()
{ JsonTypes::registerType( new JsonHSVr (JsonWriter::RegisterMode) ); }
JsonHSVr::JsonHSVr ( unsigned long flags )
: JsonObject(flags)
{
if (flags & JsonWriter::RegisterMode) return;
add( "_hue" , typeid(double) );
add( "_saturation", typeid(double) );
add( "_value" , typeid(double) );
}
JsonHSVr::~JsonHSVr ()
{ }
string JsonHSVr::getTypeName () const
{ return "HSVr"; }
JsonHSVr* JsonHSVr::clone ( unsigned long flags ) const
{ return new JsonHSVr ( flags ); }
void JsonHSVr::toData(JsonStack& stack)
{
ltracein(51);
check( stack, "JsonHSVr::toData" );
double hue = get<double>( stack, "_hue" );
double saturation = get<double>( stack, "_saturation" );
double value = get<double>( stack, "_value" );
DisplayStyle::HSVr* hsvr = new DisplayStyle::HSVr(hue,saturation,value);
update( stack, hsvr );
ltraceout(51);
}
} // Hurricane namespace.

View File

@ -34,7 +34,8 @@ namespace Hurricane {
Graphics::Graphics () Graphics::Graphics ()
: _htmlTranslator () : _observers ()
, _htmlTranslator ()
, _styles () , _styles ()
, _active (NULL) , _active (NULL)
, _fireColorScale () , _fireColorScale ()
@ -70,6 +71,18 @@ namespace Hurricane {
} }
void Graphics::addObserver ( BaseObserver* observer )
{ getGraphics()->_observers.addObserver( observer ); }
void Graphics::removeObserver ( BaseObserver* observer )
{ getGraphics()->_observers.removeObserver( observer ); }
void Graphics::notify ( unsigned flags )
{ getGraphics()->_observers.notify( flags ); }
Graphics* Graphics::getGraphics () Graphics* Graphics::getGraphics ()
{ {
if (not _singleton) { if (not _singleton) {
@ -351,6 +364,70 @@ namespace Hurricane {
} }
void Graphics::toJson ( JsonWriter* w ) const
{
w->startObject();
jsonWrite( w, "@typename", "Graphics" );
jsonWrite( w, "_active" , _active->getName() );
w->key( "+styles" );
w->startArray();
for ( DisplayStyle* ds : _styles ) ds->toJson( w );
w->endArray();
w->endObject();
}
// -------------------------------------------------------------------
// Class : "JsonGraphics".
Initializer<JsonGraphics> jsonGraphicsInit ( 0 );
void JsonGraphics::initialize ()
{ JsonTypes::registerType( new JsonGraphics (JsonWriter::RegisterMode) ); }
JsonGraphics::JsonGraphics ( unsigned long flags )
: JsonObject(flags)
, _active ()
{
if (flags & JsonWriter::RegisterMode) return;
add( "_active", typeid(string) );
add( "+groups", typeid(JsonArray) );
}
JsonGraphics::~JsonGraphics ()
{
Graphics* graphics = Graphics::getGraphics();
graphics->setStyle( _active );
graphics->notify ( Graphics::ChangedDisplayStyles );
}
string JsonGraphics::getTypeName () const
{ return "Graphics"; }
JsonGraphics* JsonGraphics::clone ( unsigned long flags ) const
{ return new JsonGraphics ( flags ); }
void JsonGraphics::toData(JsonStack& stack)
{
ltracein(51);
check( stack, "JsonGraphics::toData" );
_active = get<string>( stack, "_active" );
update( stack, Graphics::getGraphics() );
ltraceout(51);
}
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -35,17 +35,32 @@ namespace Hurricane {
GraphicsWidget::GraphicsWidget ( QWidget* parent ) GraphicsWidget::GraphicsWidget ( QWidget* parent )
: QWidget (parent) : QWidget (parent)
, _cellWidget (NULL) , _cellWidget (NULL)
, _stylesGrid (new QGridLayout())
, _stylesGroup(new QButtonGroup())
, _updateState(ExternalEmit) , _updateState(ExternalEmit)
{ {
setAttribute ( Qt::WA_QuitOnClose, false ); setAttribute ( Qt::WA_QuitOnClose, false );
setWindowTitle ( tr("Display Styles") ); setWindowTitle ( tr("Display Styles") );
setFont ( Graphics::getNormalFont(true) ); setFont ( Graphics::getNormalFont(true) );
QButtonGroup* group = new QButtonGroup ();
QGroupBox* groupBox = new QGroupBox ( tr("Display Styles") ); QGroupBox* groupBox = new QGroupBox ( tr("Display Styles") );
QGridLayout* gLayout = new QGridLayout ();
QVBoxLayout* wLayout = new QVBoxLayout (); QVBoxLayout* wLayout = new QVBoxLayout ();
if (Graphics::isHighDpi()) _stylesGrid->setContentsMargins( 30, 30, 30, 30 );
groupBox->setLayout ( _stylesGrid );
wLayout->addWidget ( groupBox );
wLayout->addStretch ();
setLayout ( wLayout );
connect ( _stylesGroup, SIGNAL(buttonClicked(int)), this, SLOT(setStyle(int)) );
readGraphics ();
}
void GraphicsWidget::readGraphics ()
{
const vector<DisplayStyle*>& styles = Graphics::getStyles (); const vector<DisplayStyle*>& styles = Graphics::getStyles ();
DisplayStyle* activeStyle = Graphics::getStyle (); DisplayStyle* activeStyle = Graphics::getStyle ();
@ -59,18 +74,10 @@ namespace Hurricane {
label->setText ( styles[istyle]->getDescription().c_str() ); label->setText ( styles[istyle]->getDescription().c_str() );
label->setFont ( Graphics::getNormalFont() ); label->setFont ( Graphics::getNormalFont() );
gLayout->addWidget ( button, istyle-hideFallback, 0 ); _stylesGrid ->addWidget ( button, istyle-hideFallback, 0 );
gLayout->addWidget ( label , istyle-hideFallback, 1 ); _stylesGrid ->addWidget ( label , istyle-hideFallback, 1 );
group->addButton ( button, istyle ); _stylesGroup->addButton ( button, istyle );
} }
if (Graphics::isHighDpi()) gLayout->setContentsMargins( 30, 30, 30, 30 );
groupBox->setLayout ( gLayout );
wLayout->addWidget ( groupBox );
wLayout->addStretch ();
setLayout ( wLayout );
connect ( group, SIGNAL(buttonClicked(int)), this, SLOT(setStyle(int)) );
} }
@ -109,5 +116,22 @@ namespace Hurricane {
} }
void GraphicsWidget::resetGraphics ()
{
QLayoutItem* child = NULL;
while ( (child = _stylesGrid->takeAt(0)) != 0 ) {
_stylesGrid->removeWidget( child->widget() );
delete child->widget();
}
}
}
void GraphicsWidget::rereadGraphics ()
{
resetGraphics();
readGraphics();
//setStyle( 0 );
}
} // Hurricane namespace.

View File

@ -0,0 +1,523 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2016-2016, 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 : "./JsonConfiguration.cpp" |
// +-----------------------------------------------------------------+
#include "vlsisapd/configuration/LayoutDescription.h"
#include "hurricane/Error.h"
#include "hurricane/viewer/JsonConfiguration.h"
void jsonWrite ( JsonWriter* w, const Cfg::Parameter* p )
{
w->startObject();
jsonWrite( w, "@typename", "Cfg::Parameter" );
jsonWrite( w, "_id" , p->getId() );
jsonWrite( w, "_type" , Cfg::Parameter::typeToString(p->getType()) );
jsonWrite( w, "_priority", Cfg::Parameter::priorityToString(p->getPriority()) );
jsonWrite( w, "_value" , p->asString() );
jsonWrite( w, "_flags" , p->getFlags() );
if (p->getType() == Cfg::Parameter::Int) {
if (p->hasMin()) jsonWrite( w, "_minInt", p->getMinInt() );
if (p->hasMax()) jsonWrite( w, "_maxInt", p->getMaxInt() );
}
if (p->getType() == Cfg::Parameter::Double) {
if (p->hasMin()) jsonWrite( w, "_minDouble", p->getMinDouble() );
if (p->hasMax()) jsonWrite( w, "_maxDouble", p->getMaxDouble() );
}
jsonWrite( w, "+values", p->getValues() );
w->key( "+slaves" );
w->startArray();
for ( std::string slave : p->getSlaves() ) {
w->startObject();
jsonWrite( w, "@typename", "Cfg::Parameter::Slave" );
jsonWrite( w, "_id" , slave );
w->endObject();
}
w->endArray();
w->endObject();
}
void jsonWrite ( JsonWriter* w, const Cfg::Parameter::EnumValue v )
{
w->startObject();
jsonWrite( w, "@typename", "Cfg::Parameter::EnumValue" );
jsonWrite( w, "_label" , v._label );
jsonWrite( w, "_value" , v._value );
w->endObject();
}
void jsonWrite ( JsonWriter* w, const Cfg::Configuration* cfg )
{
w->startObject();
jsonWrite( w, "@typename" , "Cfg::Configuration" );
jsonWrite( w, "+parameters", cfg->getParameters() );
jsonWrite( w, "+layout" , &cfg->getLayout () );
w->endObject();
}
void jsonWrite ( JsonWriter* w, const Cfg::WidgetDescription* widget )
{
w->startObject();
jsonWrite( w, "@typename", "Cfg::WidgetDescription" );
jsonWrite( w, "_type" , Cfg::WidgetDescription::typeToString(widget->getType()) );
jsonWrite( w, "_id" , widget->getId () );
jsonWrite( w, "_label" , widget->getLabel () );
jsonWrite( w, "_column" , widget->getColumn() );
jsonWrite( w, "_span" , widget->getSpan () );
jsonWrite( w, "_flags" , widget->getFlags () );
w->endObject();
}
void jsonWrite ( JsonWriter* w, const Cfg::TabDescription* tab )
{
w->startObject();
jsonWrite( w, "@typename", "Cfg::TabDescription" );
jsonWrite( w, "_name" , tab->getName() );
jsonWrite( w, "_id" , tab->getId() );
jsonWrite( w, "+widgets" , tab->getWidgets() );
w->endObject();
}
void jsonWrite ( JsonWriter* w, const Cfg::LayoutDescription* layout )
{
w->startObject();
jsonWrite( w, "@typename", "Cfg::LayoutDescription" );
jsonWrite( w, "+tabs" , layout->getTabs() );
w->endObject();
}
namespace Hurricane {
using Cfg::Parameter;
using Cfg::Configuration;
using Cfg::LayoutDescription;
using Cfg::TabDescription;
using Cfg::WidgetDescription;
// -------------------------------------------------------------------
// Class : "JsonConfiguration"
Initializer<JsonConfiguration> jsonConfigurationInit ( 0 );
void JsonConfiguration::initialize ()
{ JsonTypes::registerType( new JsonConfiguration (JsonWriter::RegisterMode) ); }
JsonConfiguration::JsonConfiguration( unsigned long flags )
: JsonObject(flags)
{
add( "+parameters", typeid(JsonArray) );
}
string JsonConfiguration::getTypeName () const
{ return "Cfg::Configuration"; }
JsonConfiguration* JsonConfiguration::clone ( unsigned long flags ) const
{ return new JsonConfiguration ( flags ); }
void JsonConfiguration::toData ( JsonStack& stack )
{
check( stack, "JsonConfiguration::toData" );
Configuration* cfg = Configuration::get();
update( stack, cfg );
}
// -------------------------------------------------------------------
// Class : "JsonParameter"
Initializer<JsonParameter> jsonParameterInit ( 0 );
void JsonParameter::initialize ()
{ JsonTypes::registerType( new JsonParameter (JsonWriter::RegisterMode) ); }
JsonParameter::JsonParameter ( unsigned long flags )
: JsonObject(flags)
{
add( "_id" , typeid(string) );
add( "_type" , typeid(string) );
add( "_priority", typeid(string) );
add( "_value" , typeid(string) );
add( "_flags" , typeid(int64_t) );
add( "+values" , typeid(JsonArray) );
add( "+slaves" , typeid(JsonArray) );
}
string JsonParameter::getTypeName () const
{ return "Cfg::Parameter"; }
JsonParameter* JsonParameter::clone ( unsigned long flags ) const
{ return new JsonParameter ( flags ); }
void JsonParameter::toData ( JsonStack& stack )
{
check( stack, "JsonParameter::toData" );
Configuration* cfg = get<Configuration*>( stack, "_configuration" );
Parameter* param = NULL;
string id = get<string> ( stack, "_id" );
string stype = get<string> ( stack, "_type" );
string spriority = get<string> ( stack, "_priority" );
string value = get<string> ( stack, "_value" );
int flags = get<int64_t>( stack, "_flags" );
Parameter::Type type = Parameter::stringToType (stype);
Parameter::Priority priority = Parameter::stringToPriority(spriority);
param = cfg->getParameter( id );
if (not param) {
param = cfg->addParameter( id, type, value, priority );
} else {
if (param->getType() != type) {
cerr << Error( "JsonParameter::toData(): Type incoherency on parameter \"%s\", not restored."
, id.c_str() ) << endl;
}
param->setRawString( value, Parameter::Interactive );
param->setPriority( priority );
}
if (type == Parameter::Int) {
if (flags & Parameter::HasMin) {
add( "_minInt", typeid(int64_t) );
param->setMin( (int)get<int64_t>( stack, "_minInt" ), Parameter::Interactive );
}
if (flags & Parameter::HasMax) {
add( "_maxInt", typeid(int64_t) );
param->setMax( (int)get<int64_t>( stack, "_maxInt" ), Parameter::Interactive );
}
}
if (type == Parameter::Double) {
if (flags & Parameter::HasMin) {
add( "_minDouble", typeid(int64_t) );
param->setMin( (double)get<int64_t>( stack, "_minDouble" ), Parameter::Interactive );
}
if (flags & Parameter::HasMax) {
add( "_maxDouble", typeid(int64_t) );
param->setMax( (double)get<int64_t>( stack, "_maxDouble" ), Parameter::Interactive );
}
}
if (param) param->valueChanged();
update( stack, param );
}
// -------------------------------------------------------------------
// Class : "JsonParamEnumValue"
Initializer<JsonParamEnumValue> jsonParamEnumValueInit ( 0 );
void JsonParamEnumValue::initialize ()
{ JsonTypes::registerType( new JsonParamEnumValue (JsonWriter::RegisterMode) ); }
JsonParamEnumValue::JsonParamEnumValue ( unsigned long flags )
: JsonObject(flags)
{
add( "_label", typeid(string) );
add( "_value", typeid(int64_t) );
}
string JsonParamEnumValue::getTypeName () const
{ return "Cfg::Parameter::EnumValue"; }
JsonParamEnumValue* JsonParamEnumValue::clone ( unsigned long flags ) const
{ return new JsonParamEnumValue ( flags ); }
void JsonParamEnumValue::toData ( JsonStack& stack )
{
check( stack, "JsonParamEnumValue::toData" );
Parameter* param = get<Parameter*>( stack, ".Cfg::Parameter" );
string label = get<string> ( stack, "_label" );
int value = get<int64_t> ( stack, "_value" );
if (not param) {
cerr << Error( "JsonParamEnumValue::toData(): Missing \".Cfg::Parameter\" in stack context.\n"
" (while reading Cfg::Parameter::EnumValue \"%s\")"
, label.c_str()
) << endl;
} else {
if (stack.issetFlags(JsonWriter::TechnoMode)) {
param->addValue( label, value );
}
}
update( stack, NULL );
}
// -------------------------------------------------------------------
// Class : "JsonParamSlave"
Initializer<JsonParamSlave> jsonParamSlaveInit ( 0 );
void JsonParamSlave::initialize ()
{ JsonTypes::registerType( new JsonParamSlave (JsonWriter::RegisterMode) ); }
JsonParamSlave::JsonParamSlave ( unsigned long flags )
: JsonObject(flags)
{
add( "_id", typeid(string) );
}
string JsonParamSlave::getTypeName () const
{ return "Cfg::Parameter::Slave"; }
JsonParamSlave* JsonParamSlave::clone ( unsigned long flags ) const
{ return new JsonParamSlave ( flags ); }
void JsonParamSlave::toData ( JsonStack& stack )
{
check( stack, "JsonParamSlave::toData" );
Parameter* param = get<Parameter*>( stack, ".Cfg::Parameter" );
string id = get<string> ( stack, "_id " );
if (not param) {
cerr << Error( "JsonParamSlave::toData(): Missing \".Cfg::Parameter\" in stack context.\n"
" (while reading Cfg::Parameter::Slave \"%s\")"
, id.c_str()
) << endl;
} else {
if (stack.issetFlags(JsonWriter::TechnoMode)) {
param->addSlave( id );
}
}
update( stack, NULL );
}
// -------------------------------------------------------------------
// Class : "JsonWidgetDescription"
Initializer<JsonWidgetDescription> jsonWidgetDescriptionInit ( 0 );
void JsonWidgetDescription::initialize ()
{ JsonTypes::registerType( new JsonWidgetDescription (JsonWriter::RegisterMode) ); }
JsonWidgetDescription::JsonWidgetDescription ( unsigned long flags )
: JsonObject(flags)
{
add( ".Cfg::TabDescription", typeid(Cfg::TabDescription*) );
add( "_type" , typeid(string) );
add( "_id" , typeid(string) );
add( "_label" , typeid(string) );
add( "_column" , typeid(int64_t) );
add( "_span" , typeid(int64_t) );
add( "_flags" , typeid(int64_t) );
}
string JsonWidgetDescription::getTypeName () const
{ return "Cfg::WidgetDescription"; }
JsonWidgetDescription* JsonWidgetDescription::clone ( unsigned long flags ) const
{ return new JsonWidgetDescription ( flags ); }
void JsonWidgetDescription::toData ( JsonStack& stack )
{
check( stack, "JsonWidgetDescription::toData" );
LayoutDescription* layout = get<LayoutDescription*>( stack, "+layout" );
TabDescription* tab = get<TabDescription*> ( stack, ".Cfg::TabDescription" );
WidgetDescription* widget = NULL;
string stype = get<string> ( stack, "_type" );
string id = get<string> ( stack, "_id" );
string label = get<string> ( stack, "_label" );
int column = get<int64_t>( stack, "_column" );
int span = get<int64_t>( stack, "_span" );
int flags = get<int64_t>( stack, "_flags" );
WidgetDescription::Type type = WidgetDescription::stringToType(stype);
if (not layout) {
cerr << Error( "JsonWidgetDescription::toData(): Missing \"+layout\" in stack context.\n"
" (while reading \"%s\")"
, id.c_str()
) << endl;
} else if (not tab) {
cerr << Error( "JsonWidgetDescription::toData(): Missing \".Cfg::TabDescription\" in stack context.\n"
" (while reading \"%s\")"
, id.c_str()
) << endl;
} else {
if (stack.issetFlags(JsonWriter::TechnoMode)) {
switch ( type ) {
case WidgetDescription::Rule: layout->addRule ( tab->getName() ); break;
case WidgetDescription::Title: layout->addTitle ( tab->getName(), label ); break;
case WidgetDescription::Section: layout->addSection( tab->getName(), label, column ); break;
case WidgetDescription::Parameter:
layout->addParameter( tab->getName(), id, label, column, span, flags );
widget = layout->getWidget( id );
break;
}
} else {
// Coherency checking only.
if (type == WidgetDescription::Parameter) {
widget = layout->getWidget( id );
if (not widget) {
cerr << Error( "JsonWidgetDescription::toData(): Parameter id=\"%s\" has no layout."
, id.c_str() ) << endl;
}
}
}
}
update( stack, widget );
}
// -------------------------------------------------------------------
// Class : "JsonTabDescription"
Initializer<JsonTabDescription> jsonTabDescriptionInit ( 0 );
void JsonTabDescription::initialize ()
{ JsonTypes::registerType( new JsonTabDescription (JsonWriter::RegisterMode) ); }
JsonTabDescription::JsonTabDescription ( unsigned long flags )
: JsonObject(flags)
{
add( "_name" , typeid(string) );
add( "_id" , typeid(string) );
add( "+widgets", typeid(JsonArray) );
}
string JsonTabDescription::getTypeName () const
{ return "Cfg::TabDescription"; }
JsonTabDescription* JsonTabDescription::clone ( unsigned long flags ) const
{ return new JsonTabDescription ( flags ); }
void JsonTabDescription::toData ( JsonStack& stack )
{
check( stack, "JsonTabDescription::toData" );
LayoutDescription* layout = get<LayoutDescription*>( stack, "+layout" );
TabDescription* tab = NULL;
string id = get<string>( stack, "_id" );
string name = get<string>( stack, "_name" );
if (not layout) {
cerr << Error( "JsonTabDescription::toData(): Missing \"+layout\" in stack context.\n"
" (while reading TabDescription \"%s\")"
, id.c_str()
) << endl;
} else {
if (stack.issetFlags(JsonWriter::TechnoMode)) {
layout->addTab( name, id );
tab = layout->getTab( name, id );
} else {
// Coherency checking only.
tab = layout->getTab( name, id );
if (not tab) {
cerr << Error( "JsonTabDescription::toData(): Tab name=\"%s\", id=\"%s\" has no layout."
, name.c_str(), id.c_str() ) << endl;
}
}
}
update( stack, tab );
}
// -------------------------------------------------------------------
// Class : "JsonLayoutDescription"
Initializer<JsonLayoutDescription> jsonLayoutDescriptionInit ( 0 );
void JsonLayoutDescription::initialize ()
{ JsonTypes::registerType( new JsonLayoutDescription (JsonWriter::RegisterMode) ); }
JsonLayoutDescription::JsonLayoutDescription ( unsigned long flags )
: JsonObject(flags)
{
add( "+tabs", typeid(JsonArray) );
}
JsonLayoutDescription::~JsonLayoutDescription ()
{
}
string JsonLayoutDescription::getTypeName () const
{ return "Cfg::LayoutDescription"; }
JsonLayoutDescription* JsonLayoutDescription::clone ( unsigned long flags ) const
{ return new JsonLayoutDescription ( flags ); }
void JsonLayoutDescription::toData ( JsonStack& stack )
{
check( stack, "JsonLayoutDescription::toData" );
LayoutDescription* layout = &Configuration::get()->getLayout();
update( stack, layout );
}
} // Hurricane namespace.

View File

@ -0,0 +1,185 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2016-2016, 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 : "./JsonParameter.cpp" |
// +-----------------------------------------------------------------+
#include "hurricane/Error.h"
#include "hurricane/viewer/JsonParameter.h"
void jsonWrite ( JsonWriter* w, const Cfg::Configuration* cfg )
{
w->startObject();
jsonWrite( w, "@typename" , "Cfg::Configuration" );
jsonWrite( w, "+parameters", cfg->getParameters() );
// w->key( "+parameters" );
// w->startArray();
// for ( auto mapElement : cfg->getParameters() ) jsonWrite( w, mapElement.second );
// w->endArray();
w->endObject();
}
void jsonWrite ( JsonWriter* w, const Cfg::Parameter* p )
{
w->startObject();
jsonWrite( w, "@typename", "Cfg::Parameter" );
jsonWrite( w, "_id" , p->getId() );
jsonWrite( w, "_type" , Cfg::Parameter::typeToString(p->getType()) );
jsonWrite( w, "_priority", Cfg::Parameter::priorityToString(p->getPriority()) );
jsonWrite( w, "_value" , p->asString() );
jsonWrite( w, "_flags" , p->getFlags() );
if (p->getType() == Cfg::Parameter::Int) {
if (p->hasMin()) jsonWrite( w, "_minInt", p->getMinInt() );
if (p->hasMax()) jsonWrite( w, "_maxInt", p->getMaxInt() );
}
if (p->getType() == Cfg::Parameter::Double) {
if (p->hasMin()) jsonWrite( w, "_minDouble", p->getMinDouble() );
if (p->hasMax()) jsonWrite( w, "_maxDouble", p->getMaxDouble() );
}
w->endObject();
}
namespace Hurricane {
using Cfg::Parameter;
using Cfg::Configuration;
// -------------------------------------------------------------------
// Class : "JsonConfiguration"
Initializer<JsonConfiguration> jsonConfigurationInit ( 0 );
void JsonConfiguration::initialize ()
{ JsonTypes::registerType( new JsonConfiguration (JsonWriter::RegisterMode) ); }
JsonConfiguration::JsonConfiguration( unsigned long flags )
: JsonObject(flags)
{
add( "+parameters", typeid(JsonArray) );
}
string JsonConfiguration::getTypeName () const
{ return "Cfg::Configuration"; }
JsonConfiguration* JsonConfiguration::clone ( unsigned long flags ) const
{ return new JsonConfiguration ( flags ); }
void JsonConfiguration::toData ( JsonStack& stack )
{
check( stack, "JsonConfiguration::toData" );
Configuration* cfg = Configuration::get();
update( stack, cfg );
}
// -------------------------------------------------------------------
// Class : "JsonParameter"
Initializer<JsonParameter> jsonParameterInit ( 0 );
void JsonParameter::initialize ()
{ JsonTypes::registerType( new JsonParameter (JsonWriter::RegisterMode) ); }
JsonParameter::JsonParameter( unsigned long flags )
: JsonObject(flags)
{
add( "_id" , typeid(string) );
add( "_type" , typeid(string) );
add( "_priority", typeid(string) );
add( "_value" , typeid(string) );
add( "_flags" , typeid(int64_t) );
}
string JsonParameter::getTypeName () const
{ return "Cfg::Parameter"; }
JsonParameter* JsonParameter::clone ( unsigned long flags ) const
{ return new JsonParameter ( flags ); }
void JsonParameter::toData ( JsonStack& stack )
{
check( stack, "JsonParameter::toData" );
Configuration* cfg = get<Configuration*>( stack, "_configuration" );
Parameter* param = NULL;
string id = get<string> ( stack, "_id" );
string stype = get<string> ( stack, "_type" );
string spriority = get<string> ( stack, "_priority" );
string value = get<string> ( stack, "_value" );
int flags = get<int64_t>( stack, "_flags" );
Parameter::Type type = Parameter::stringToType (stype);
Parameter::Priority priority = Parameter::stringToPriority(spriority);
param = cfg->getParameter( id );
if (not param) {
param = cfg->addParameter( id, type, value, priority );
} else {
if (param->getType() != type) {
cerr << Error( "JsonParameter::toData(): Type incoherency on parameter \"%s\", not restored."
, id.c_str() ) << endl;
}
param->setRawString( value, Parameter::Interactive );
param->setPriority( priority );
}
if (type == Parameter::Int) {
if (flags & Parameter::HasMin) {
add( "_minInt", typeid(int64_t) );
param->setMin( (int)get<int64_t>( stack, "_minInt" ), Parameter::Interactive );
}
if (flags & Parameter::HasMax) {
add( "_maxInt", typeid(int64_t) );
param->setMax( (int)get<int64_t>( stack, "_maxInt" ), Parameter::Interactive );
}
}
if (type == Parameter::Double) {
if (flags & Parameter::HasMin) {
add( "_minDouble", typeid(int64_t) );
param->setMin( (double)get<int64_t>( stack, "_minDouble" ), Parameter::Interactive );
}
if (flags & Parameter::HasMax) {
add( "_maxDouble", typeid(int64_t) );
param->setMax( (double)get<int64_t>( stack, "_maxDouble" ), Parameter::Interactive );
}
}
update( stack, param );
}
} // Hurricane namespace.

View File

@ -1,15 +1,9 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2016, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
@ -17,10 +11,7 @@
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./PaletteNamedItem.cpp" | // | C++ Module : "./PaletteNamedItem.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include <QCheckBox> #include <QCheckBox>

View File

@ -1,7 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2016, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | H U R R I C A N E | // | H U R R I C A N E |
@ -62,12 +62,15 @@ namespace {
}; };
GridBuffer::GridBuffer ( QGridLayout* grid, size_t maxRow, size_t startRow, size_t startColumn ) GridBuffer::GridBuffer ( QGridLayout* grid
, size_t maxRow
, size_t startRow
, size_t startColumn )
: _grid (grid) : _grid (grid)
, _rowMax (maxRow) , _rowMax (maxRow)
, _row (startRow) , _row (startRow)
, _column (startColumn) , _column (startColumn)
, _widgets() , _widgets ()
, _aligns () , _aligns ()
{ } { }
@ -123,6 +126,9 @@ namespace {
namespace Hurricane { namespace Hurricane {
// -------------------------------------------------------------------
// Class : "PaletteWidget".
QWidget* PaletteWidget::_createGroupItem ( const Name& name ) QWidget* PaletteWidget::_createGroupItem ( const Name& name )
{ {
QLabel* groupLabel = new QLabel (); QLabel* groupLabel = new QLabel ();
@ -218,10 +224,12 @@ namespace Hurricane {
vLayout->addWidget ( _scrollArea ); vLayout->addWidget ( _scrollArea );
setLayout ( vLayout ); setLayout ( vLayout );
readGraphics ();
} }
void PaletteWidget::build () void PaletteWidget::readGraphics ()
{ {
GridBuffer gridBuffer ( _grid, _columnHeight ); GridBuffer gridBuffer ( _grid, _columnHeight );
@ -299,6 +307,7 @@ namespace Hurricane {
void PaletteWidget::updateExtensions ( Cell* cell ) void PaletteWidget::updateExtensions ( Cell* cell )
{ {
if (_extensionGroup) {
_grid->removeWidget ( _extensionGroup ); _grid->removeWidget ( _extensionGroup );
//_extensionGroup->deleteLater (); //_extensionGroup->deleteLater ();
delete _extensionGroup; delete _extensionGroup;
@ -311,7 +320,7 @@ namespace Hurricane {
delete iextension->second; delete iextension->second;
} }
_extensionGoItems.clear (); _extensionGoItems.clear ();
}
GridBuffer gridBuffer ( _grid, _columnHeight, _extensionRow, _extensionColumn ); GridBuffer gridBuffer ( _grid, _columnHeight, _extensionRow, _extensionColumn );
_extensionGroup = _createGroupItem ( "Extensions" ); _extensionGroup = _createGroupItem ( "Extensions" );
@ -328,6 +337,28 @@ namespace Hurricane {
} }
void PaletteWidget::resetGraphics ()
{
QLayoutItem* child = NULL;
while ( (child = _grid->takeAt(0)) != 0 ) {
_grid->removeWidget( child->widget() );
delete child->widget();
}
_layerItems.clear();
_extensionGroup = NULL;
_extensionGoItems.clear();
}
void PaletteWidget::rereadGraphics ()
{
resetGraphics();
readGraphics();
}
void PaletteWidget::_getSection ( const QString section, QLabel*& label, vector<PaletteItem*>& items ) const void PaletteWidget::_getSection ( const QString section, QLabel*& label, vector<PaletteItem*>& items ) const
{ {
label = NULL; label = NULL;

View File

@ -1,4 +1,3 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
@ -27,6 +26,7 @@ namespace Cfg {
class ConfigurationWidget; class ConfigurationWidget;
} }
#include "hurricane/Observer.h"
#include "hurricane/Occurrence.h" #include "hurricane/Occurrence.h"
@ -63,6 +63,7 @@ namespace Hurricane {
virtual void updateTab (); virtual void updateTab ();
virtual void cellPreModificate (); virtual void cellPreModificate ();
virtual void cellPostModificate (); virtual void cellPostModificate ();
virtual void graphicsUpdated ();
protected: protected:
CellWidget* _cellWidget; CellWidget* _cellWidget;
@ -84,6 +85,7 @@ namespace Hurricane {
inline GraphicsWidget* getGraphics (); inline GraphicsWidget* getGraphics ();
public slots: public slots:
void setCellWidget ( CellWidget* ); void setCellWidget ( CellWidget* );
virtual void graphicsUpdated ();
protected: protected:
GraphicsWidget* _graphics; GraphicsWidget* _graphics;
@ -126,6 +128,7 @@ namespace Hurricane {
inline PaletteWidget* getPalette (); inline PaletteWidget* getPalette ();
public slots: public slots:
virtual void setCellWidget ( CellWidget* ); virtual void setCellWidget ( CellWidget* );
virtual void graphicsUpdated ();
protected: protected:
PaletteWidget* _palette; PaletteWidget* _palette;
@ -260,9 +263,11 @@ namespace Hurricane {
inline ConfigurationWidget* getSettings (); inline ConfigurationWidget* getSettings ();
public slots: public slots:
void setCellWidget ( CellWidget* ); void setCellWidget ( CellWidget* );
protected:
virtual void showEvent ( QShowEvent* );
private: private:
size_t _timestamp;
ConfigurationWidget* _configuration; ConfigurationWidget* _configuration;
}; };
@ -292,6 +297,15 @@ namespace Hurricane {
class ControllerWidget : public QTabWidget { class ControllerWidget : public QTabWidget {
Q_OBJECT; Q_OBJECT;
public:
class GraphicsObserver : public Observer<ControllerWidget> {
public:
inline GraphicsObserver ( ControllerWidget* );
virtual void notify ( unsigned int flags );
private:
GraphicsObserver ( const GraphicsObserver& );
};
public: public:
ControllerWidget ( QWidget* parent=NULL ); ControllerWidget ( QWidget* parent=NULL );
inline CellWidget* getCellWidget (); inline CellWidget* getCellWidget ();
@ -306,6 +320,7 @@ namespace Hurricane {
void setCellWidget ( CellWidget* ); void setCellWidget ( CellWidget* );
//inline int addSetting ( QWidget* page, const QString& label ); //inline int addSetting ( QWidget* page, const QString& label );
public slots: public slots:
void graphicsUpdated ();
void cellPreModificate (); void cellPreModificate ();
void cellPostModificate (); void cellPostModificate ();
void cellChanged ( Cell* ); void cellChanged ( Cell* );
@ -313,6 +328,7 @@ namespace Hurricane {
void toggleShow (); void toggleShow ();
protected: protected:
GraphicsObserver _observer;
CellWidget* _cellWidget; CellWidget* _cellWidget;
TabGraphics* _tabGraphics; TabGraphics* _tabGraphics;
TabPalette* _tabPalette; TabPalette* _tabPalette;
@ -337,6 +353,11 @@ namespace Hurricane {
//inline int ControllerWidget::addSetting ( QWidget* page, const QString& label ) { return _tabSettings->addSetting(page,label); } //inline int ControllerWidget::addSetting ( QWidget* page, const QString& label ) { return _tabSettings->addSetting(page,label); }
inline ControllerWidget::GraphicsObserver::GraphicsObserver ( ControllerWidget* owner )
: Observer<ControllerWidget>(owner)
{ }
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -32,6 +32,7 @@ namespace Hurricane {
inline DesignBlob ( Cell* ); inline DesignBlob ( Cell* );
inline Cell* getTopCell () const; inline Cell* getTopCell () const;
void toJson ( JsonWriter* ) const; void toJson ( JsonWriter* ) const;
static DesignBlob* fromJson ( const std::string& filename );
inline std::string _getTypeName () const; inline std::string _getTypeName () const;
private: private:
Cell* _topCell; Cell* _topCell;

View File

@ -1,8 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
// | H U R R I C A N E | // | H U R R I C A N E |
@ -15,9 +14,8 @@
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+
#ifndef __HURRICANE_DISPLAYSTYLE_H__ #ifndef HURRICANE_DISPLAYSTYLE_H
#define __HURRICANE_DISPLAYSTYLE_H__ #define HURRICANE_DISPLAYSTYLE_H
#include <memory> #include <memory>
#include <string> #include <string>
@ -36,6 +34,9 @@ namespace Hurricane {
typedef std::vector <DrawingStyle> DrawingStyles; typedef std::vector <DrawingStyle> DrawingStyles;
// -------------------------------------------------------------------
// Class : "DrawingGroup".
class DrawingGroup { class DrawingGroup {
public: public:
// Constructors & Destructors. // Constructors & Destructors.
@ -57,6 +58,8 @@ namespace Hurricane {
, float threshold , float threshold
, bool goMatched , bool goMatched
); );
void addDrawingStyle ( DrawingStyle );
void toJson ( JsonWriter* ) const;
protected: protected:
const Name _name; const Name _name;
DrawingStyles _drawingStyles; DrawingStyles _drawingStyles;
@ -67,6 +70,23 @@ namespace Hurricane {
}; };
// -------------------------------------------------------------------
// Class : "JsonDrawingGroup".
class JsonDrawingGroup : public JsonObject {
public:
static void initialize ();
JsonDrawingGroup ( unsigned long flags );
~JsonDrawingGroup ();
virtual string getTypeName () const;
virtual JsonDrawingGroup* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Class : "DisplayStyle".
class DisplayStyle { class DisplayStyle {
public: public:
class HSVr { class HSVr {
@ -79,6 +99,8 @@ namespace Hurricane {
inline void setHue ( float ); inline void setHue ( float );
inline void setSaturation ( float ); inline void setSaturation ( float );
inline void setValue ( float ); inline void setValue ( float );
inline void toJson ( JsonWriter* ) const;
inline std::string _getString () const;
private: private:
float _hue; float _hue;
float _saturation; float _saturation;
@ -142,6 +164,9 @@ namespace Hurricane {
, float threshold , float threshold
, bool goMatched =true , bool goMatched =true
); );
DrawingGroup* findGroup ( const Name& groupKey );
void findOrCreate ( const Name& groupKey, size_t& gi );
void toJson ( JsonWriter* ) const;
protected: protected:
// Internals - Attributes. // Internals - Attributes.
@ -151,8 +176,6 @@ namespace Hurricane {
HSVr _darkening; HSVr _darkening;
// Internals - Methods. // Internals - Methods.
void findOrCreate ( const Name& groupKey
, size_t& gi );
void find ( const Name& groupKey void find ( const Name& groupKey
, const Name& key , const Name& key
, size_t& gi , size_t& gi
@ -161,6 +184,37 @@ namespace Hurricane {
}; };
// -------------------------------------------------------------------
// Class : "JsonDisplayStyle".
class JsonDisplayStyle : public JsonObject {
public:
static void initialize ();
JsonDisplayStyle ( unsigned long flags );
~JsonDisplayStyle ();
virtual string getTypeName () const;
virtual JsonDisplayStyle* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Class : "JsonHSVr".
class JsonHSVr : public JsonObject {
public:
static void initialize ();
JsonHSVr ( unsigned long flags );
~JsonHSVr ();
virtual string getTypeName () const;
virtual JsonHSVr* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Class : "RawDrawingStyle".
class RawDrawingStyle { class RawDrawingStyle {
public: public:
// Constructors & Destructors. // Constructors & Destructors.
@ -183,6 +237,7 @@ namespace Hurricane {
QPen getPen ( const DisplayStyle::HSVr& ) const; QPen getPen ( const DisplayStyle::HSVr& ) const;
QBrush getBrush ( const DisplayStyle::HSVr& ) const; QBrush getBrush ( const DisplayStyle::HSVr& ) const;
inline float getThreshold () const; inline float getThreshold () const;
void toJson ( JsonWriter* ) const;
private: private:
// Internal - Attributes. // Internal - Attributes.
const Name _name; const Name _name;
@ -214,7 +269,23 @@ namespace Hurricane {
}; };
// Functions. // -------------------------------------------------------------------
// Class : "JsonDrawingStyle".
class JsonDrawingStyle : public JsonObject {
public:
static void initialize ();
JsonDrawingStyle ( unsigned long flags );
~JsonDrawingStyle ();
virtual string getTypeName () const;
virtual JsonDrawingStyle* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Inline Functions.
inline bool RawDrawingStyle::isGoMatched () const { return _goMatched; } inline bool RawDrawingStyle::isGoMatched () const { return _goMatched; }
inline const Name& RawDrawingStyle::getName () const { return _name; } inline const Name& RawDrawingStyle::getName () const { return _name; }
inline const std::string& RawDrawingStyle::getPattern () const { return _pattern; } inline const std::string& RawDrawingStyle::getPattern () const { return _pattern; }
@ -241,8 +312,28 @@ namespace Hurricane {
inline void DisplayStyle::HSVr::setSaturation ( float saturation ) { _saturation=saturation; } inline void DisplayStyle::HSVr::setSaturation ( float saturation ) { _saturation=saturation; }
inline void DisplayStyle::HSVr::setValue ( float value ) { _value=value; } inline void DisplayStyle::HSVr::setValue ( float value ) { _value=value; }
inline std::string DisplayStyle::HSVr::_getString () const
{
std::string s = "<HSVr " + getString(_hue)
+ " " + getString(_saturation)
+ " " + getString(_value) + ">";
return s;
}
} // End of Hurricane namespace. inline void DisplayStyle::HSVr::toJson ( JsonWriter* w ) const
{
w->startObject();
jsonWrite( w, "@typename", "HSVr" );
jsonWrite( w, "_hue" , _hue );
jsonWrite( w, "_saturation", _saturation );
jsonWrite( w, "_value" , _value );
w->endObject();
}
} // Hurricane namespace.
#endif // __HURRICANE_DISPLAYSTYLE__ GETSTRING_VALUE_SUPPORT(Hurricane::DisplayStyle::HSVr);
#endif // HURRICANE_DISPLAYSTYLE_H

View File

@ -21,6 +21,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <QFont> #include <QFont>
#include "hurricane/Observer.h"
#include "hurricane/Breakpoint.h" #include "hurricane/Breakpoint.h"
#include "hurricane/TextTranslator.h" #include "hurricane/TextTranslator.h"
#include "hurricane/viewer/DisplayStyle.h" #include "hurricane/viewer/DisplayStyle.h"
@ -37,11 +38,18 @@ namespace Hurricane {
class Name; class Name;
class Graphics { // -------------------------------------------------------------------
// Class : "Graphics".
class Graphics {
public:
enum NotifyFlags { ChangedDisplayStyles = (1<<0) };
public: public:
// Accessors. // Accessors.
static Graphics* getGraphics (); static Graphics* getGraphics ();
static void addObserver ( BaseObserver* );
static void removeObserver ( BaseObserver* );
static void notify ( unsigned int flags );
static bool isEnabled (); static bool isEnabled ();
static bool isHighDpi (); static bool isHighDpi ();
static const QFont getFixedFont ( int weight=QFont::Normal, bool italic=false, bool underline=false, int scale=0 ); static const QFont getFixedFont ( int weight=QFont::Normal, bool italic=false, bool underline=false, int scale=0 );
@ -59,7 +67,6 @@ namespace Hurricane {
static string toHtml ( const string& ); static string toHtml ( const string& );
static int toHighDpi ( int ); static int toHighDpi ( int );
static bool breakpointStopCb ( const string& message ); static bool breakpointStopCb ( const string& message );
// Modifiers. // Modifiers.
static void addStyle ( DisplayStyle* displayStyle ); static void addStyle ( DisplayStyle* displayStyle );
static void setStyle ( const Name& key ); static void setStyle ( const Name& key );
@ -68,10 +75,11 @@ namespace Hurricane {
static DisplayStyle* getStyle (); static DisplayStyle* getStyle ();
static const vector<DisplayStyle*>& getStyles (); static const vector<DisplayStyle*>& getStyles ();
static void enable (); static void enable ();
void toJson ( JsonWriter* ) const;
// Internals - Attributes. // Internals - Attributes.
protected: protected:
static Graphics* _singleton; static Graphics* _singleton;
Observable _observers;
TextTranslator _htmlTranslator; TextTranslator _htmlTranslator;
vector<DisplayStyle*> _styles; vector<DisplayStyle*> _styles;
DisplayStyle* _active; DisplayStyle* _active;
@ -86,7 +94,6 @@ namespace Hurricane {
Graphics ( const Graphics& ); Graphics ( const Graphics& );
Graphics& operator= ( const Graphics& ); Graphics& operator= ( const Graphics& );
~Graphics (); ~Graphics ();
// Internals - Methods. // Internals - Methods.
size_t _findStyle ( const Name& key ) const; size_t _findStyle ( const Name& key ) const;
void _addStyle ( DisplayStyle* displayStyle ); void _addStyle ( DisplayStyle* displayStyle );
@ -105,7 +112,6 @@ namespace Hurricane {
inline const ColorScale& _getColorScale ( ColorScale::ScaleType ) const; inline const ColorScale& _getColorScale ( ColorScale::ScaleType ) const;
inline void _enable (); inline void _enable ();
inline const TextTranslator& _getHtmlTranslator () const; inline const TextTranslator& _getHtmlTranslator () const;
}; };
@ -157,6 +163,20 @@ namespace Hurricane {
{ return _htmlTranslator; } { return _htmlTranslator; }
// -------------------------------------------------------------------
// Class : "JsonGraphics".
class JsonGraphics : public JsonObject {
public:
static void initialize ();
JsonGraphics ( unsigned long flags );
~JsonGraphics ();
virtual string getTypeName () const;
virtual JsonGraphics* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
private:
std::string _active;
};
} // End of Hurricane namespace. } // End of Hurricane namespace.

View File

@ -19,6 +19,8 @@
#include <QWidget> #include <QWidget>
class QGridLayout;
class QButtonGroup;
#include "hurricane/viewer/CellWidget.h" #include "hurricane/viewer/CellWidget.h"
@ -32,17 +34,21 @@ namespace Hurricane {
public: public:
GraphicsWidget ( QWidget* parent=NULL ); GraphicsWidget ( QWidget* parent=NULL );
void setCellWidget ( CellWidget* ); void setCellWidget ( CellWidget* );
void readGraphics ();
void resetGraphics ();
void rereadGraphics ();
public slots: public slots:
void changeStyle (); void changeStyle ();
void setStyle ( int id ); void setStyle ( int id );
protected: protected:
CellWidget* _cellWidget; CellWidget* _cellWidget;
QGridLayout* _stylesGrid;
QButtonGroup* _stylesGroup;
UpdateState _updateState; UpdateState _updateState;
}; };
} // End of Hurricane namespace. } // Hurricane namespace.
#endif #endif

View File

@ -0,0 +1,130 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2016-2016, 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/viewer/JsonConfiguration.h" |
// +-----------------------------------------------------------------+
#ifndef HURRICANE_JSON_CONFIGURATION_H
#define HURRICANE_JSON_CONFIGURATION_H
#include "vlsisapd/configuration/Parameter.h"
#include "vlsisapd/configuration/Configuration.h"
#include "hurricane/Commons.h"
void jsonWrite ( JsonWriter*, const Cfg::Parameter* );
void jsonWrite ( JsonWriter*, const Cfg::Parameter::EnumValue );
void jsonWrite ( JsonWriter*, const Cfg::Configuration* );
void jsonWrite ( JsonWriter*, const Cfg::WidgetDescription* );
void jsonWrite ( JsonWriter*, const Cfg::TabDescription* );
void jsonWrite ( JsonWriter*, const Cfg::LayoutDescription* );
namespace Hurricane {
// -------------------------------------------------------------------
// Class : "JsonParameter".
class JsonParameter : public JsonObject {
public:
static void initialize ();
JsonParameter ( unsigned long );
virtual string getTypeName () const;
virtual JsonParameter* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Class : "JsonParamEnumValue".
class JsonParamEnumValue : public JsonObject {
public:
static void initialize ();
JsonParamEnumValue ( unsigned long );
virtual string getTypeName () const;
virtual JsonParamEnumValue* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Class : "JsonParamSlave".
class JsonParamSlave : public JsonObject {
public:
static void initialize ();
JsonParamSlave ( unsigned long );
virtual string getTypeName () const;
virtual JsonParamSlave* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Class : "JsonConfiguration".
class JsonConfiguration : public JsonObject {
public:
static void initialize ();
JsonConfiguration ( unsigned long );
virtual string getTypeName () const;
virtual JsonConfiguration* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Class : "JsonWidgetDescription".
class JsonWidgetDescription : public JsonObject {
public:
static void initialize ();
JsonWidgetDescription ( unsigned long );
virtual string getTypeName () const;
virtual JsonWidgetDescription* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Class : "JsonTabDescription".
class JsonTabDescription : public JsonObject {
public:
static void initialize ();
JsonTabDescription ( unsigned long );
virtual string getTypeName () const;
virtual JsonTabDescription* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Class : "JsonLayoutDescription".
class JsonLayoutDescription : public JsonObject {
public:
static void initialize ();
JsonLayoutDescription ( unsigned long );
virtual ~JsonLayoutDescription ();
virtual string getTypeName () const;
virtual JsonLayoutDescription* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // Hurricane namespace.
#endif // HURRICANE_JSON_CONFIGURATION_H

View File

@ -0,0 +1,66 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2016-2016, 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/viewer/JsonParameter.h" |
// +-----------------------------------------------------------------+
#ifndef HURRICANE_JSON_PARAMETER_H
#define HURRICANE_JSON_PARAMETER_H
#include "vlsisapd/configuration/Parameter.h"
#include "vlsisapd/configuration/Configuration.h"
#include "hurricane/Commons.h"
void jsonWrite ( JsonWriter*, const Cfg::Parameter* );
void jsonWrite ( JsonWriter*, const Cfg::Configuration* );
inline void jsonWrite ( JsonWriter* w, const std::string& key, const Cfg::Parameter* p )
{ w->key(key); jsonWrite( w, p ); }
inline void jsonWrite ( JsonWriter* w, const std::string& key, const Cfg::Configuration* cfg )
{ w->key(key); jsonWrite( w, cfg ); }
namespace Hurricane {
// -------------------------------------------------------------------
// Class : "JsonParameter".
class JsonParameter : public JsonObject {
public:
static void initialize ();
JsonParameter ( unsigned long );
virtual string getTypeName () const;
virtual JsonParameter* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
// -------------------------------------------------------------------
// Class : "JsonConfiguration".
class JsonConfiguration : public JsonObject {
public:
static void initialize ();
JsonConfiguration ( unsigned long );
virtual string getTypeName () const;
virtual JsonConfiguration* clone ( unsigned long ) const;
virtual void toData ( JsonStack& );
};
} // Hurricane namespace.
#endif // HURRICANE_JSON_PARAMETER_H

View File

@ -1,30 +1,21 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2016, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
// | Author : Jean-Paul CHAPUT | // | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./PaletteLayerItem.h" | // | C++ Header : "./hurricane/viewer/PaletteLayerItem.h" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_PALETTE_LAYER_ITEM__ #ifndef HURRICANE_PALETTE_LAYER_ITEM_H
#define __HURRICANE_PALETTE_LAYER_ITEM__ #define HURRICANE_PALETTE_LAYER_ITEM_H
class QCheckBox; class QCheckBox;
@ -64,7 +55,6 @@ namespace Hurricane {
}; };
} // End of Hurricane namespace. } // Hurricane namespace.
#endif // HURRICANE_PALETTE_LAYER_ITEM_H
#endif // __HURRICANE_PALETTE_LAYER_ITEM__

View File

@ -1,30 +1,21 @@
// -*- C++ -*- // -*- C++ -*-
// //
// This file is part of the Coriolis Software. // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved // Copyright (c) UPMC 2008-2016, All Rights Reserved
// //
// =================================================================== // +-----------------------------------------------------------------+
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E | // | 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 | // | V L S I B a c k e n d D a t a - B a s e |
// | | // | |
// | Author : Jean-Paul CHAPUT | // | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Header : "./PaletteWidget.h" | // | C++ Header : "./hurricane/viewer/PaletteWidget.h" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_PALETTE_WIDGET__ #ifndef HURRICANE_PALETTE_WIDGET_H
#define __HURRICANE_PALETTE_WIDGET__ #define HURRICANE_PALETTE_WIDGET_H
#include <map> #include <map>
#include <limits> #include <limits>
@ -52,8 +43,12 @@ namespace Hurricane {
class PaletteNamedItem; class PaletteNamedItem;
class PaletteLayerItem; class PaletteLayerItem;
class PaletteExtensionGoItem; class PaletteExtensionGoItem;
class PaletteWidget;
// -------------------------------------------------------------------
// Class : "PaletteWidget".
class PaletteWidget : public QWidget { class PaletteWidget : public QWidget {
Q_OBJECT; Q_OBJECT;
@ -66,7 +61,9 @@ namespace Hurricane {
bool isSelectable ( const Name& name ) const; bool isSelectable ( const Name& name ) const;
inline void setOneColumn (); inline void setOneColumn ();
inline void setColumnHeight ( size_t height=std::numeric_limits<size_t>::max() ); inline void setColumnHeight ( size_t height=std::numeric_limits<size_t>::max() );
void build (); void readGraphics ();
void resetGraphics ();
void rereadGraphics ();
signals: signals:
void paletteChanged (); void paletteChanged ();
public slots: public slots:
@ -108,7 +105,6 @@ namespace Hurricane {
inline void PaletteWidget::setColumnHeight ( size_t height ) { _columnHeight = height; } inline void PaletteWidget::setColumnHeight ( size_t height ) { _columnHeight = height; }
} // End of Hurricane namespace. } // Hurricane namespace.
#endif // HURRICANE_PALETTE_WIDGET_H
#endif // __HURRICANE_PALETTE_WIDGET__

View File

@ -204,8 +204,8 @@ int main ( int argc, char *argv[] )
bool showConf = Cfg::getParamBool("misc.showConf")->asBool(); bool showConf = Cfg::getParamBool("misc.showConf")->asBool();
dbo_ptr<DataBase> db ( DataBase::create() ); dbo_ptr<DataBase> db ( DataBase::getDB() );
dbo_ptr<AllianceFramework> af ( AllianceFramework::create() ); dbo_ptr<AllianceFramework> af ( AllianceFramework::get() );
Cell* cell = NULL; Cell* cell = NULL;
Utilities::Path path = Utilities::Path::cwd(); Utilities::Path path = Utilities::Path::cwd();

Some files were not shown because too many files have changed in this diff Show More