X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSALOMESDS%2FSALOMESDS_PickelizedPyObjServer.hxx;h=365ac5bdb9f46910ffe677c5084f627a418d5786;hb=f6120c1bdb84ed1cc827ffab8284c0ac2709189f;hp=2d94ca1d6a564c381575cc81c2f905a8bd32bbf4;hpb=703cf8ca778de35a6b463d4b4fca7c36697d717f;p=modules%2Fkernel.git diff --git a/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.hxx b/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.hxx index 2d94ca1d6..365ac5bdb 100644 --- a/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.hxx +++ b/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 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 @@ -28,29 +28,58 @@ #include "SALOMESDS_BasicDataServer.hxx" +#include + namespace SALOMESDS { class PickelizedPyObjServer : public BasicDataServer, public virtual POA_SALOME::PickelizedPyObjServer { public: - PickelizedPyObjServer(DataScopeServer *father, const std::string& varName, const SALOME::ByteVec& value); - PickelizedPyObjServer(DataScopeServer *father, const std::string& varName, PyObject *obj); - ~PickelizedPyObjServer(); + PickelizedPyObjServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value); + PickelizedPyObjServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj); + virtual ~PickelizedPyObjServer(); void setSerializedContent(const SALOME::ByteVec& newValue); SALOME::ByteVec *fetchSerializedContent(); - protected: + public: + bool isDict(); + void checkKeyNotAlreadyPresent(PyObject *key); + void checkKeyPresent(PyObject *key); + PyObject *getPyObj() const { return _self; } + public: + virtual void addKeyValueHard(PyObject *key, PyObject *value); + virtual void removeKeyInVarErrorIfNotAlreadyExisting(PyObject *key); + virtual void addKeyValueErrorIfAlreadyExisting(PyObject *key, PyObject *value) = 0; + virtual std::string getAccessStr() const = 0; + public: static void FromByteSeqToCpp(const SALOME::ByteVec& bsToBeConv, std::string& ret); + static void FromCppToByteSeq(const std::string& strToBeConv, SALOME::ByteVec& ret); static SALOME::ByteVec *FromCppToByteSeq(const std::string& strToBeConv); + static PyObject *GetPyObjFromPickled(const std::string& pickledData, DataScopeServerBase *dsb); + static PyObject *GetPyObjFromPickled(const std::vector& pickledData, DataScopeServerBase *dsb); + static std::string Pickelize(PyObject *obj, DataScopeServerBase *dsb); PyObject *getPyObjFromPickled(const std::string& pickledData); + PyObject *getPyObjFromPickled(const std::vector& pickledData); std::string pickelize(PyObject *obj); void setNewPyObj(PyObject *obj); void setSerializedContentInternal(const SALOME::ByteVec& newValue); static PyObject *CreateDftObjFromType(PyObject *globals, const std::string& typeName); + private: + void checkKeyPresence(PyObject *key, bool presence); protected: static const char FAKE_VAR_NAME_FOR_WORK[]; PyObject *_self; PortableServer::POA_var _poa; }; + + class PickelizedPyObjServerModifiable : public PickelizedPyObjServer + { + public: + PickelizedPyObjServerModifiable(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value); + PickelizedPyObjServerModifiable(DataScopeServerBase *father, const std::string& varName, PyObject *obj); + public: + void addKeyValueErrorIfAlreadyExisting(PyObject *key, PyObject *value); + void removeKeyInVarErrorIfNotAlreadyExisting(PyObject *key); + }; } #endif