Salome HOME
python_test_driver.py declination of salome_test_driver.py for SSL mode (timeout...
[modules/kernel.git] / src / SALOMESDS / SALOMESDS_PickelizedPyObjServer.hxx
index 2d94ca1d6a564c381575cc81c2f905a8bd32bbf4..365ac5bdb9f46910ffe677c5084f627a418d5786 100644 (file)
@@ -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
 
 #include "SALOMESDS_BasicDataServer.hxx"
 
+#include <vector>
+
 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<unsigned char>& pickledData, DataScopeServerBase *dsb);
+    static std::string Pickelize(PyObject *obj, DataScopeServerBase *dsb);
     PyObject *getPyObjFromPickled(const std::string& pickledData);
+    PyObject *getPyObjFromPickled(const std::vector<unsigned char>& 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