* ./hurricane/sr/isobar:

- New: In PyComponent, added support for getConnexComponents() and
        getSlaveComponents().
This commit is contained in:
Jean-Paul Chaput 2013-04-18 10:55:34 +00:00
parent fc805bf500
commit 84dfbe2980
2 changed files with 80 additions and 65 deletions

View File

@ -1,19 +1,19 @@
// -*- C++ -*-
// //
// $Id: PyComponent.cpp,v 1.17 2008/02/07 17:09:41 xtof Exp $ // This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2013, 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 |
// | | // | |
// | 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++ Module : "./PyComponent.cpp" | // | C++ Module : "./PyComponents.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/isobar/PyNet.h" #include "hurricane/isobar/PyNet.h"
#include "hurricane/isobar/PyLayer.h" #include "hurricane/isobar/PyLayer.h"
@ -26,16 +26,16 @@
#include "hurricane/isobar/PyVertical.h" #include "hurricane/isobar/PyVertical.h"
#include "hurricane/isobar/PyContact.h" #include "hurricane/isobar/PyContact.h"
#include "hurricane/isobar/PyPin.h" #include "hurricane/isobar/PyPin.h"
#include "hurricane/isobar/PyComponentCollection.h"
namespace Isobar { namespace Isobar {
using namespace Hurricane; using namespace Hurricane;
extern "C" { extern "C" {
#undef ACCESS_OBJECT #undef ACCESS_OBJECT
#undef ACCESS_CLASS #undef ACCESS_CLASS
#define ACCESS_OBJECT _baseObject._object #define ACCESS_OBJECT _baseObject._object
@ -43,18 +43,13 @@ extern "C" {
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Component,component,function) #define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Component,component,function)
// x=================================================================x // +=================================================================+
// | "PyComponent" Python Module Code Part | // | "PyComponent" Python Module Code Part |
// x=================================================================x // +=================================================================+
#if defined(__PYTHON_MODULE__) #if defined(__PYTHON_MODULE__)
// x-------------------------------------------------------------x
// | "PyComponent" Attribute Methods |
// x-------------------------------------------------------------x
// Standart Accessors (Attributes). // Standart Accessors (Attributes).
DirectGetLongAttribute(PyComponent_getX,getX,PyComponent,Component) DirectGetLongAttribute(PyComponent_getX,getX,PyComponent,Component)
DirectGetLongAttribute(PyComponent_getY,getY,PyComponent,Component) DirectGetLongAttribute(PyComponent_getY,getY,PyComponent,Component)
@ -63,9 +58,8 @@ extern "C" {
DBoDestroyAttribute(PyComponent_destroy,PyComponent) DBoDestroyAttribute(PyComponent_destroy,PyComponent)
// --------------------------------------------------------------- static PyObject* PyComponent_getPosition ( PyComponent *self )
// Attribute Method : "PyComponent_getPosition ()" {
static PyObject* PyComponent_getPosition ( PyComponent *self ) {
trace << "PyComponent_getPosition ()" << endl; trace << "PyComponent_getPosition ()" << endl;
METHOD_HEAD ( "Component.getPosition()" ) METHOD_HEAD ( "Component.getPosition()" )
@ -80,10 +74,8 @@ extern "C" {
} }
// --------------------------------------------------------------- static PyObject* PyComponent_getNet ( PyComponent *self )
// Attribute Method : "PyComponent_getNet ()" {
static PyObject* PyComponent_getNet ( PyComponent *self ) {
trace << "PyComponent_getNet ()" << endl; trace << "PyComponent_getNet ()" << endl;
Net* net = NULL; Net* net = NULL;
@ -97,10 +89,9 @@ extern "C" {
return PyNet_Link ( net ); return PyNet_Link ( net );
} }
// ---------------------------------------------------------------
// Attribute Method : "PyComponent_getLayer ()"
static PyObject* PyComponent_getLayer ( PyComponent *self ) { static PyObject* PyComponent_getLayer ( PyComponent *self )
{
trace << "PyComponent_getLayer ()" << endl; trace << "PyComponent_getLayer ()" << endl;
METHOD_HEAD ( "Component.getLayer()" ) METHOD_HEAD ( "Component.getLayer()" )
@ -130,9 +121,6 @@ extern "C" {
} }
// ---------------------------------------------------------------
// Attribute Method : "PyComponent_getBoundingBox ()"
static PyObject* PyComponent_getBoundingBox ( PyComponent *self, PyObject* args ) static PyObject* PyComponent_getBoundingBox ( PyComponent *self, PyObject* args )
{ {
trace << "PyComponent_getBoundingBox ()" << endl; trace << "PyComponent_getBoundingBox ()" << endl;
@ -163,9 +151,49 @@ extern "C" {
} }
static PyObject* PyComponent_getConnexComponents ( PyComponent *self )
{
trace << "PyComponent_getConnexComponents()" << endl;
METHOD_HEAD( "PyComponent.getConnexComponents()" )
PyComponentCollection* pyComponentCollection = NULL;
HTRY
Components* components = new Components(component->getConnexComponents());
pyComponentCollection = PyObject_NEW( PyComponentCollection, &PyTypeComponentCollection );
if (pyComponentCollection == NULL) {
return NULL;
}
pyComponentCollection->_object = components;
HCATCH
return (PyObject*)pyComponentCollection;
}
static PyObject* PyComponent_getSlaveComponents ( PyComponent *self )
{
trace << "PyComponent_getSlaveComponents()" << endl;
METHOD_HEAD( "PyComponent.getSlaveComponents()" )
PyComponentCollection* pyComponentCollection = NULL;
HTRY
Components* components = new Components(component->getSlaveComponents());
pyComponentCollection = PyObject_NEW( PyComponentCollection, &PyTypeComponentCollection );
if (pyComponentCollection == NULL) {
return NULL;
}
pyComponentCollection->_object = components;
HCATCH
return (PyObject*)pyComponentCollection;
}
// ---------------------------------------------------------------
// PyComponent Attribute Method table.
PyMethodDef PyComponent_Methods[] = PyMethodDef PyComponent_Methods[] =
{ { "getX" , (PyCFunction)PyComponent_getX , METH_NOARGS , "Return the Component X value." } { { "getX" , (PyCFunction)PyComponent_getX , METH_NOARGS , "Return the Component X value." }
@ -174,17 +202,15 @@ extern "C" {
, { "getCenter" , (PyCFunction)PyComponent_getCenter , METH_NOARGS , "Return the Component center position." } , { "getCenter" , (PyCFunction)PyComponent_getCenter , METH_NOARGS , "Return the Component center position." }
, { "getNet" , (PyCFunction)PyComponent_getNet , METH_NOARGS , "Returns the net owning the component." } , { "getNet" , (PyCFunction)PyComponent_getNet , METH_NOARGS , "Returns the net owning the component." }
, { "getLayer" , (PyCFunction)PyComponent_getLayer , METH_NOARGS , "Return the component layer." } , { "getLayer" , (PyCFunction)PyComponent_getLayer , METH_NOARGS , "Return the component layer." }
, { "getBoundingBox" , (PyCFunction)PyComponent_getBoundingBox, METH_VARARGS, "Return the component boundingBox (optionally on a BasicLayer)." } , { "getBoundingBox" , (PyCFunction)PyComponent_getBoundingBox , METH_VARARGS, "Return the component boundingBox (optionally on a BasicLayer)." }
, { "getConnexComponents" , (PyCFunction)PyComponent_getConnexComponents, METH_NOARGS, "All the components connecteds to this one through hyper hooks." }
, { "getSlaveComponents" , (PyCFunction)PyComponent_getSlaveComponents , METH_NOARGS, "All the components anchored directly or indirectly on this one." }
, { "destroy" , (PyCFunction)PyComponent_destroy , METH_NOARGS , { "destroy" , (PyCFunction)PyComponent_destroy , METH_NOARGS
, "destroy associated hurricane object, the python object remains." } , "destroy associated hurricane object, the python object remains." }
, {NULL, NULL, 0, NULL} /* sentinel */ , {NULL, NULL, 0, NULL} /* sentinel */
}; };
// x-------------------------------------------------------------x
// | "PyComponent" Object Methods |
// x-------------------------------------------------------------x
DBoDeleteMethod(Component) DBoDeleteMethod(Component)
PyTypeObjectLinkPyType(Component) PyTypeObjectLinkPyType(Component)
@ -192,23 +218,16 @@ extern "C" {
#else // End of Python Module Code Part. #else // End of Python Module Code Part.
// x=================================================================x // +=================================================================+
// | "PyComponent" Shared Library Code Part | // | "PyComponent" Shared Library Code Part |
// x=================================================================x // +=================================================================+
// ---------------------------------------------------------------
// PyComponent Object Definitions.
PyTypeInheritedObjectDefinitions(Component, Entity) PyTypeInheritedObjectDefinitions(Component, Entity)
#endif // End of Shared Library Code Part. #endif // End of Shared Library Code Part.
} // End of extern "C". } // extern "C".
} // Isobar namespace.
} // End of Isobar namespace.

View File

@ -2,10 +2,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/LIP6 2008-2013, 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,10 +12,7 @@
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./PyNetExternalComponents.cpp" | // | C++ Module : "./PyNetExternalComponents.cpp" |
// | *************************************************************** | // +-----------------------------------------------------------------+
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/isobar/PyNet.h" #include "hurricane/isobar/PyNet.h"