diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2009-03-26 11:34:24 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2009-03-26 11:34:24 -0230 |
commit | 0de45cd71fa21bcb20b8a3f754ff20cdf329ff23 (patch) | |
tree | 06c0fd3304362d39a56df0a234e90b3f84687edc /py/modules/IcePy/ObjectAdapter.cpp | |
parent | More fixes to FixUtil.py (diff) | |
download | ice-0de45cd71fa21bcb20b8a3f754ff20cdf329ff23.tar.bz2 ice-0de45cd71fa21bcb20b8a3f754ff20cdf329ff23.tar.xz ice-0de45cd71fa21bcb20b8a3f754ff20cdf329ff23.zip |
Bug 2511 - add default servants
Diffstat (limited to 'py/modules/IcePy/ObjectAdapter.cpp')
-rw-r--r-- | py/modules/IcePy/ObjectAdapter.cpp | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/py/modules/IcePy/ObjectAdapter.cpp b/py/modules/IcePy/ObjectAdapter.cpp index efd8b2164b2..8a27457b428 100644 --- a/py/modules/IcePy/ObjectAdapter.cpp +++ b/py/modules/IcePy/ObjectAdapter.cpp @@ -790,6 +790,47 @@ adapterAddFacetWithUUID(ObjectAdapterObject* self, PyObject* args) extern "C" #endif static PyObject* +adapterAddDefaultServant(ObjectAdapterObject* self, PyObject* args) +{ + PyObject* objectType = lookupType("Ice.Object"); + PyObject* servant; + PyObject* categoryObj; + if(!PyArg_ParseTuple(args, STRCAST("O!O"), objectType, &servant, &categoryObj)) + { + return 0; + } + + ServantWrapperPtr wrapper= createServantWrapper(servant); + if(PyErr_Occurred()) + { + return 0; + } + + string category; + if(!getStringArg(categoryObj, "category", category)) + { + return 0; + } + + assert(self->adapter); + try + { + (*self->adapter)->addDefaultServant(wrapper, category); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return 0; + } + + Py_INCREF(Py_None); + return Py_None; +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* adapterRemove(ObjectAdapterObject* self, PyObject* args) { PyObject* identityType = lookupType("Ice.Identity"); @@ -932,6 +973,47 @@ adapterRemoveAllFacets(ObjectAdapterObject* self, PyObject* args) extern "C" #endif static PyObject* +adapterRemoveDefaultServant(ObjectAdapterObject* self, PyObject* args) +{ + PyObject* categoryObj; + if(!PyArg_ParseTuple(args, STRCAST("O"), &categoryObj)) + { + return 0; + } + + string category; + if(!getStringArg(categoryObj, "category", category)) + { + return 0; + } + + assert(self->adapter); + Ice::ObjectPtr obj; + try + { + obj = (*self->adapter)->removeDefaultServant(category); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return 0; + } + + if(!obj) + { + Py_INCREF(Py_None); + return Py_None; + } + + ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); + assert(wrapper); + return wrapper->getObject(); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* adapterFind(ObjectAdapterObject* self, PyObject* args) { PyObject* identityType = lookupType("Ice.Identity"); @@ -1112,6 +1194,47 @@ adapterFindByProxy(ObjectAdapterObject* self, PyObject* args) extern "C" #endif static PyObject* +adapterFindDefaultServant(ObjectAdapterObject* self, PyObject* args) +{ + PyObject* categoryObj; + if(!PyArg_ParseTuple(args, STRCAST("O"), &categoryObj)) + { + return 0; + } + + string category; + if(!getStringArg(categoryObj, "category", category)) + { + return 0; + } + + assert(self->adapter); + Ice::ObjectPtr obj; + try + { + obj = (*self->adapter)->findDefaultServant(category); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return 0; + } + + if(!obj) + { + Py_INCREF(Py_None); + return Py_None; + } + + ServantWrapperPtr wrapper = ServantWrapperPtr::dynamicCast(obj); + assert(wrapper); + return wrapper->getObject(); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* adapterAddServantLocator(ObjectAdapterObject* self, PyObject* args) { PyObject* locatorType = lookupType("Ice.ServantLocator"); @@ -1369,12 +1492,16 @@ static PyMethodDef AdapterMethods[] = PyDoc_STR(STRCAST("addWithUUID(servant) -> Ice.ObjectPrx")) }, { STRCAST("addFacetWithUUID"), reinterpret_cast<PyCFunction>(adapterAddFacetWithUUID), METH_VARARGS, PyDoc_STR(STRCAST("addFacetWithUUID(servant, facet) -> Ice.ObjectPrx")) }, + { STRCAST("addDefaultServant"), reinterpret_cast<PyCFunction>(adapterAddDefaultServant), METH_VARARGS, + PyDoc_STR(STRCAST("addDefaultServant(servant, category) -> None")) }, { STRCAST("remove"), reinterpret_cast<PyCFunction>(adapterRemove), METH_VARARGS, PyDoc_STR(STRCAST("remove(identity) -> Ice.Object")) }, { STRCAST("removeFacet"), reinterpret_cast<PyCFunction>(adapterRemoveFacet), METH_VARARGS, PyDoc_STR(STRCAST("removeFacet(identity, facet) -> Ice.Object")) }, { STRCAST("removeAllFacets"), reinterpret_cast<PyCFunction>(adapterRemoveAllFacets), METH_VARARGS, PyDoc_STR(STRCAST("removeAllFacets(identity) -> dictionary")) }, + { STRCAST("removeDefaultServant"), reinterpret_cast<PyCFunction>(adapterRemoveDefaultServant), METH_VARARGS, + PyDoc_STR(STRCAST("removeDefaultServant(category) -> Ice.Object")) }, { STRCAST("find"), reinterpret_cast<PyCFunction>(adapterFind), METH_VARARGS, PyDoc_STR(STRCAST("find(identity) -> Ice.Object")) }, { STRCAST("findFacet"), reinterpret_cast<PyCFunction>(adapterFindFacet), METH_VARARGS, @@ -1383,6 +1510,8 @@ static PyMethodDef AdapterMethods[] = PyDoc_STR(STRCAST("findAllFacets(identity) -> dictionary")) }, { STRCAST("findByProxy"), reinterpret_cast<PyCFunction>(adapterFindByProxy), METH_VARARGS, PyDoc_STR(STRCAST("findByProxy(Ice.ObjectPrx) -> Ice.Object")) }, + { STRCAST("findDefaultServant"), reinterpret_cast<PyCFunction>(adapterFindDefaultServant), METH_VARARGS, + PyDoc_STR(STRCAST("findDefaultServant(category) -> Ice.Object")) }, { STRCAST("addServantLocator"), reinterpret_cast<PyCFunction>(adapterAddServantLocator), METH_VARARGS, PyDoc_STR(STRCAST("addServantLocator(Ice.ServantLocator, category) -> None")) }, { STRCAST("findServantLocator"), reinterpret_cast<PyCFunction>(adapterFindServantLocator), METH_VARARGS, |