-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
void PickelizedPyObjServer::addKeyValueHard(PyObject *key, PyObject *value)
{
- bool isOK(PyDict_SetItem(_self,key,value)==0);
- if(!isOK)
- throw Exception("PickelizedPyObjServer::addKeyValueHard : error when trying to add key,value to dict !");
-}
-
-void PickelizedPyObjServer::addKeyValueErrorIfAlreadyExisting(PyObject *key, PyObject *value)
-{
- checkKeyNotAlreadyPresent(key);
- bool isOK(PyDict_SetItem(_self,key,value)==0);
- if(!isOK)
- throw Exception("PickelizedPyObjServer::addKeyValueErrorIfAlreadyExisting : error when trying to add key,value to dict !");
+ std::ostringstream oss; oss << "PickelizedPyObjServer::addKeyValueHard : var \"" << getVarNameCpp() << "\" is not permitted to alter its value !";
+ throw Exception(oss.str());
}
void PickelizedPyObjServer::removeKeyInVarErrorIfNotAlreadyExisting(PyObject *key)
{
- checkKeyPresent(key);
- if(PyDict_DelItem(_self,key)!=0)
- throw Exception("PickelizedPyObjServer::removeKeyInVarErrorIfNotAlreadyExisting : error during deletion of key in dict !");
+ std::ostringstream oss; oss << "PickelizedPyObjServer::removeKeyInVarErrorIfNotAlreadyExisting : var \"" << getVarNameCpp() << "\" is not permitted to alter its value !";
+ throw Exception(oss.str());
}
void PickelizedPyObjServer::FromByteSeqToCpp(const SALOME::ByteVec& bsToBeConv, std::string& ret)
buf[i]=bsToBeConv[i];
}
-SALOME::ByteVec *PickelizedPyObjServer::FromCppToByteSeq(const std::string& strToBeConv)
+void PickelizedPyObjServer::FromCppToByteSeq(const std::string& strToBeConv, SALOME::ByteVec& ret)
{
- SALOME::ByteVec *ret(new SALOME::ByteVec);
const char *buf(strToBeConv.c_str());
std::size_t sz(strToBeConv.size());
- ret->length(sz);
+ ret.length(sz);
for(std::size_t i=0;i<sz;i++)
- (*ret)[i]=buf[i];
+ ret[i]=buf[i];
+}
+
+SALOME::ByteVec *PickelizedPyObjServer::FromCppToByteSeq(const std::string& strToBeConv)
+{
+ SALOME::ByteVec *ret(new SALOME::ByteVec);
+ FromCppToByteSeq(strToBeConv,*ret);
return ret;
}
}
Py_XDECREF(retPy);
}
+
+PickelizedPyObjServerModifiable::PickelizedPyObjServerModifiable(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value):PickelizedPyObjServer(father,varName,value)
+{
+}
+
+PickelizedPyObjServerModifiable::PickelizedPyObjServerModifiable(DataScopeServerBase *father, const std::string& varName, PyObject *obj):PickelizedPyObjServer(father,varName,obj)
+{
+}
+
+void PickelizedPyObjServerModifiable::addKeyValueErrorIfAlreadyExisting(PyObject *key, PyObject *value)
+{
+ checkKeyNotAlreadyPresent(key);
+ bool isOK(PyDict_SetItem(_self,key,value)==0);
+ if(!isOK)
+ throw Exception("PickelizedPyObjServerModifiable::addKeyValueErrorIfAlreadyExisting : error when trying to add key,value to dict !");
+}
+
+void PickelizedPyObjServerModifiable::removeKeyInVarErrorIfNotAlreadyExisting(PyObject *key)
+{
+ checkKeyPresent(key);
+ if(PyDict_DelItem(_self,key)!=0)
+ throw Exception("PickelizedPyObjServerModifiable::removeKeyInVarErrorIfNotAlreadyExisting : error during deletion of key in dict !");
+}