-// 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_PickelizedPyObjServer.hxx"
#include "SALOMESDS_PickelizedPyObjRdWrServer.hxx"
#include "SALOMESDS_PickelizedPyObjRdExtServer.hxx"
+#include "SALOMESDS_TrustTransaction.hxx"
#include <sstream>
ret.resize(sz);
unsigned char *buf(const_cast<unsigned char *>(&ret[0]));
for(std::size_t i=0;i<sz;i++)
- buf[i]=bsToBeConv[i];
+ buf[i]=bsToBeConv[(CORBA::ULong)i]; //!< TODO: size_t to CORBA::ULong
}
void Transaction::FromVBToByteSeq(const std::vector<unsigned char>& bsToBeConv, SALOME::ByteVec& ret)
{
std::size_t sz(bsToBeConv.size());
- ret.length(sz);
+ ret.length((CORBA::ULong)sz); //!< TODO: size_t to CORBA::ULong
for(std::size_t i=0;i<sz;i++)
- ret[i]=bsToBeConv[i];
+ ret[(CORBA::ULong)i]=bsToBeConv[i]; //!< TODO: size_t to CORBA::ULong
}
Transaction::~Transaction()
}
void TransactionVarCreate::prepareRollBackInCaseOfFailure()
-{//nothing it is not a bug
+{
checkNotAlreadyExisting();
}
_dsct->createRdExtVarInternal(_var_name,data2);
}
+TransactionRdExtVarFreeStyleCreate::TransactionRdExtVarFreeStyleCreate(DataScopeServerTransaction *dsct, const std::string& varName, const SALOME::ByteVec& constValue, const char *compareFuncContent):TransactionRdExtVarCreate(dsct,varName,constValue),_cmp_func_content(compareFuncContent),_cmp_func(nullptr)
+{
+ constexpr char EXPECTED_COMPARE_FUNC_NAME[]="comptchev";
+ SALOME::AutoPyRef context(PyDict_New());
+ SALOME::AutoPyRef res(PyRun_String(compareFuncContent,Py_file_input,_dsct->getGlobals(),context));
+ if(res.isNull())
+ {
+ std::ostringstream oss; oss << "TransactionRdExtVarFreeStyleCreate ctor : Fail to parse and evaluate \"" << compareFuncContent << "\" as python function !";
+ throw Exception(oss.str());
+ }
+ PyObject *func(PyDict_GetItemString(context,EXPECTED_COMPARE_FUNC_NAME));//borrowed
+ if(!func)
+ {
+ std::ostringstream oss; oss << "TransactionRdExtVarFreeStyleCreate ctor : Parsing of func is OK but not func called \"" << EXPECTED_COMPARE_FUNC_NAME << "\" is the given parsed string !";
+ throw Exception(oss.str());
+ }
+ _cmp_func = func; Py_XINCREF(func);
+ if(PyDict_DelItemString(context,EXPECTED_COMPARE_FUNC_NAME)!=0)
+ {
+ std::ostringstream oss; oss << "TransactionRdExtVarFreeStyleCreate ctor : Internal error during suppression of \"" << EXPECTED_COMPARE_FUNC_NAME << "\" key that exepect to be present ! Smells bad !";
+ throw Exception(oss.str());
+ }
+}
+
+void TransactionRdExtVarFreeStyleCreate::prepareRollBackInCaseOfFailure()
+{//nothing it is not a bug
+}
+
+void TransactionRdExtVarFreeStyleCreate::rollBack()
+{// nothing to be done here. Fress style means I don t care. Do not remove var.
+ if(!_null_rollback)
+ TransactionRdExtVarCreate::rollBack();
+}
+
+void TransactionRdExtVarFreeStyleCreate::perform()
+{
+ SALOME::ByteVec data2;
+ FromVBToByteSeq(_data,data2);
+ try
+ {
+ _dsct->createRdExtVarFreeStyleInternal(_var_name,data2,std::move(_cmp_func_content),std::move(_cmp_func));
+ }
+ catch(NotSameException& e)
+ {
+ _null_rollback = true;
+ throw e;
+ }
+}
+
+void TransactionRdExtInitVarCreate::perform()
+{
+ SALOME::ByteVec data2;
+ FromVBToByteSeq(_data,data2);
+ _dsct->createRdExtInitVarInternal(_var_name,data2);
+}
+
void TransactionRdWrVarCreate::perform()
{
SALOME::ByteVec data2;
_dsct->createRdWrVarInternal(_var_name,data2);
}
+TransactionKillVar::TransactionKillVar(DataScopeServerTransaction *dsct, const std::string& varName):Transaction(dsct,varName)
+{
+}
+
+/*!
+ * TODO
+ */
+void TransactionKillVar::prepareRollBackInCaseOfFailure()
+{
+ checkVarExisting();
+ //BasicDataServer *bds(_dsct->retrieveVarInternal2(_var_name);
+ //bds->clone();
+}
+
+void TransactionKillVar::perform()
+{
+ _dsct->deleteVar(_var_name.c_str());
+}
+
+/*!
+ * TODO
+ */
+void TransactionKillVar::rollBack()
+{
+}
+
+/*!
+ * no implementation it is not a bug ! killVar is not an event.
+ */
+void TransactionKillVar::notify()
+{
+}
+
TransactionDictModify::TransactionDictModify(DataScopeServerTransaction *dsct, const std::string& varName):Transaction(dsct,varName),_varc(0)
{
_varc=checkVarExistingAndDict();
void TransactionMorphRdWrIntoRdOnly::notify()
{
}
+
+TransactionMultiKeyAddSession::TransactionMultiKeyAddSession(DataScopeServerTransaction *dsct, const std::string& varName):Transaction(dsct,varName)
+{
+ _dsct->moveStatusOfVarFromRdExtOrRdExtInitToRdExtInit(_var_name);
+}
+
+void TransactionMultiKeyAddSession::addKeyValueInVarErrorIfAlreadyExistingNow(const SALOME::ByteVec& key, const SALOME::ByteVec& value)
+{
+ _dsct->checkVarExistingAndDict(_var_name);
+ TransactionAddKeyValueErrorIfAlreadyExisting ret(_dsct,_var_name,key,value);
+ {
+ ret.perform();
+ /*bool mustRollback(true);
+ TrustTransaction t;
+ t.setTransaction(&ret,&mustRollback);
+ t.operate();
+ mustRollback=false;//important let this line to notify t that everything was OK*/
+ }
+ ret.notify();
+}
+
+/*!
+ * no implementation it is not a bug !
+ */
+void TransactionMultiKeyAddSession::prepareRollBackInCaseOfFailure()
+{
+}
+
+void TransactionMultiKeyAddSession::perform()
+{
+ _dsct->moveStatusOfVarFromRdExtOrRdExtInitToRdExt(_var_name);
+}
+
+/*!
+ * no implementation it is not a bug !
+ */
+void TransactionMultiKeyAddSession::rollBack()
+{
+}
+
+/*!
+ * no implementation it is not a bug !
+ */
+void TransactionMultiKeyAddSession::notify()
+{
+}
+