coriolis/hurricane/src/isobar/PyDataBase.cpp

143 lines
3.6 KiB
C++
Raw Normal View History

2008-03-06 10:46:43 -06:00
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2013, All Rights Reserved
2008-03-06 10:46:43 -06:00
//
// +-----------------------------------------------------------------+
2008-03-06 10:46:43 -06:00
// | 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 : "./PyDataBase.cpp" |
// +-----------------------------------------------------------------+
2008-03-06 10:46:43 -06:00
#include "hurricane/isobar/PyDataBase.h"
#include "hurricane/isobar/PyTechnology.h"
#include "hurricane/isobar/PyLibrary.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(DataBase,db,function)
2008-03-06 10:46:43 -06:00
// +=================================================================+
// | "PyDataBase" Python Module Code Part |
// +=================================================================+
2008-03-06 10:46:43 -06:00
#if defined(__PYTHON_MODULE__)
2008-03-06 10:46:43 -06:00
PyObject* PyDataBase_getDB ( PyObject* module ) {
trace << "PyDataBase_getDB()" << endl;
2008-03-06 10:46:43 -06:00
DataBase* db = NULL;
HTRY
db = DataBase::getDB ();
2008-03-06 10:46:43 -06:00
if ( db == NULL )
PyErr_SetString ( HurricaneError, "DataBase has not been created yet" );
HCATCH
return PyDataBase_Link ( db );
}
2008-03-17 08:54:33 -05:00
PyObject* PyDataBase_getTechnology ( PyDataBase* self ) {
trace << "PyDataBase_getTechnology()" << endl;
2008-03-06 10:46:43 -06:00
Technology* techno = NULL;
HTRY
2008-03-17 08:54:33 -05:00
METHOD_HEAD("DataBase.getTechnology()")
2008-03-06 10:46:43 -06:00
2008-03-17 08:54:33 -05:00
techno = db->getTechnology ();
2008-03-06 10:46:43 -06:00
if ( techno == NULL )
Py_RETURN_NONE;
HCATCH
return PyTechnology_Link ( techno );
}
static PyObject* PyDataBase_getRootLibrary ( PyDataBase *self ) {
trace << "PyDataBase_getRootLibrary ()" << endl;
2008-03-06 10:46:43 -06:00
Library* library = NULL;
2008-03-06 10:46:43 -06:00
HTRY
METHOD_HEAD ( "DataBase.getRootLibrary()" )
library = db->getRootLibrary ();
HCATCH
return PyLibrary_Link(library);
}
2008-03-06 10:46:43 -06:00
// Standart Accessors (Attributes).
// Standart Destroy (Attribute).
DBoDestroyAttribute(PyDataBase_destroy,PyDataBase)
2008-03-06 10:46:43 -06:00
// ---------------------------------------------------------------
// PyDataBase Attribute Method table.
PyMethodDef PyDataBase_Methods[] =
{ { "getTechnology" , (PyCFunction)PyDataBase_getTechnology , METH_NOARGS, "Return the Technology" }
, { "getRootLibrary", (PyCFunction)PyDataBase_getRootLibrary, METH_NOARGS, "Return the root library" }
, { "destroy" , (PyCFunction)PyDataBase_destroy , METH_NOARGS
, "Destroy associated hurricane object The python object remains." }
2008-03-06 10:46:43 -06:00
, {NULL, NULL, 0, NULL} /* sentinel */
};
DBoDeleteMethod(DataBase)
PyTypeObjectLinkPyType(DataBase)
#else // End of Python Module Code Part.
// +=================================================================+
// | "PyDataBase" Shared Library Code Part |
// +=================================================================+
2008-03-06 10:46:43 -06:00
PyObject* PyDataBase_create ( PyObject *module ) {
trace << "PyDataBase_create()" << endl;
2008-03-06 10:46:43 -06:00
DataBase* db = NULL;
HTRY
2008-03-18 04:42:44 -05:00
db = DataBase::create ();
2008-03-06 10:46:43 -06:00
HCATCH
return PyDataBase_Link(db);
}
// Link/Creation Method.
DBoLinkCreateMethod(DataBase)
2008-03-06 10:46:43 -06:00
PyTypeObjectDefinitions(DataBase)
2008-03-06 10:46:43 -06:00
#endif // End of Shared Library Code Part.
} // extern "C".
2008-03-06 10:46:43 -06:00
} // Isobar namespace.
2008-03-06 10:46:43 -06:00