Added C++ & Python tutorial code."

This commit is contained in:
Jean-Paul Chaput 2017-12-01 14:17:47 +01:00
parent 62a433ad3c
commit 51d5313801
15 changed files with 1560 additions and 0 deletions

View File

@ -30,6 +30,7 @@ projects = [
, "equinox" , "equinox"
, "solstice" , "solstice"
, "unicorn" , "unicorn"
, "tutorial"
#, "testbench" #, "testbench"
#, "ispd" #, "ispd"
, "cumulus" , "cumulus"

37
tutorial/CMakeLists.txt Normal file
View File

@ -0,0 +1,37 @@
# -*- explicit-buffer-name: "CMakeLists.txt<tutorial>" -*-
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
project(TUTORIAL)
option(BUILD_DOC "Build the documentation (doxygen)" OFF)
cmake_minimum_required(VERSION 2.8.9)
list(INSERT CMAKE_MODULE_PATH 0 "${DESTDIR}$ENV{CORIOLIS_TOP}/share/cmake/Modules/")
find_package(Bootstrap REQUIRED)
setup_project_paths(CORIOLIS)
set_cmake_policies()
set_lib_link_mode()
setup_boost(program_options python)
setup_qt()
find_package(Libexecinfo REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(PythonLibs 2 REQUIRED)
find_package(PythonSitePackages REQUIRED)
find_package(LEFDEF REQUIRED)
find_package(VLSISAPD REQUIRED)
find_package(HURRICANE REQUIRED)
find_package(CORIOLIS REQUIRED)
add_subdirectory(src)
add_subdirectory(python)
#add_subdirectory(cmake_modules)
#if(BUILD_DOC)
# find_package(Doxygen)
# if(DOXYGEN_FOUND)
# add_subdirectory(doc)
# endif()
#endif()

View File

@ -0,0 +1,3 @@
# -*- explicit-buffer-name: "CMakeLists.txt<tutorial/python>" -*-
install ( FILES runDemo.py DESTINATION ${PYTHON_SITE_PACKAGES}/cumulus/plugins )

168
tutorial/python/runDemo.py Normal file
View File

@ -0,0 +1,168 @@
#!/usr/bin/env python
#
# This file is part of the Coriolis Software.
# Copyright (c) UPMC 2017-2017, All Rights Reserved
#
# +-----------------------------------------------------------------+
# | C O R I O L I S |
# | T o o l E n g i n e T u t o r i a l |
# | |
# | Author : Jean-Paul CHAPUT |
# | E-mail : Jean-Paul.Chaput@lip6.fr |
# | =============================================================== |
# | Python : "./plugins/RSavePlugin.py" |
# +-----------------------------------------------------------------+
try:
import sys
import os.path
import Cfg
import Viewer
import CRL
import helpers
from helpers import ErrorMessage
from helpers import WarningMessage
from helpers import showPythonTrace
import plugins
from Hurricane import DataBase
from Hurricane import Breakpoint
from Hurricane import UpdateSession
from Hurricane import DbU
from Hurricane import Box
from Hurricane import Contact
from Hurricane import Vertical
from Hurricane import Horizontal
from Hurricane import Net
from Hurricane import Cell
except ImportError, e:
serror = str(e)
if serror.startswith('No module named'):
module = serror.split()[-1]
print '[ERROR] The <%s> python module or symbol cannot be loaded.' % module
print ' Please check the integrity of the <coriolis> package.'
if serror.find('cannot open shared object file'):
library = serror.split(':')[0]
print '[ERROR] The <%s> shared library cannot be loaded.' % library
print ' Under RHEL 6, you must be under devtoolset-2.'
print ' (scl enable devtoolset-2 bash)'
sys.exit(1)
except Exception, e:
print '[ERROR] A strange exception occurred while loading the basic Coriolis/Python'
print ' modules. Something may be wrong at Python/C API level.\n'
print ' %s' % e
sys.exit(2)
def runDemo ( cell, editor ):
print 'runDemo() Python plugin function has been called.'
if cell:
print WarningMessage( 'A Cell "%s" is already loaded in the Viewer, cowardly exiting.' % cell.getName() )
return
library = CRL.AllianceFramework.get().getLibrary( 0 )
cell = CRL.AllianceFramework.get().getCell( 'demo_cell', CRL.Catalog.State.Views )
if cell:
print WarningMessage( '"demo_cell" has already been created, do not run twice.' )
return
UpdateSession.open()
cell = Cell.create( library, 'demo_cell' )
cell.setAbutmentBox( Box( DbU.fromLambda( 0.0), DbU.fromLambda( 0.0)
, DbU.fromLambda(15.0), DbU.fromLambda(50.0) ) )
UpdateSession.close()
if editor: editor.setCell( cell )
Breakpoint.stop( 5, 'Abutment box has been drawn.' )
UpdateSession.open()
technology = DataBase.getDB().getTechnology()
nwell = technology.getLayer( 'NWELL' )
ntrans = technology.getLayer( 'NTRANS' )
ptrans = technology.getLayer( 'PTRANS' )
diffN = technology.getLayer( 'NDIF' )
diffP = technology.getLayer( 'PDIF' )
contDiffN = technology.getLayer( 'CONT_DIF_N' )
contDiffP = technology.getLayer( 'CONT_DIF_P' )
contPoly = technology.getLayer( 'CONT_POLY' )
poly = technology.getLayer( 'POLY' )
metal1 = technology.getLayer( 'METAL1' )
nwellNet = Net.create( cell, 'nwell' )
Horizontal.create( nwellNet, nwell, DbU.fromLambda(39.0), DbU.fromLambda(24.0), DbU.fromLambda(0.0), DbU.fromLambda(15.0) )
vss = Net.create( cell, 'vss' )
vdd = Net.create( cell, 'vdd' )
Horizontal.create( vss, metal1 , DbU.fromLambda(3.0), DbU.fromLambda(6.0), DbU.fromLambda(0.0), DbU.fromLambda(15.0) )
Vertical.create ( vss, diffN , DbU.fromLambda(3.5), DbU.fromLambda(4.0), DbU.fromLambda(4.0), DbU.fromLambda(12.0) )
Contact.create ( vss, contDiffN, DbU.fromLambda(4.0), DbU.fromLambda(5.0) )
Horizontal.create( vdd, metal1 , DbU.fromLambda(47.0), DbU.fromLambda( 6.0), DbU.fromLambda( 0.0), DbU.fromLambda(15.0) )
Vertical.create ( vdd, diffP , DbU.fromLambda( 3.5), DbU.fromLambda( 4.0), DbU.fromLambda(28.0), DbU.fromLambda(46.0) )
Contact.create ( vdd, contDiffP, DbU.fromLambda( 4.0), DbU.fromLambda(45.0) )
UpdateSession.close()
Breakpoint.stop( 5, 'Power nets have been drawn.' )
UpdateSession.open()
nq = Net.create( cell, 'nq' )
Vertical.create ( nq, diffN , DbU.fromLambda(10.0), DbU.fromLambda( 3.0), DbU.fromLambda( 8.0), DbU.fromLambda(12.0) )
Vertical.create ( nq, diffP , DbU.fromLambda(10.0), DbU.fromLambda( 3.0), DbU.fromLambda(28.0), DbU.fromLambda(37.0) )
Contact.create ( nq, contDiffN, DbU.fromLambda(10.0), DbU.fromLambda(10.0) )
Contact.create ( nq, contDiffP, DbU.fromLambda(10.0), DbU.fromLambda(30.0) )
Contact.create ( nq, contDiffP, DbU.fromLambda(10.0), DbU.fromLambda(35.0) )
Vertical.create ( nq, metal1 , DbU.fromLambda(10.0), DbU.fromLambda( 2.0), DbU.fromLambda(10.0), DbU.fromLambda(40.0) )
UpdateSession.close()
Breakpoint.stop( 5, 'Output has been drawn.' )
UpdateSession.open()
i = Net.create( cell, 'i' )
Vertical.create ( i, ntrans , DbU.fromLambda( 7.0), DbU.fromLambda( 1.0), DbU.fromLambda( 6.0), DbU.fromLambda(14.0) )
Vertical.create ( i, poly , DbU.fromLambda( 7.0), DbU.fromLambda( 1.0), DbU.fromLambda(14.0), DbU.fromLambda(26.0) )
Vertical.create ( i, ptrans , DbU.fromLambda( 7.0), DbU.fromLambda( 1.0), DbU.fromLambda(26.0), DbU.fromLambda(39.0) )
Horizontal.create( i, poly , DbU.fromLambda(20.0), DbU.fromLambda( 3.0), DbU.fromLambda( 4.0), DbU.fromLambda( 7.0) )
Contact.create ( i, contPoly , DbU.fromLambda( 5.0), DbU.fromLambda(20.0) )
Vertical.create ( i, metal1 , DbU.fromLambda( 5.0), DbU.fromLambda( 2.0), DbU.fromLambda(10.0), DbU.fromLambda(40.0) )
UpdateSession.close()
Breakpoint.stop( 5, 'Input has been drawn.' )
return
# --------------------------------------------------------------------
# Plugin hook functions, unicornHook:menus, ScritMain:call
def unicornHook ( **kw ):
editor = kw['editor']
editor.addMenu( 'tutorials' , 'Tutorials', Viewer.CellViewer.TopMenu )
editor.addMenu( 'tutorials.plugins', 'Plugins' , Viewer.CellViewer.NoFlags )
plugins.kwUnicornHook( 'tutorials.plugins.runDemo'
, 'Tutorial - Run Demo (Python flavor)'
, 'Launch runDemo() in the Tutorial Python plugin.'
, sys.modules[__name__].__file__
, **kw
)
return
def ScriptMain ( **kw ):
try:
helpers.staticInitialization( quiet=True )
#helpers.setTraceLevel( 550 )
cell, editor = plugins.kwParseMain( **kw )
runDemo( cell, editor )
except ErrorMessage, e:
print e; errorCode = e.code
except Exception, e:
showPythonTrace( 'runDemo.py', e )
return 0

View File

@ -0,0 +1,64 @@
# -*- explicit-buffer-name: "CMakeLists.txt<tutorial/src>" -*-
# include( ${QT_USE_FILE} )
include_directories( ${TUTORIAL_SOURCE_DIR}/src
${CORIOLIS_INCLUDE_DIR}
${HURRICANE_INCLUDE_DIR}
${CONFIGURATION_INCLUDE_DIR}
${QtX_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${PYTHON_INCLUDE_PATH}
)
set( includes tutorial/TutorialEngine.h
tutorial/GraphicTutorialEngine.h
)
set( pyIncludes tutorial/PyTutorialEngine.h
tutorial/PyGraphicTutorialEngine.h
)
set( mocIncludes tutorial/GraphicTutorialEngine.h )
set( cpps TutorialEngine.cpp
GraphicTutorialEngine.cpp
)
set( pyCpps PyTutorial.cpp
PyTutorialEngine.cpp
PyGraphicTutorialEngine.cpp
)
qtX_wrap_cpp( mocCpps ${mocIncludes} )
set( depLibs ${CORIOLIS_PYTHON_LIBRARIES}
${CORIOLIS_LIBRARIES}
${HURRICANE_PYTHON_LIBRARIES}
${HURRICANE_GRAPHICAL_LIBRARIES}
${HURRICANE_LIBRARIES}
${CONFIGURATION_LIBRARY}
${BOOKSHELF_LIBRARY}
${CIF_LIBRARY}
${AGDS_LIBRARY}
${UTILITIES_LIBRARY}
${LEFDEF_LIBRARIES}
${OA_LIBRARIES}
${QtX_LIBRARIES}
${Boost_LIBRARIES}
${LIBXML2_LIBRARIES}
${PYTHON_LIBRARIES} -lutil
${LIBEXECINFO_LIBRARIES}
)
add_library( tutorial ${cpps} ${mocCpps} ${pyCpps} )
set_target_properties( tutorial PROPERTIES VERSION 1.0 SOVERSION 1 )
target_link_libraries( tutorial ${depLibs} )
add_python_module( "${pyCpps}"
"${pyIncludes}"
"Do_not_generate_C_library"
Tutorial
"tutorial;${depLibs}"
include/coriolis2/tutorial
)
install( TARGETS tutorial DESTINATION lib${LIB_SUFFIX} )
install( PROGRAMS tutorial.py DESTINATION bin RENAME tutorial )
install( FILES ${includes}
${mocIncludes} DESTINATION include/coriolis2/tutorial )

View File

@ -0,0 +1,184 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2017-2017, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | T o o l E n g i n e T u t o r i a l |
// | |
// | Author : Jean-Paul Chaput |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./GraphicTutorialEngine.cpp" |
// +-----------------------------------------------------------------+
#include <boost/bind.hpp>
#include <QAction>
#include <QMenu>
#include <QMenuBar>
#include <QApplication>
#include <hurricane/Warning.h>
#include <hurricane/Error.h>
#include <hurricane/Breakpoint.h>
#include <hurricane/DebugSession.h>
#include <hurricane/Go.h>
#include <hurricane/Net.h>
#include <hurricane/Cell.h>
#include <hurricane/viewer/Graphics.h>
#include <hurricane/viewer/CellWidget.h>
#include <hurricane/viewer/CellViewer.h>
#include <hurricane/viewer/ControllerWidget.h>
#include <hurricane/viewer/ExceptionWidget.h>
#include <crlcore/Utilities.h>
#include <crlcore/AllianceFramework.h>
#include <tutorial/GraphicTutorialEngine.h>
namespace Tutorial {
using namespace std;
using Hurricane::Error;
using Hurricane::Warning;
using Hurricane::Exception;
using Hurricane::Breakpoint;
using Hurricane::DebugSession;
using Hurricane::Point;
using Hurricane::Entity;
using Hurricane::Net;
using Hurricane::Graphics;
using Hurricane::ControllerWidget;
using Hurricane::ExceptionWidget;
using CRL::Catalog;
using CRL::AllianceFramework;
size_t GraphicTutorialEngine::_references = 0;
GraphicTutorialEngine* GraphicTutorialEngine::_singleton = NULL;
TutorialEngine* GraphicTutorialEngine::createEngine ()
{
Cell* cell = getCell ();
TutorialEngine* tutorial = TutorialEngine::get( cell );
if (not tutorial) {
tutorial = TutorialEngine::create( cell );
tutorial->setViewer( _viewer );
} else
cerr << Warning( "%s already has a Tutorial engine.", getString(cell).c_str() ) << endl;
return tutorial;
}
TutorialEngine* GraphicTutorialEngine::getForFramework ()
{
// Currently, only one framework is avalaible: Alliance.
TutorialEngine* tutorial = TutorialEngine::get( getCell() );
if (tutorial) return tutorial;
tutorial = createEngine();
if (not tutorial)
throw Error( "Failed to create Tutorial engine on %s.", getString(getCell()).c_str() );
return tutorial;
}
void GraphicTutorialEngine::_runDemoPart1 ()
{
TutorialEngine* tutorial = getForFramework();
Cell* demo = tutorial->runDemoPart1();
_viewer->setCell( demo );
}
void GraphicTutorialEngine::_runDemoPart2 ()
{
TutorialEngine* tutorial = getForFramework();
tutorial->runDemoPart2();
}
void GraphicTutorialEngine::addToMenu ( CellViewer* viewer )
{
assert( _viewer == NULL );
_viewer = viewer;
if (_viewer->hasMenuAction("tutorials.runDemoPart1")) {
cerr << Warning( "GraphicTutorialEngine::addToMenu() - Tutorial tool already hooked in." ) << endl;
return;
}
_viewer->addMenu ( "tutorials", "Tutorials", CellViewer::TopMenu );
_viewer->addToMenu( "tutorials.runDemoPart1"
, "Tutorial - &Run Demo, part 1"
, "Launch the Tutorial::runDemo() method."
, std::bind(&GraphicTutorialEngine::_runDemoPart1,this)
);
_viewer->addToMenu( "tutorials.runDemoPart2"
, "Tutorial - &Run Demo, part 2"
, "Launch the Tutorial::runDemo() method."
, std::bind(&GraphicTutorialEngine::_runDemoPart2,this)
);
}
const Name& GraphicTutorialEngine::getName () const
{ return TutorialEngine::staticGetName(); }
Cell* GraphicTutorialEngine::getCell ()
{
if (_viewer == NULL) {
throw Error( "<b>Tutorial:</b> GraphicTutorialEngine not bound to any Viewer." );
return NULL;
}
if (_viewer->getCell() == NULL) {
throw Error( "<b>Tutorial:</b> No Cell is loaded into the Viewer." );
return NULL;
}
return _viewer->getCell();
}
GraphicTutorialEngine* GraphicTutorialEngine::grab ()
{
if (not _references) {
_singleton = new GraphicTutorialEngine ();
}
_references++;
return _singleton;
}
size_t GraphicTutorialEngine::release ()
{
--_references;
if (not _references) {
delete _singleton;
_singleton = NULL;
}
return _references;
}
GraphicTutorialEngine::GraphicTutorialEngine ()
: GraphicTool()
, _viewer (NULL)
{ }
GraphicTutorialEngine::~GraphicTutorialEngine ()
{ }
} // Tutorial namespace.

View File

@ -0,0 +1,116 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2017-2017, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | T o o l E n g i n e T u t o r i a l |
// | |
// | Author : Jean-Paul Chaput |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./PyGraphicTutorialEngine.cpp" |
// +-----------------------------------------------------------------+
#include "tutorial/PyGraphicTutorialEngine.h"
#include "hurricane/isobar/PyCell.h"
#include "hurricane/Cell.h"
#undef ACCESS_OBJECT
#undef ACCESS_CLASS
#define ACCESS_OBJECT _baseObject._object
#define ACCESS_CLASS(_pyObject) &(_pyObject->_baseObject)
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(GraphicTutorialEngine,gtool,function)
namespace Tutorial {
using namespace Hurricane;
using namespace Isobar;
extern "C" {
// +=================================================================+
// | "PyGraphicTutorialEngine" Python Module Code Part |
// +=================================================================+
#if defined(__PYTHON_MODULE__)
static PyObject* PyGraphicTutorialEngine_grab ( PyObject* )
{
cdebug_log(40,0) << "PyGraphicTutorialEngine_grab()" << endl;
PyGraphicTutorialEngine* pyGraphicTutorialEngine = NULL;
HTRY
pyGraphicTutorialEngine = PyObject_NEW ( PyGraphicTutorialEngine, &PyTypeGraphicTutorialEngine );
if ( pyGraphicTutorialEngine == NULL ) return NULL;
pyGraphicTutorialEngine->ACCESS_OBJECT = GraphicTutorialEngine::grab();
HCATCH
return (PyObject*)pyGraphicTutorialEngine;
}
static PyObject* PyGraphicTutorialEngine_getCell ( PyGraphicTutorialEngine* self )
{
cdebug_log(40,0) << "PyGraphicTutorialEngine_getCell ()" << endl;
Cell* cell = NULL;
HTRY
METHOD_HEAD("GraphicTutorialEngine.getCell()")
cell = gtool->getCell ();
HCATCH
if (cell == NULL) Py_RETURN_NONE;
return PyCell_Link(cell);
}
GetNameMethod(GraphicTutorialEngine, gtool)
// Standart destroy (Attribute).
PyMethodDef PyGraphicTutorialEngine_Methods[] =
{ { "grab" , (PyCFunction)PyGraphicTutorialEngine_grab , METH_NOARGS|METH_STATIC
, "Returns the GraphicTutorialEngine singleton." }
, { "getName" , (PyCFunction)PyGraphicTutorialEngine_getName , METH_NOARGS
, "Returns the name of the GraphicTutorialEngine (class attribute)." }
, { "getCell" , (PyCFunction)PyGraphicTutorialEngine_getCell , METH_NOARGS
, "Returns the Cell on which this GraphicTutorialEngine is attached." }
, {NULL, NULL, 0, NULL} /* sentinel */
};
// ---------------------------------------------------------------
// PyGraphicTutorialEngine Type Methods.
PythonOnlyDeleteMethod(GraphicTutorialEngine)
PyTypeObjectLinkPyType(GraphicTutorialEngine)
#else // End of Python Module Code Part.
// +=================================================================+
// | "PyGraphicTutorialEngine" Shared Library Code Part |
// +=================================================================+
// Link/Creation Method.
LinkCreateMethod(GraphicTutorialEngine)
PyTypeInheritedObjectDefinitions(GraphicTutorialEngine,GraphicTool)
#endif // End of Shared Library Code Part.
} // extern "C".
} // Tutorial namespace.

View File

@ -0,0 +1,91 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2017-2017, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | T o o l E n g i n e T u t o r i a l |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./PyTutorial.cpp" |
// +-----------------------------------------------------------------+
#include "hurricane/isobar/PyHurricane.h"
#include "hurricane/isobar/PyCell.h"
#include "tutorial/PyTutorialEngine.h"
#include "tutorial/PyGraphicTutorialEngine.h"
namespace Tutorial {
using std::cerr;
using std::endl;
using Hurricane::tab;
using Isobar::__cs;
using CRL::PyTypeToolEngine;
using CRL::PyTypeGraphicTool;
#if !defined(__PYTHON_MODULE__)
// +=================================================================+
// | "PyTutorial" Shared Library Code Part |
// +=================================================================+
# else // End of PyHurricane Shared Library Code Part.
// +=================================================================+
// | "PyTutorial" Python Module Code Part |
// +=================================================================+
extern "C" {
// +-------------------------------------------------------------+
// | "PyTutorial" Module Methods |
// +-------------------------------------------------------------+
static PyMethodDef PyTutorial_Methods[] =
{ {NULL, NULL, 0, NULL} /* sentinel */
};
// ---------------------------------------------------------------
// Module Initialization : "initTutorial ()"
DL_EXPORT(void) initTutorial () {
cdebug_log(40,0) << "initTutorial()" << endl;
PyTutorialEngine_LinkPyType();
PyGraphicTutorialEngine_LinkPyType();
PYTYPE_READY_SUB( TutorialEngine , ToolEngine );
PYTYPE_READY_SUB( GraphicTutorialEngine, GraphicTool );
PyObject* module = Py_InitModule( "Tutorial", PyTutorial_Methods );
if (module == NULL) {
cerr << "[ERROR]\n"
<< " Failed to initialize Tutorial module." << endl;
return;
}
Py_INCREF( &PyTypeTutorialEngine );
PyModule_AddObject( module, "TutorialEngine", (PyObject*)&PyTypeTutorialEngine );
Py_INCREF( &PyTypeGraphicTutorialEngine );
PyModule_AddObject( module, "GraphicTutorialEngine", (PyObject*)&PyTypeGraphicTutorialEngine );
}
} // End of extern "C".
#endif // Python Module Code Part.
} // Tutorial namespace.

View File

@ -0,0 +1,218 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2017-2017, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | T o o l E n g i n e T u t o r i a l |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./PyTutorialEngine.cpp" |
// +-----------------------------------------------------------------+
#include "hurricane/isobar/PyCell.h"
#include "hurricane/viewer/PyCellViewer.h"
#include "hurricane/viewer/ExceptionWidget.h"
#include "hurricane/Cell.h"
#include "crlcore/Utilities.h"
#include "tutorial/PyTutorialEngine.h"
#include <functional>
# undef ACCESS_OBJECT
# undef ACCESS_CLASS
# define ACCESS_OBJECT _baseObject._object
# define ACCESS_CLASS(_pyObject) &(_pyObject->_baseObject)
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(TutorialEngine,tutorial,function)
namespace Tutorial {
using std::cerr;
using std::endl;
using std::hex;
using std::ostringstream;
using Hurricane::tab;
using Hurricane::Exception;
using Hurricane::Bug;
using Hurricane::Error;
using Hurricane::Warning;
using Hurricane::ExceptionWidget;
using Isobar::ProxyProperty;
using Isobar::ProxyError;
using Isobar::ConstructorError;
using Isobar::HurricaneError;
using Isobar::HurricaneWarning;
using Isobar::ParseOneArg;
using Isobar::ParseTwoArg;
using Isobar::PyCell;
using Isobar::PyCell_Link;
using Isobar::PyCellViewer;
using Isobar::PyTypeCellViewer;
using CRL::PyToolEngine;
extern "C" {
#if defined(__PYTHON_MODULE__)
// +=================================================================+
// | "PyTutorialEngine" Python Module Code Part |
// +=================================================================+
static PyObject* PyTutorialEngine_get ( PyObject*, PyObject* args )
{
cdebug_log(40,0) << "PyTutorialEngine_get()" << endl;
TutorialEngine* tutorial = NULL;
HTRY
PyObject* arg0;
if (not ParseOneArg("Tutorial.get", args, CELL_ARG, &arg0)) return NULL;
tutorial = TutorialEngine::get(PYCELL_O(arg0));
HCATCH
return PyTutorialEngine_Link(tutorial);
}
static PyObject* PyTutorialEngine_create ( PyObject*, PyObject* args )
{
cdebug_log(40,0) << "PyTutorialEngine_create()" << endl;
TutorialEngine* tutorial = NULL;
HTRY
PyObject* arg0;
if (not ParseOneArg("Tutorial.get", args, CELL_ARG, &arg0)) return NULL;
Cell* cell = PYCELL_O(arg0);
tutorial = TutorialEngine::get(cell);
if (tutorial == NULL) {
tutorial = TutorialEngine::create(cell);
} else
cerr << Warning("%s already has a Tutorial engine.",getString(cell).c_str()) << endl;
HCATCH
return PyTutorialEngine_Link(tutorial);
}
static PyObject* PyTutorialEngine_setViewer ( PyTutorialEngine* self, PyObject* args )
{
cdebug_log(40,0) << "PyTutorialEngine_setViewer ()" << endl;
HTRY
METHOD_HEAD( "TutorialEngine.setViewer()" )
PyObject* pyViewer = NULL;
if (not PyArg_ParseTuple(args,"O:EtesianEngine.setViewer()",&pyViewer)) {
PyErr_SetString( ConstructorError, "Bad parameters given to EtesianEngine.setViewer()." );
return NULL;
}
if (IsPyCellViewer(pyViewer)) {
tutorial->setViewer( PYCELLVIEWER_O(pyViewer) );
}
HCATCH
Py_RETURN_NONE;
}
PyObject* PyTutorialEngine_runDemoPart1 ( PyTutorialEngine* self )
{
cdebug_log(40,0) << "PyTutorialEngine_runDemoPart1()" << endl;
Cell* cell = NULL;
HTRY
METHOD_HEAD("TutorialEngine.runDemoPart1()")
if (tutorial->getViewer()) {
if (ExceptionWidget::catchAllWrapper( std::bind(&TutorialEngine::runDemoPart1,tutorial) )) {
PyErr_SetString( HurricaneError, "TutorialEngine::runDemoPart1() has thrown an exception (C++)." );
return NULL;
}
cell = tutorial->getCell();
} else {
cell = tutorial->runDemoPart1();
}
HCATCH
return PyCell_Link( cell );
}
PyObject* PyTutorialEngine_runDemoPart2 ( PyTutorialEngine* self )
{
cdebug_log(40,0) << "PyTutorialEngine_runDemoPart2()" << endl;
HTRY
METHOD_HEAD("TutorialEngine.runDemoPart2()")
if (tutorial->getViewer()) {
if (ExceptionWidget::catchAllWrapper( std::bind(&TutorialEngine::runDemoPart1,tutorial) )) {
PyErr_SetString( HurricaneError, "TutorialEngine::runDemoPart2() has thrown an exception (C++)." );
return NULL;
}
} else {
tutorial->runDemoPart2();
}
HCATCH
Py_RETURN_NONE;
}
// Standart Accessors (Attributes).
// Standart Destroy (Attribute).
DBoDestroyAttribute(PyTutorialEngine_destroy,PyTutorialEngine)
PyMethodDef PyTutorialEngine_Methods[] =
{ { "get" , (PyCFunction)PyTutorialEngine_get , METH_VARARGS|METH_STATIC
, "Returns the Tutorial engine attached to the Cell, None if there isnt't." }
, { "create" , (PyCFunction)PyTutorialEngine_create , METH_VARARGS|METH_STATIC
, "Create a Tutorial engine on this cell." }
, { "setViewer" , (PyCFunction)PyTutorialEngine_setViewer , METH_VARARGS
, "Associate a Viewer to this TutorialEngine." }
, { "runDemoPart1" , (PyCFunction)PyTutorialEngine_runDemoPart1 , METH_NOARGS
, "Run the first part of the demo." }
, { "runDemoPart2" , (PyCFunction)PyTutorialEngine_runDemoPart2 , METH_NOARGS
, "Run the second part of the demo." }
, { "destroy" , (PyCFunction)PyTutorialEngine_destroy , METH_NOARGS
, "Destroy the associated hurricane object. The python object remains." }
, {NULL, NULL, 0, NULL} /* sentinel */
};
DBoDeleteMethod(TutorialEngine)
PyTypeObjectLinkPyType(TutorialEngine)
#else // End of Python Module Code Part.
// +=================================================================+
// | "PyTutorialEngine" Shared Library Code Part |
// +=================================================================+
// Link/Creation Method.
PyTypeInheritedObjectDefinitions(TutorialEngine,PyToolEngine)
DBoLinkCreateMethod(TutorialEngine)
#endif // Shared Library Code Part.
} // extern "C".
} // Tutorial namespace.

View File

@ -0,0 +1,274 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2017-2017, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | T o o l E n g i n e T u t o r i a l |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Module : "./TutorialEngine.cpp" |
// +-----------------------------------------------------------------+
#include <Python.h>
#include <sstream>
#include <fstream>
#include <iomanip>
#include "vlsisapd/utilities/Path.h"
#include "hurricane/DebugSession.h"
#include "hurricane/UpdateSession.h"
#include "hurricane/Bug.h"
#include "hurricane/Error.h"
#include "hurricane/Warning.h"
#include "hurricane/DataBase.h"
#include "hurricane/Technology.h"
#include "hurricane/Breakpoint.h"
#include "hurricane/Layer.h"
#include "hurricane/Net.h"
#include "hurricane/RoutingPad.h"
#include "hurricane/Plug.h"
#include "hurricane/Cell.h"
#include "hurricane/Instance.h"
#include "hurricane/Vertical.h"
#include "hurricane/Horizontal.h"
#include "crlcore/AllianceFramework.h"
#include "tutorial/TutorialEngine.h"
namespace Tutorial {
using namespace std;
using Hurricane::dbo_ptr;
using Hurricane::UpdateSession;
using Hurricane::DebugSession;
using Hurricane::tab;
using Hurricane::Bug;
using Hurricane::Error;
using Hurricane::Warning;
using Hurricane::Breakpoint;
using Hurricane::Timer;
using Hurricane::DbU;
using Hurricane::Box;
using Hurricane::Layer;
using Hurricane::DataBase;
using Hurricane::Technology;
using Hurricane::Component;
using Hurricane::Contact;
using Hurricane::Horizontal;
using Hurricane::Vertical;
using Hurricane::RoutingPad;
using Hurricane::Cell;
using Hurricane::Plug;
using Hurricane::Instance;
using Hurricane::Transformation;
using Hurricane::Occurrence;
// -------------------------------------------------------------------
// Class : "Tutorial::TutorialEngine".
Name TutorialEngine::_toolName = "Tutorial";
const Name& TutorialEngine::staticGetName ()
{ return _toolName; }
TutorialEngine* TutorialEngine::get ( const Cell* cell )
{ return static_cast<TutorialEngine*>(ToolEngine::get(cell,staticGetName())); }
TutorialEngine::TutorialEngine ( Cell* cell )
: Super (cell)
, _viewer (NULL)
{ }
void TutorialEngine::_postCreate ()
{
Super::_postCreate ();
}
TutorialEngine* TutorialEngine::create ( Cell* cell )
{
TutorialEngine* tutorial = new TutorialEngine ( cell );
tutorial->_postCreate();
return tutorial;
}
void TutorialEngine::_preDestroy ()
{ }
TutorialEngine::~TutorialEngine ()
{ }
const Name& TutorialEngine::getName () const
{ return _toolName; }
Cell* TutorialEngine::runDemoPart1 ()
{
cerr << "TutorialEngine::runDemoPart1() has been called." << endl;
CRL::AllianceFramework* framework = CRL::AllianceFramework::get();
UpdateSession::open();
Cell* demo = framework->createCell( "demo_cell_2" );
demo->setAbutmentBox( Box( DbU::fromLambda( 0.0)
, DbU::fromLambda( 0.0)
, DbU::fromLambda(135.0)
, DbU::fromLambda(110.0)
) );
// Instanciation & placement of "i1_xr2".
Cell* model = framework->getCell( "xr2_x1", CRL::Catalog::State::Views );
Instance* i1_xr2 = Instance::create( demo, "i1_xr2", model );
i1_xr2->setTransformation( Transformation( DbU::fromLambda( 0.0 )
, DbU::fromLambda( 0.0 )
, Transformation::Orientation::ID
) );
i1_xr2->setPlacementStatus( Instance::PlacementStatus::PLACED );
// Instanciation & placement of "i2_xr2".
model = framework->getCell( "xr2_x1", CRL::Catalog::State::Views );
Instance* i2_xr2 = Instance::create( demo, "i2_xr2", model );
i2_xr2->setTransformation( Transformation( DbU::fromLambda( 55.0 )
, DbU::fromLambda( 0.0 )
, Transformation::Orientation::ID
) );
i2_xr2->setPlacementStatus( Instance::PlacementStatus::PLACED );
// Instanciation & placement of "i3_a2".
model = framework->getCell( "a2_x2", CRL::Catalog::State::Views );
Instance* i3_a2 = Instance::create( demo, "i3_a2", model );
i3_a2->setTransformation( Transformation( DbU::fromLambda( 0.0 )
, DbU::fromLambda( 100.0 )
, Transformation::Orientation::MY
) );
i3_a2->setPlacementStatus( Instance::PlacementStatus::PLACED );
// Instanciation & placement of "i4_a2".
model = framework->getCell( "a2_x2", CRL::Catalog::State::Views );
Instance* i4_a2 = Instance::create( demo, "i4_a2", model );
i4_a2->setTransformation( Transformation( DbU::fromLambda( 55.0 )
, DbU::fromLambda( 100.0 )
, Transformation::Orientation::MY
) );
i4_a2->setPlacementStatus( Instance::PlacementStatus::PLACED );
// Instanciation & placement of "i1_xr2".
model = framework->getCell( "o2_x2", CRL::Catalog::State::Views );
Instance* i5_o2 = Instance::create( demo, "i5_o2", model );
i5_o2->setTransformation( Transformation( DbU::fromLambda( 110.0 )
, DbU::fromLambda( 0.0 )
, Transformation::Orientation::ID
) );
i5_o2->setPlacementStatus( Instance::PlacementStatus::PLACED );
UpdateSession::close();
return demo;
}
void TutorialEngine::runDemoPart2 ()
{
cerr << "TutorialEngine::runDemoPart2() has been called." << endl;
Cell* cell = getCell();
UpdateSession::open();
Net* net = Net::create( cell, "demo" );
Instance* i1_xr2 = cell->getInstance( "i1_xr2" );
Plug* plug = i1_xr2->getPlug( i1_xr2->getMasterCell()->getNet("q") );
plug->setNet( net );
RoutingPad* rp1 = RoutingPad::create( net, Occurrence(plug) );
rp1->setOnBestComponent( RoutingPad::BiggestArea );
Instance* i2_xr2 = cell->getInstance( "i2_xr2" );
plug = i2_xr2->getPlug( i2_xr2->getMasterCell()->getNet("i0") );
plug->setNet( net );
RoutingPad* rp2 = RoutingPad::create( net, Occurrence(plug) );
rp2->setOnBestComponent( RoutingPad::BiggestArea );
Instance* i4_a2 = cell->getInstance( "i4_a2" );
plug = i4_a2->getPlug( i4_a2->getMasterCell()->getNet("i0") );
plug->setNet( net );
RoutingPad* rp3 = RoutingPad::create( net, Occurrence(plug) );
rp3->setOnBestComponent( RoutingPad::BiggestArea );
UpdateSession::close();
Breakpoint::stop( 1, "RoutingPad createds" );
UpdateSession::open();
Technology* technology = DataBase::getDB()->getTechnology();
Layer* metal2 = technology->getLayer( "METAL2" );
Layer* metal3 = technology->getLayer( "METAL3" );
Layer* via1 = technology->getLayer( "VIA12" );
Layer* via2 = technology->getLayer( "VIA23" );
Contact* contact1 = Contact::create( rp1, via1, DbU::fromLambda( 0.0), DbU::fromLambda( 0.0) );
Contact* contact2 = Contact::create( rp2, via1, DbU::fromLambda( 0.0), DbU::fromLambda(-5.0) );
Contact* contact3 = Contact::create( rp3, via1, DbU::fromLambda( 0.0), DbU::fromLambda( 0.0) );
Contact* contact4 = Contact::create( net, via2, DbU::fromLambda(50.0), DbU::fromLambda(20.0) );
Contact* contact5 = Contact::create( net, via2, DbU::fromLambda(50.0), DbU::fromLambda(75.0) );
Horizontal::create( contact1, contact4, metal2, DbU::fromLambda(20.0), DbU::fromLambda(2.0) );
Horizontal::create( contact4, contact2, metal2, DbU::fromLambda(20.0), DbU::fromLambda(2.0) );
Horizontal::create( contact5, contact3, metal2, DbU::fromLambda(75.0), DbU::fromLambda(2.0) );
Vertical::create ( contact4, contact5, metal3, DbU::fromLambda(50.0), DbU::fromLambda(2.0) );
UpdateSession::close();
cout << "All components of " << net << endl;
for ( Component* component : net->getComponents() ) {
cout << "| " << component << endl;
}
Breakpoint::stop( 1, "Contacts and wires createds" );
UpdateSession::open();
contact5->destroy();
UpdateSession::close();
}
string TutorialEngine::_getTypeName () const
{ return "Tutorial::TutorialEngine"; }
string TutorialEngine::_getString () const
{
ostringstream os;
os << "<" << "TutorialEngine " << _cell->getName () << ">";
return os.str();
}
Record* TutorialEngine::_getRecord () const
{
Record* record = Super::_getRecord ();
if (record) {
// Add new records here.
}
return record;
}
} // Tutorial namespace.

122
tutorial/src/tutorial.py Executable file
View File

@ -0,0 +1,122 @@
#!/usr/bin/env python
try:
import sys
import os.path
import optparse
import Cfg
import Hurricane
import Viewer
from helpers import showPythonTrace
import CRL
import Unicorn
import Tutorial
except ImportError, e:
serror = str(e)
if serror.startswith('No module named'):
module = serror.split()[-1]
print '[ERROR] The <%s> python module or symbol cannot be loaded.' % module
print ' Please check the integrity of the <coriolis> package.'
if serror.find('cannot open shared object file'):
library = serror.split(':')[0]
print '[ERROR] The <%s> shared library cannot be loaded.' % library
print ' Under RHEL 6, you must be under devtoolset-2.'
print ' (scl enable devtoolset-2 bash)'
sys.exit(1)
except Exception, e:
print '[ERROR] A strange exception occurred while loading the basic Coriolis/Python'
print ' modules. Something may be wrong at Python/C API level.\n'
print ' %s' % e
sys.exit(2)
def setCgtBanner ( banner ):
banner.setName('tutu')
banner.setPurpose('Tutorial for Users')
return banner
def credits ():
s = ''
s += ' Tool Credits\n'
s += ' Hurricane .................... Remy Escassut & Christian Masson\n'
return s
if __name__ == '__main__':
try:
usage = str(setCgtBanner(CRL.Banner()))
usage += '\ncgt [options]'
parser = optparse.OptionParser(usage)
parser.add_option( '--no-init' , action='store_true', dest='noInit' , help='Do not load any initialization.')
parser.add_option( '-c', '--cell' , type='string' , dest='cell' , help='The name of the cell to load, whithout extension.')
parser.add_option( '--acm-sigda-89' , type='string' , dest='acmSigdaName' , help='An ACM/SIGDA 89 bench name to load, whithout extension.')
parser.add_option( '--blif' , type='string' , dest='blifName' , help='A Blif (Yosys) design name to load, whithout extension.')
parser.add_option( '--ispd-05' , type='string' , dest='ispd05name' , help='An ISPD 05 bench (placement) name to load, whithout extension.')
parser.add_option( '-v', '--verbose' , action='store_true', dest='verbose' , help='First level of verbosity.')
parser.add_option( '-V', '--very-verbose' , action='store_true', dest='veryVerbose' , help='Second level of verbosity.')
parser.add_option( '-i', '--info' , action='store_true', dest='info' , help='Display lots of informational messages.')
parser.add_option( '--paranoid' , action='store_true', dest='paranoid' , help='Display everything that *may be* suspicious...')
parser.add_option( '-b', '--bug' , action='store_true', dest='bug' , help='Display bug related messages.')
parser.add_option( '--show-conf' , action='store_true', dest='showConf' , help='Display Kite configuration.')
parser.add_option( '-D', '--core-dump' , action='store_true', dest='coreDump' , help='Enable core-dump when a crash occurs.')
parser.add_option( '-L', '--log-mode' , action='store_true', dest='logMode' , help='Disable ANSI escape sequences in console output.')
(options, args) = parser.parse_args()
args.insert(0, 'tutu')
flags = 0
if options.noInit:
flags |= CRL.AllianceFramework.NoPythonInit
af = CRL.AllianceFramework.create( flags )
print af.getEnvironment().getPrint()
Cfg.Configuration.pushDefaultPriority(Cfg.Parameter.Priority.CommandLine)
if options.coreDump: Cfg.getParamBool ('misc.catchCore' ).setBool(False)
if options.verbose: Cfg.getParamBool ('misc.verboseLevel1').setBool(True)
if options.veryVerbose: Cfg.getParamBool ('misc.verboseLevel2').setBool(True)
if options.info: Cfg.getParamBool ('misc.info' ).setBool(True)
if options.paranoid: Cfg.getParamBool ('misc.paranoid' ).setBool(True)
if options.bug: Cfg.getParamBool ('misc.bug' ).setBool(True)
if options.logMode: Cfg.getParamBool ('misc.logMode' ).setBool(True)
if options.showConf: Cfg.getParamBool ('misc.showConf' ).setBool(True)
Cfg.Configuration.popDefaultPriority()
cell = None
if options.acmSigdaName:
cell = CRL.AcmSigda.load(options.acmSigdaName)
elif options.ispd05name:
cell = CRL.Ispd05.load(options.ispd05name)
elif options.blifName:
cell = CRL.Blif.load(options.blifName)
elif options.cell:
cell = af.getCell(options.cell, CRL.Catalog.State.Views)
# Run in graphic mode.
ha = Viewer.HApplication.create(args)
Viewer.Graphics.enable()
unicorn = Unicorn.UnicornGui.create()
unicorn.setApplicationName ('tutu')
unicorn.registerTool (Tutorial.GraphicTutorialEngine.grab())
unicorn.setLayerVisible ("grid" , False);
unicorn.setLayerVisible ("text.instance" , False);
unicorn.setLayerVisible ("text.component", False);
setCgtBanner(unicorn.getBanner())
print unicorn.getBanner()
print credits()
if cell: unicorn.setCell(cell)
unicorn.show()
ha.qtExec()
except Exception, e:
showPythonTrace( sys.argv[0], e )
sys.exit(0)

View File

@ -0,0 +1,76 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2017-2017, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | T o o l E n g i n e T u t o r i a l |
// | |
// | Author : Jean-Paul Chaput |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./tutorial/GraphicTutorialEngine.h" |
// +-----------------------------------------------------------------+
#ifndef TUTORIAL_GRAPHIC_TUTORIAL_ENGINE_H
#define TUTORIAL_GRAPHIC_TUTORIAL_ENGINE_H
#include <functional>
#include <QObject>
namespace Hurricane {
class Go;
class BasicLayer;
class Transformation;
class CellWidget;
class CellViewer;
}
#include "crlcore/GraphicToolEngine.h"
#include "tutorial/TutorialEngine.h"
namespace Tutorial {
using Hurricane::Go;
using Hurricane::Box;
using Hurricane::BasicLayer;
using Hurricane::Transformation;
using Hurricane::CellWidget;
using Hurricane::CellViewer;
using CRL::GraphicTool;
// -------------------------------------------------------------------
// Class : "Tutorial::GraphicTutorialEngine".
class GraphicTutorialEngine : public GraphicTool {
Q_OBJECT;
public:
TutorialEngine* createEngine ();
TutorialEngine* getForFramework ();
static GraphicTutorialEngine* grab ();
virtual const Name& getName () const;
Cell* getCell ();
virtual size_t release ();
virtual void addToMenu ( CellViewer* );
void postEvent ();
protected:
GraphicTutorialEngine ();
virtual ~GraphicTutorialEngine ();
void _runDemoPart1 ();
void _runDemoPart2 ();
protected:
static size_t _references;
static GraphicTutorialEngine* _singleton;
CellViewer* _viewer;
};
} // Tutorial namespace.
#endif // TUTORIAL_GRAPHIC_TUTORIAL_ENGINE_H

View File

@ -0,0 +1,55 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2017-2017, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | T o o l E n g i n e T u t o r i a l |
// | |
// | Author : Jean-Paul Chaput |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./tutorial/PyGraphicTutorialEngine.h" |
// +-----------------------------------------------------------------+
#ifndef TUTORIAL_PY_GRAPHIC_TUTORIAL_ENGINE_H
#define TUTORIAL_PY_GRAPHIC_TUTORIAL_ENGINE_H
#include "crlcore/PyGraphicToolEngine.h"
#include "tutorial/GraphicTutorialEngine.h"
namespace Tutorial {
extern "C" {
// -------------------------------------------------------------------
// Python Object : "PyGraphicTutorialEngine".
typedef struct {
CRL::PyGraphicTool _baseObject;
} PyGraphicTutorialEngine;
// -------------------------------------------------------------------
// Functions & Types exported to "PyTutorial.ccp".
extern PyTypeObject PyTypeGraphicTutorialEngine;
extern PyMethodDef PyGraphicTutorialEngine_Methods[];
extern void PyGraphicTutorialEngine_LinkPyType ();
#define IsPyGraphicTutorialEngine(v) ( (v)->ob_type == &PyTypeGraphicTutorialEngine )
#define PY_GRAPHIC_TUTORIAL_ENGINE(v) ( (PyGraphicTutorialEngine*)(v) )
#define PY_GRAPHIC_TUTORIAL_ENGINE_O(v) ( PY_GRAPHIC_TUTORIAL_ENGINE(v)->_baseObject._object )
} // extern "C".
} // Tutorial namespace.
#endif // TUTORIAL_PY_GRAPHIC_TUTORIAL_ENGINE_H

View File

@ -0,0 +1,58 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2017-2017, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | T o o l E n g i n e T u t o r i a l |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./tutorial/PyTutorialEngine.cpp" |
// +-----------------------------------------------------------------+
#ifndef PY_TUTORIAL_ENGINE_H
#define PY_TUTORIAL_ENGINE_H
#include "hurricane/isobar/PyHurricane.h"
#include "crlcore/PyToolEngine.h"
#include "tutorial/TutorialEngine.h"
namespace Tutorial {
extern "C" {
// -------------------------------------------------------------------
// Python Object : "PyTutorialEngine".
typedef struct {
CRL::PyToolEngine _baseObject;
} PyTutorialEngine;
// -------------------------------------------------------------------
// Functions & Types exported to "PyTutorial.ccp".
extern PyTypeObject PyTypeTutorialEngine;
extern PyMethodDef PyTutorialEngine_Methods[];
extern PyObject* PyTutorialEngine_Link ( Tutorial::TutorialEngine* );
extern void PyTutorialEngine_LinkPyType ();
extern void PyTutorialEngine_postModuleInit ();
#define IsPyTutorialEngine(v) ( (v)->ob_type == &PyTypeTutorialEngine )
#define PYTUTORIALENGINE(v) ( (PyTutorialEngine*)(v) )
#define PYTUTORIALENGINE_O(v) ( PYTUTORIALENGINE(v)->_baseObject._object )
} // extern "C".
} // Tutorial namespace.
#endif // PY_TUTORIAL_ENGINE_H

View File

@ -0,0 +1,93 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC 2017-2017, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | T o o l E n g i n e T u t o r i a l |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== |
// | C++ Header : "./tutorial/TutorialEngine.h" |
// +-----------------------------------------------------------------+
#ifndef TUTORIAL_TUTORIAL_ENGINE_H
#define TUTORIAL_TUTORIAL_ENGINE_H
#include <string>
#include <iostream>
#include "hurricane/Name.h"
namespace Hurricane {
class Layer;
class Net;
class Cell;
class CellViewer;
}
#include "crlcore/ToolEngine.h"
namespace Tutorial {
using Hurricane::Record;
using Hurricane::Name;
using Hurricane::Layer;
using Hurricane::Net;
using Hurricane::Cell;
using Hurricane::CellViewer;
using CRL::ToolEngine;
// -------------------------------------------------------------------
// Class : "Tutorial::TutorialEngine".
class TutorialEngine : public ToolEngine {
public:
typedef ToolEngine Super;
public:
static const Name& staticGetName ();
static TutorialEngine* create ( Cell* );
static TutorialEngine* get ( const Cell* );
public:
inline CellViewer* getViewer () const;
inline ToolEngine* base ();
virtual const Name& getName () const;
inline void setViewer ( CellViewer* );
Cell* runDemoPart1 ();
void runDemoPart2 ();
virtual Record* _getRecord () const;
virtual std::string _getString () const;
virtual std::string _getTypeName () const;
protected:
// Constructors & Destructors.
TutorialEngine ( Cell* );
virtual ~TutorialEngine ();
virtual void _postCreate ();
virtual void _preDestroy ();
private:
TutorialEngine ( const TutorialEngine& );
TutorialEngine& operator= ( const TutorialEngine& );
private:
// Attributes.
static Name _toolName;
protected:
CellViewer* _viewer;
};
// Inline Functions.
inline CellViewer* TutorialEngine::getViewer () const { return _viewer; }
inline ToolEngine* TutorialEngine::base () { return static_cast<ToolEngine*>(this); }
inline void TutorialEngine::setViewer ( CellViewer* viewer ) { _viewer=viewer; }
} // Tutorial namespace.
INSPECTOR_P_SUPPORT(Tutorial::TutorialEngine);
#endif // TUTORIAL_TUTORIAL_ENGINE_H