coriolis/hurricane/src/isobar/PyHyperNet.cpp

219 lines
7.0 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"
2008-10-17 12:27:20 -05:00
#include "hurricane/isobar/PyOccurrenceCollection.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-10-17 12:27:20 -05:00
// Attribute Method : "PyHyperNet_getLeafPlugOccurrences()"
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
static PyObject* PyHyperNet_getLeafPlugOccurrences(PyHyperNet *self)
2008-03-06 10:46:43 -06:00
{
2008-10-17 12:27:20 -05:00
trace << "PyHyperNet_getLeafPlugOccurrences()" << endl;
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
METHOD_HEAD ( "HyperNet.getLeafPlugOccurrences()" )
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
PyOccurrenceCollection* pyOccurrenceCollection = NULL;
2008-03-06 10:46:43 -06:00
HTRY
2008-10-17 12:27:20 -05:00
Occurrences* occurrences = new Occurrences(hyperNet->getLeafPlugOccurrences());
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
pyOccurrenceCollection = PyObject_NEW(PyOccurrenceCollection, &PyTypeOccurrenceCollection);
if (pyOccurrenceCollection == NULL) {
return NULL;
}
2008-03-06 10:46:43 -06:00
2008-10-17 12:27:20 -05:00
pyOccurrenceCollection->_object = occurrences;
2008-03-06 10:46:43 -06:00
HCATCH
2008-10-17 12:27:20 -05:00
return (PyObject*)pyOccurrenceCollection;
2008-03-06 10:46:43 -06:00
}
// ---------------------------------------------------------------
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-10-17 12:27:20 -05:00
, { "getLeafPlugOccurrences", (PyCFunction)PyHyperNet_getLeafPlugOccurrences, 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
DirectDeleteMethod(PyHyperNet_DeAlloc,PyHyperNet)
PyTypeObjectLinkPyType(HyperNet)
# else // End of Python Module Code Part.
// x=================================================================x
// | "PyHyperNet" Shared Library Code Part |
// x=================================================================x
2008-03-06 10:46:43 -06:00
// ---------------------------------------------------------------
// Attribute Method : "PyHyperNet_create ()"
2008-03-06 10:46:43 -06:00
PyObject* PyHyperNet_create ( PyObject *module, PyObject *args ) {
trace << "PyHyperNet_create()" << endl;
2008-03-06 10:46:43 -06:00
HyperNet* hyperNet = NULL;
2008-03-06 10:46:43 -06:00
PyObject* arg0;
if (! ParseOneArg ( "HyperNet.create()", 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 );
}
// ---------------------------------------------------------------
// 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.