From 6a43686ce26de5d2d5edf4a485ecff3a242c26b6 Mon Sep 17 00:00:00 2001 From: Joe George Date: Tue, 8 Dec 2015 11:33:42 -0500 Subject: ICE-6908 - Add ValueFactory ValueFactory is a replacement for ObjectFactory (which is still available if needed). It is an interface with only one operation and can has the "delegate" metadata. --- python/modules/IcePy/Communicator.cpp | 86 ++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) (limited to 'python/modules/IcePy/Communicator.cpp') diff --git a/python/modules/IcePy/Communicator.cpp b/python/modules/IcePy/Communicator.cpp index 919086d9ae8..df7d2282927 100644 --- a/python/modules/IcePy/Communicator.cpp +++ b/python/modules/IcePy/Communicator.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -1197,7 +1198,51 @@ communicatorAddObjectFactory(CommunicatorObject* self, PyObject* args) } - if(!pof->add(factory, id)) + if(!pof->addObjectFactory(factory, id)) + { + return 0; + } + + Py_INCREF(Py_None); + return Py_None; +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* +communicatorAddValueFactory(CommunicatorObject* self, PyObject* args) +{ + PyObject* factoryType = lookupType("Ice.ValueFactory"); + assert(factoryType); + + PyObject* factory; + PyObject* strObj; + if(!PyArg_ParseTuple(args, STRCAST("O!O"), factoryType, &factory, &strObj)) + { + return 0; + } + + string id; + if(!getStringArg(strObj, "id", id)) + { + return 0; + } + + ObjectFactoryPtr pof; + try + { + pof = ObjectFactoryPtr::dynamicCast((*self->communicator)->findObjectFactory("")); + assert(pof); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return 0; + + } + + if(!pof->addValueFactory(factory, id)) { return 0; } @@ -1236,7 +1281,40 @@ communicatorFindObjectFactory(CommunicatorObject* self, PyObject* args) return 0; } - return pof->find(id); + return pof->findObjectFactory(id); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* +communicatorFindValueFactory(CommunicatorObject* self, PyObject* args) +{ + PyObject* strObj; + if(!PyArg_ParseTuple(args, STRCAST("O"), &strObj)) + { + return 0; + } + + string id; + if(!getStringArg(strObj, "id", id)) + { + return 0; + } + + ObjectFactoryPtr pof; + try + { + pof = ObjectFactoryPtr::dynamicCast((*self->communicator)->findObjectFactory("")); + assert(pof); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return 0; + } + + return pof->findValueFactory(id); } #ifdef WIN32 @@ -1570,6 +1648,10 @@ static PyMethodDef CommunicatorMethods[] = PyDoc_STR(STRCAST("addObjectFactory(factory, id) -> None")) }, { STRCAST("findObjectFactory"), reinterpret_cast(communicatorFindObjectFactory), METH_VARARGS, PyDoc_STR(STRCAST("findObjectFactory(id) -> Ice.ObjectFactory")) }, + { STRCAST("addValueFactory"), reinterpret_cast(communicatorAddValueFactory), METH_VARARGS, + PyDoc_STR(STRCAST("addValueFactory(factory, id) -> None")) }, + { STRCAST("findValueFactory"), reinterpret_cast(communicatorFindValueFactory), METH_VARARGS, + PyDoc_STR(STRCAST("findValueFactory(id) -> Ice.ValueFactory")) }, { STRCAST("getImplicitContext"), reinterpret_cast(communicatorGetImplicitContext), METH_NOARGS, PyDoc_STR(STRCAST("getImplicitContext() -> Ice.ImplicitContext")) }, { STRCAST("getProperties"), reinterpret_cast(communicatorGetProperties), METH_NOARGS, -- cgit v1.2.3