coriolis/hurricane/src/isobar/PyHyperNet.cpp

224 lines
7.1 KiB
C++
Raw Normal View History

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: PyHyperNet.cpp,v 1.2 2007/05/10 11:15:56 d2 Exp $
//
// x-----------------------------------------------------------------x
// | |
// | C O R I O L I S |
// | I s o b a r - Hurricane / Python Interface |
// | |
// | Author : Damien DUPUIS |
// | E-mail : Damien.Dupuis@lip6.fr |
// | =============================================================== |
// | C++ Module : "./PyHyperNet.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/isobar/PyHyperNet.h"
#include "hurricane/isobar/PyCell.h"
#include "hurricane/isobar/PyOccurrence.h"
#include "hurricane/isobar/PyOccurrenceLocator.h"
2008-03-06 10:46:43 -06:00
2008-03-28 04:48:47 -05:00
using namespace Hurricane;
2008-03-06 10:46:43 -06:00
namespace Isobar {
extern "C" {
# define METHOD_HEAD(function) GENERIC_METHOD_HEAD(HyperNet,hyperNet,function)
// x=================================================================x
// | "PyHyperNet" Python Module Code Part |
// x=================================================================x
# if defined(__PYTHON_MODULE__)
// x-------------------------------------------------------------x
// | "PyHyperNet" Attribute Methods |
// x-------------------------------------------------------------x
// Standart Predicates (Attributes).
2008-03-19 05:02:56 -05:00
DirectGetBoolAttribute(PyHyperNet_isValid ,isValid ,PyHyperNet,HyperNet)
2008-03-06 10:46:43 -06:00
// Standart Delete (Attribute).
2008-03-17 08:54:33 -05:00
DirectDestroyAttribute(PyHyperNet_destroy, PyHyperNet)
2008-03-06 10:46:43 -06:00
// ---------------------------------------------------------------
2008-03-17 08:54:33 -05:00
// Attribute Method : "PyHyperNet_getPlugsLocator ()"
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
static PyObject* PyHyperNet_getLeafPlugOccurrenceLocator ( PyHyperNet *self )
2008-03-06 10:46:43 -06:00
{
2008-03-17 08:54:33 -05:00
trace << "PyHyperNet_getLeafPlugOccurrenceLocator ()" << endl;
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
METHOD_HEAD ( "HyperNet.getLeafPlugOccurrenceLocator()" )
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
Occurrences occurrences = hyperNet->getLeafPlugOccurrences ();
2008-03-06 10:46:43 -06:00
PyOccurrenceLocator* pyOccurrenceLocator = PyObject_NEW ( PyOccurrenceLocator, &PyTypeOccurrenceLocator );
if (pyOccurrenceLocator == NULL) { return NULL; }
trace_in ();
trace << "new PyOccurrenceLocator [" << hex << pyOccurrenceLocator << "]" << endl;
trace_out ();
HTRY
2008-03-17 08:54:33 -05:00
pyOccurrenceLocator->_object = occurrences.getLocator ();
2008-03-06 10:46:43 -06:00
HCATCH
return ( (PyObject*)pyOccurrenceLocator );
}
// ---------------------------------------------------------------
2008-03-17 08:54:33 -05:00
// Attribute Method : "PyHyperNet_getCell ()"
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
static PyObject* PyHyperNet_getCell ( PyHyperNet *self )
2008-03-06 10:46:43 -06:00
{
2008-03-17 08:54:33 -05:00
trace << "PyHyperNet_getCell ()" << endl;
2008-03-06 10:46:43 -06:00
Cell* cell = NULL;
HTRY
2008-03-17 08:54:33 -05:00
METHOD_HEAD ( "HyperNet.getCell()" )
cell = hyperNet->getCell ();
2008-03-06 10:46:43 -06:00
HCATCH
return PyCell_Link ( cell );
}
// ---------------------------------------------------------------
// PyHyperNet Attribute Method table.
PyMethodDef PyHyperNet_Methods[] =
2008-03-17 08:54:33 -05:00
{ { "getCell" , (PyCFunction)PyHyperNet_getCell , METH_NOARGS , "Returns the hyperNet cell." }
2008-03-19 05:02:56 -05:00
, { "isValid" , (PyCFunction)PyHyperNet_isValid , METH_NOARGS , "Returns trus if the HyperNet isValid." }
2008-03-17 08:54:33 -05:00
, { "getLeafPlugOccurrenceLocator", (PyCFunction)PyHyperNet_getLeafPlugOccurrenceLocator, METH_NOARGS
2008-03-06 10:46:43 -06:00
, "Returns the collection of leaf occurrences" }
2008-03-17 08:54:33 -05:00
, { "destroy" , (PyCFunction)PyHyperNet_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
// | "PyHyperNet" Object Methods |
// x-------------------------------------------------------------x
// ---------------------------------------------------------------
2008-03-18 04:42:44 -05:00
// Attribute Method : "PyHyperNet_new ()"
2008-03-06 10:46:43 -06:00
static PyObject* PyHyperNet_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
trace << "PyHyperNet_new()" << endl;
HyperNet* hyperNet = NULL;
PyObject* arg0;
if (! ParseOneArg ( "HyperNet.new()", args, ":occur", &arg0 )) {
PyErr_SetString(ConstructorError, "invalid number of parameters for HyperNet constructor." );
return ( NULL );
}
2008-03-06 10:46:43 -06:00
hyperNet = new HyperNet ( *PYOCCURRENCE_O(arg0) );
PyHyperNet* pyHyperNet;
pyHyperNet = PyObject_NEW(PyHyperNet, &PyTypeHyperNet);
if (pyHyperNet == NULL) return NULL;
HTRY
pyHyperNet->_object = hyperNet;
HCATCH
return ( (PyObject*)pyHyperNet );
}
DirectDeleteMethod(PyHyperNet_DeAlloc,PyHyperNet)
PyTypeObjectLinkPyType(HyperNet)
PyTypeObjectConstructor(HyperNet)
# else // End of Python Module Code Part.
// x=================================================================x
// | "PyHyperNet" Shared Library Code Part |
// x=================================================================x
// ---------------------------------------------------------------
// PyHyperNet Object Definitions.
PyTypeObjectDefinitions(HyperNet)
2008-03-06 10:46:43 -06:00
# endif // End of Shared Library Code Part.
} // End of extern "C".
} // End of Isobar namespace.