31 :
base_class(name,svc), m_log(msgSvc(), name ),
68 if ( ! Py_IsInitialized() ) {
75 if ( ! Py_IsInitialized() ) {
83 const std::string py_module_name =
"GaudiMP.IoRegistry";
86 PyObject *module = PyImport_ImportModule ((
char*)py_module_name.c_str());
87 if ( !module || !PyModule_Check (module) ) {
95 PyObject *pyclass = PyDict_GetItemString (PyModule_GetDict(module),
96 (
char*)py_class_name.c_str());
101 << py_class_name <<
"] from module ["
102 << py_module_name <<
"] !"
104 Py_XDECREF (pyclass);
109 m_dict = PyObject_GetAttrString (pyclass, (
char*)
"instances");
112 <<
"could not retrieve attribute [instances] from class ["
113 << py_module_name <<
"." << py_class_name <<
"] !" <<
endmsg;
123 PyObject* py_repr = PyObject_Repr (
m_dict);
124 if ( py_repr && PyString_Check(py_repr) ) {
125 repr = PyString_AsString(py_repr);
127 Py_XDECREF( py_repr );
144 PyObject* py_repr = PyObject_Repr (
m_dict);
145 if ( py_repr && PyString_Check(py_repr) ) {
146 repr = PyString_AsString(py_repr);
148 Py_XDECREF( py_repr );
164 if ( 0 == iocomponent ) {
179 if ( 0 == iocomponent ) {
189 PyObject *o = PyDict_GetItemString (
m_dict, (
char*)ioname.c_str());
193 if ( NULL==o || !PyDict_Check (o) ) {
200 PyObject *
item = PyDict_GetItemString (o, (
char*)fname.c_str());
202 const bool contains = (item != 0);
203 if ( contains ==
false ) {
206 PyObject* py_repr = PyObject_Repr (o);
207 if ( py_repr && PyString_Check(py_repr) ) {
208 repr = PyString_AsString(py_repr);
210 Py_XDECREF( py_repr );
231 if ( 0 == iocomponent ) {
233 <<
"io_register (component) received a NULL pointer !" <<
endmsg;
244 <<
"] already registered @" << (
void*)itr->second <<
endmsg;
260 if ( 0 == iocomponent ) {
268 <<
"could not register component [" << iocomponent->
name() <<
"] "
269 <<
"with the I/O component manager !"
280 PyObject *o = PyDict_GetItemString (
m_dict, (
char*)ioname.c_str());
288 <<
"in the I/O registry !" <<
endmsg;
291 if ( 0 != PyDict_SetItemString (
m_dict, (
char*)ioname.c_str(), o) ) {
294 << ioname <<
"] " <<
"in the I/O registry !" <<
endmsg;
297 }
else if ( !PyDict_Check (o) ) {
299 <<
"internal consistency error (expected a dictionary !)"
313 m_log <<
MSG::ERROR <<
"unknown value for iomode: [" << iomode <<
"] !"
319 PyObject *val = PyDict_GetItemString (o, (
char*)fname.c_str());
332 int err = PyList_SetItem (val,
333 0, PyString_FromString ((
char*)mode.c_str()));
342 err = PyList_SetItem (val, 1, Py_None);
349 err = PyDict_SetItemString (o, (
char*)fname.c_str(), val);
351 m_log <<
MSG::ERROR <<
"could not properly fill registry w/ python-list !"
368 if ( 0 == iocomponent ) {
379 PyObject *o = PyDict_GetItemString (
m_dict, (
char*)ioname.c_str());
383 if ( NULL==o || !PyDict_Check (o) ) {
389 PyObject *pylist = PyDict_GetItemString (o, (
char*)fname.c_str());
392 if ( NULL==pylist || !PyList_Check (pylist) ) {
398 const std::size_t sz = PyList_Size (pylist);
400 m_log <<
MSG::ERROR <<
"[" << ioname <<
"][" << fname <<
"] list has size ["
401 << sz <<
" ! (expected sz==2)"
408 fname = PyString_AsString ( PyList_GetItem (pylist, 1) );
428 if ( !(*io)->io_reinit().isSuccess() ) {
431 <<
"]->io_reinit() !" <<
endmsg;