2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
//
|
|
|
|
|
// This file is part of the Coriolis Project.
|
|
|
|
|
// Copyright (C) Laboratoire LIP6 - Departement ASIM
|
|
|
|
|
// Universite Pierre et Marie Curie
|
|
|
|
|
//
|
|
|
|
|
// Main contributors :
|
|
|
|
|
// Christophe Alexandre <Christophe.Alexandre@lip6.fr>
|
|
|
|
|
// Sophie Belloeil <Sophie.Belloeil@lip6.fr>
|
|
|
|
|
// Hugo Cl<43>ment <Hugo.Clement@lip6.fr>
|
|
|
|
|
// Jean-Paul Chaput <Jean-Paul.Chaput@lip6.fr>
|
|
|
|
|
// Damien Dupuis <Damien.Dupuis@lip6.fr>
|
|
|
|
|
// Christian Masson <Christian.Masson@lip6.fr>
|
|
|
|
|
// Marek Sroka <Marek.Sroka@lip6.fr>
|
|
|
|
|
//
|
|
|
|
|
// The Coriolis Project is free software; you can redistribute it
|
|
|
|
|
// and/or modify it under the terms of the GNU General Public License
|
|
|
|
|
// as published by the Free Software Foundation; either version 2 of
|
|
|
|
|
// the License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// The Coriolis Project is distributed in the hope that it will be
|
|
|
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
|
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with the Coriolis Project; if not, write to the Free Software
|
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
// USA
|
|
|
|
|
//
|
|
|
|
|
// License-Tag
|
|
|
|
|
// Authors-Tag
|
|
|
|
|
// ===================================================================
|
|
|
|
|
//
|
|
|
|
|
// $Id: PyOccurrence.cpp,v 1.7 2007/05/02 11:50:46 d2 Exp $
|
|
|
|
|
//
|
|
|
|
|
// x-----------------------------------------------------------------x
|
|
|
|
|
// | |
|
|
|
|
|
// | C O R I O L I S |
|
|
|
|
|
// | I s o b a r - Hurricane / Python Interface |
|
|
|
|
|
// | |
|
|
|
|
|
// | Author : Jean-Paul CHAPUT |
|
|
|
|
|
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
|
|
|
|
// | =============================================================== |
|
|
|
|
|
// | C++ Module : "./PyOccurrence.cpp" |
|
|
|
|
|
// | *************************************************************** |
|
|
|
|
|
// | U p d a t e s |
|
|
|
|
|
// | |
|
|
|
|
|
// x-----------------------------------------------------------------x
|
|
|
|
|
|
2008-05-21 17:46:29 -05:00
|
|
|
|
#include "hurricane/isobar/PyBox.h"
|
|
|
|
|
#include "hurricane/isobar/PyTransformation.h"
|
|
|
|
|
#include "hurricane/isobar/PyName.h"
|
|
|
|
|
#include "hurricane/isobar/PyPath.h"
|
|
|
|
|
#include "hurricane/isobar/PyOccurrence.h"
|
|
|
|
|
#include "hurricane/isobar/PyCell.h"
|
|
|
|
|
#include "hurricane/isobar/PySegment.h"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Isobar {
|
|
|
|
|
|
2008-03-28 04:48:47 -05:00
|
|
|
|
using namespace Hurricane;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Occurrence,occurrence,function)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// x=================================================================x
|
|
|
|
|
// | "PyOccurrence" Python Module Code Part |
|
|
|
|
|
// x=================================================================x
|
|
|
|
|
|
|
|
|
|
#if defined(__PYTHON_MODULE__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
|
// | "PyOccurrence" Attribute Methods |
|
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Standart Accessors (Attributes).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Standart Predicates (Attributes).
|
2008-03-19 05:02:56 -05:00
|
|
|
|
DirectGetBoolAttribute(PyOccurrence_isValid ,isValid ,PyOccurrence,Occurrence)
|
2008-04-09 12:14:17 -05:00
|
|
|
|
DirectGetBoolAttribute(PyOccurrence_hasProperty,hasProperty,PyOccurrence,Occurrence)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
// Standart destroy (Attribute).
|
|
|
|
|
DirectDestroyAttribute(PyOccurrence_destroy, PyOccurrence)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
|
// Attribute Method : "PyOccurrence_getEntity ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
static PyObject* PyOccurrence_getEntity ( PyOccurrence *self ) {
|
|
|
|
|
trace << "PyOccurrence_getEntity()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
METHOD_HEAD ( "Occurrence.getEntity()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
PyObject* pyEntity = NULL;
|
|
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
|
Entity* entity = occurrence->getEntity();
|
2008-03-06 10:46:43 -06:00
|
|
|
|
if ( entity == NULL )
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
|
|
|
|
|
pyEntity = PyEntity_NEW ( entity );
|
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
return pyEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
|
// Attribute Method : "PyOccurrence_getOwnerCell ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
static PyObject* PyOccurrence_getOwnerCell ( PyOccurrence *self ) {
|
|
|
|
|
trace << "PyOccurrence_getOwnerCell()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
METHOD_HEAD ( "Occurernce.getOwnerCell()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
Cell* cell = NULL;
|
|
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
|
cell = occurrence->getOwnerCell();
|
2008-03-06 10:46:43 -06:00
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
return PyCell_Link ( cell );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
|
// Attribute Method : "PyOccurrence_getMasterCell ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
static PyObject* PyOccurrence_getMasterCell ( PyOccurrence *self )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
{
|
2008-03-17 08:54:33 -05:00
|
|
|
|
trace << "PyOccurrence_getMasterCell()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
METHOD_HEAD ( "Occurrence.getMasterCell()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
Cell* cell = NULL;
|
|
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
|
cell = occurrence->getMasterCell();
|
2008-03-06 10:46:43 -06:00
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
return PyCell_Link ( cell );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
|
// Attribute Method : "PyOccurrence_getPath ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
static PyObject* PyOccurrence_getPath ( PyOccurrence *self )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
{
|
2008-03-17 08:54:33 -05:00
|
|
|
|
trace << "PyOccurrence_getPath ()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
METHOD_HEAD ( "Occurrence.getPath()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
PyPath* pyPath = PyObject_NEW ( PyPath, &PyTypePath );
|
|
|
|
|
if ( pyPath == NULL ) { return NULL; }
|
|
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
|
pyPath->_object = new Path ( occurrence->getPath() );
|
2008-03-06 10:46:43 -06:00
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
return ( (PyObject*)pyPath );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
|
// Attribute Method : "PyOccurrence_getName ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
static PyObject* PyOccurrence_getName ( PyOccurrence *self )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
{
|
2008-03-17 08:54:33 -05:00
|
|
|
|
trace << "PyOccurrence_getName ()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
METHOD_HEAD ( "Occurrence.getName()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
PyName* pyName = PyObject_NEW ( PyName, &PyTypeName );
|
|
|
|
|
if ( pyName == NULL ) { return NULL; }
|
|
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
|
pyName->_object = new Name ( occurrence->getName() );
|
2008-03-06 10:46:43 -06:00
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
return ( (PyObject*)pyName );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2008-03-17 08:54:33 -05:00
|
|
|
|
// Attribute Method : "PyOccurrence_getBoundingBox ()"
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
static PyObject* PyOccurrence_getBoundingBox ( PyOccurrence *self )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
{
|
2008-03-17 08:54:33 -05:00
|
|
|
|
trace << "PyOccurrence_getBoundingBox ()" << endl;
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
METHOD_HEAD ( "Occurrence.getBoundingBox()" )
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
PyBox* pyBox = PyObject_NEW ( PyBox, &PyTypeBox );
|
|
|
|
|
if ( pyBox == NULL ) { return NULL; }
|
|
|
|
|
|
|
|
|
|
HTRY
|
2008-03-17 08:54:33 -05:00
|
|
|
|
pyBox->_object = new Box ( occurrence->getBoundingBox() );
|
2008-03-06 10:46:43 -06:00
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
return ( (PyObject*)pyBox );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
// PyOccurrence Attribute Method table.
|
|
|
|
|
|
|
|
|
|
PyMethodDef PyOccurrence_Methods[] =
|
2008-03-17 08:54:33 -05:00
|
|
|
|
{ { "getEntity" , (PyCFunction)PyOccurrence_getEntity , METH_NOARGS, "Returns the referenced entity." }
|
|
|
|
|
, { "getPath" , (PyCFunction)PyOccurrence_getPath , METH_NOARGS, "Returns the hierarchical instaciation path." }
|
|
|
|
|
, { "getName" , (PyCFunction)PyOccurrence_getName , METH_NOARGS, "Returns the occurrence name (concatenation of path and entity name." }
|
|
|
|
|
, { "getOwnerCell" , (PyCFunction)PyOccurrence_getOwnerCell , METH_NOARGS, "Returns the occurrence owner cell." }
|
|
|
|
|
, { "getMasterCell" , (PyCFunction)PyOccurrence_getMasterCell , METH_NOARGS, "Returns the cell owning the referenced entity." }
|
|
|
|
|
, { "getBoundingBox", (PyCFunction)PyOccurrence_getBoundingBox, METH_NOARGS, "Returns the occurrence bounding box." }
|
2008-03-19 05:02:56 -05:00
|
|
|
|
, { "isValid" , (PyCFunction)PyOccurrence_isValid , METH_NOARGS, "Returns true if the occurrence is valid." }
|
2008-04-09 12:14:17 -05:00
|
|
|
|
, { "hasProperty" , (PyCFunction)PyOccurrence_hasProperty , METH_NOARGS, "Returns true if the occurrence owns some properties." }
|
2008-03-17 08:54:33 -05:00
|
|
|
|
, { "destroy" , (PyCFunction)PyOccurrence_destroy , METH_NOARGS
|
|
|
|
|
, "Destroy associated hurricane object, the python object remains." }
|
2008-03-06 10:46:43 -06:00
|
|
|
|
, {NULL, NULL, 0, NULL} /* sentinel */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
|
// | "PyOccurrence" Object Methods |
|
|
|
|
|
// x-------------------------------------------------------------x
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
// Attribute Method : "PyOccurrence_new ()"
|
|
|
|
|
|
|
|
|
|
static PyObject* PyOccurrence_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
|
|
|
|
|
trace << "PyOccurrence_new()" << endl;
|
|
|
|
|
|
|
|
|
|
Occurrence* occurrence;
|
|
|
|
|
PyObject* arg0;
|
|
|
|
|
PyObject* arg1;
|
|
|
|
|
|
|
|
|
|
__cs.Init ("Occurrence.new");
|
|
|
|
|
if ( ! PyArg_ParseTuple(args,"|O&O&:Occurrence.new"
|
|
|
|
|
,Converter,&arg0
|
|
|
|
|
,Converter,&arg1
|
|
|
|
|
) ) return ( NULL );
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
if ( __cs.getObjectIds() == NO_ARG ) { occurrence = new Occurrence (); }
|
|
|
|
|
else if ( __cs.getObjectIds() == ENT_ARG ) { occurrence = new Occurrence ( PYENTITY_O(arg0) ); }
|
|
|
|
|
else if ( __cs.getObjectIds() == COMP_PATH_ARG) { occurrence = new Occurrence ( PYSEGMENT_O(arg0)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
, *PYPATH_O(arg1) ); }
|
2008-03-17 08:54:33 -05:00
|
|
|
|
else if ( __cs.getObjectIds() == ENT_PATH_ARG ) { occurrence = new Occurrence ( PYENTITY_O(arg0)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
, *PYPATH_O(arg1) ); }
|
|
|
|
|
else {
|
|
|
|
|
PyErr_SetString ( ConstructorError, "invalid number of parameters for Occurrence constructor. " );
|
|
|
|
|
return ( NULL );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PyOccurrence* pyOccurrence = PyObject_NEW(PyOccurrence, &PyTypeOccurrence);
|
|
|
|
|
if (pyOccurrence == NULL) return NULL;
|
|
|
|
|
|
|
|
|
|
HTRY
|
|
|
|
|
pyOccurrence->_object = occurrence;
|
|
|
|
|
HCATCH
|
|
|
|
|
|
|
|
|
|
return ( (PyObject*)pyOccurrence );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DirectDeleteMethod(PyOccurrence_DeAlloc,PyOccurrence)
|
|
|
|
|
PyTypeObjectLinkPyType(Occurrence)
|
|
|
|
|
PyTypeObjectConstructor(Occurrence)
|
|
|
|
|
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
#else // End of Python Module Code Part.
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// x=================================================================x
|
|
|
|
|
// | "PyOccurrence" Shared Library Code Part |
|
|
|
|
|
// x=================================================================x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
// PyOccurrence Object Definitions.
|
|
|
|
|
|
2008-10-12 08:37:33 -05:00
|
|
|
|
PyTypeObjectDefinitions(Occurrence)
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
2008-03-17 08:54:33 -05:00
|
|
|
|
#endif // End of Shared Library Code Part.
|
2008-03-06 10:46:43 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // End of extern "C".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // End of Isobar namespace.
|