From 19218ce907e14ee8293dc0b3d22d342e6ae1283f Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 13 Jul 2015 16:34:51 +0200 Subject: [PATCH] Still continue. --- idl/SALOME_SDS.idl | 2 + src/SALOMESDS/SALOMESDS_BasicDataServer.cxx | 2 +- src/SALOMESDS/SALOMESDS_BasicDataServer.hxx | 6 +- src/SALOMESDS/SALOMESDS_DataScopeServer.cxx | 71 ++++++++++++++++++- src/SALOMESDS/SALOMESDS_DataScopeServer.hxx | 20 +++--- .../SALOMESDS_PickelizedPyObjRdExtServer.cxx | 4 +- .../SALOMESDS_PickelizedPyObjRdExtServer.hxx | 4 +- .../SALOMESDS_PickelizedPyObjRdOnlyServer.cxx | 4 +- .../SALOMESDS_PickelizedPyObjRdOnlyServer.hxx | 4 +- .../SALOMESDS_PickelizedPyObjRdWrServer.cxx | 6 +- .../SALOMESDS_PickelizedPyObjRdWrServer.hxx | 6 +- .../SALOMESDS_PickelizedPyObjServer.cxx | 4 +- .../SALOMESDS_PickelizedPyObjServer.hxx | 4 +- src/SALOMESDS/SALOMESDS_Transaction.cxx | 39 +++++++++- src/SALOMESDS/SALOMESDS_Transaction.hxx | 29 +++++++- 15 files changed, 166 insertions(+), 39 deletions(-) diff --git a/idl/SALOME_SDS.idl b/idl/SALOME_SDS.idl index 9986edfdc..fac3ecdfb 100644 --- a/idl/SALOME_SDS.idl +++ b/idl/SALOME_SDS.idl @@ -84,6 +84,8 @@ module SALOME interface DataScopeServerTransaction : DataScopeServerBase { Transaction createRdOnlyVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception); + Transaction createRdExtVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception); + Transaction createRdWrVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception); void atomicApply(in ListOfTransaction transactions) raises (SALOME::SALOME_Exception); }; diff --git a/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx b/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx index d0f102838..d1bb917f5 100644 --- a/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx +++ b/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx @@ -28,7 +28,7 @@ using namespace SALOMESDS; int BasicDataServer::POA_CNT=0; -BasicDataServer::BasicDataServer(DataScopeServer *father, const std::string& varName):_father(father),_var_name(varName) +BasicDataServer::BasicDataServer(DataScopeServerBase *father, const std::string& varName):_father(father),_var_name(varName) { PortableServer::POA_var poa(_father->getPOA()); PortableServer::POAManager_var pman(poa->the_POAManager()); diff --git a/src/SALOMESDS/SALOMESDS_BasicDataServer.hxx b/src/SALOMESDS/SALOMESDS_BasicDataServer.hxx index bf146b893..9d0bc679f 100644 --- a/src/SALOMESDS/SALOMESDS_BasicDataServer.hxx +++ b/src/SALOMESDS/SALOMESDS_BasicDataServer.hxx @@ -30,12 +30,12 @@ namespace SALOMESDS { - class DataScopeServer; + class DataScopeServerBase; class BasicDataServer : public RefCountServ, public virtual POA_SALOME::BasicDataServer { public: - BasicDataServer(DataScopeServer *father, const std::string& varName); + BasicDataServer(DataScopeServerBase *father, const std::string& varName); SALOME::DataScopeServer_ptr getMyDataScopeServer(); char *getVarName(); char *getScopeName(); @@ -48,7 +48,7 @@ namespace SALOMESDS protected: PortableServer::POA_var getPOA() const { return _poa; } protected: - DataScopeServer *_father; + DataScopeServerBase *_father; private: std::string _var_name; PortableServer::POA_var _poa; diff --git a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx index 82b1fa20c..c08cfc2ee 100644 --- a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx +++ b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx @@ -303,14 +303,72 @@ DataScopeServerTransaction::DataScopeServerTransaction(const DataScopeServerTran { } +void DataScopeServerTransaction::createRdOnlyVarInternal(const std::string& varName, const SALOME::ByteVec& constValue) +{ + checkNotAlreadyExistingVar(varName); + PickelizedPyObjRdOnlyServer *tmp(new PickelizedPyObjRdOnlyServer(this,varName,constValue)); + CORBA::Object_var ret(activateWithDedicatedPOA(tmp)); + std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp); + _vars.push_back(p); +} + +void DataScopeServerTransaction::createRdExtVarInternal(const std::string& varName, const SALOME::ByteVec& constValue) +{ + checkNotAlreadyExistingVar(varName); + PickelizedPyObjRdExtServer *tmp(new PickelizedPyObjRdExtServer(this,varName,constValue)); + CORBA::Object_var ret(activateWithDedicatedPOA(tmp)); + std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp); + _vars.push_back(p); +} + +void DataScopeServerTransaction::createRdWrVarInternal(const std::string& varName, const SALOME::ByteVec& constValue) +{ + checkNotAlreadyExistingVar(varName); + PickelizedPyObjRdWrServer *tmp(new PickelizedPyObjRdWrServer(this,varName,constValue)); + CORBA::Object_var ret(activateWithDedicatedPOA(tmp)); + std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp); + _vars.push_back(p); +} + SALOME::Transaction_ptr DataScopeServerTransaction::createRdOnlyVarTransac(const char *varName, const SALOME::ByteVec& constValue) { - TransactionRdOnlyVarCreate *ret(new TransactionRdOnlyVarCreate(varName,constValue)); + TransactionRdOnlyVarCreate *ret(new TransactionRdOnlyVarCreate(this,varName,constValue)); + ret->checkNotAlreadyExisting(); + PortableServer::ObjectId_var id(_poa->activate_object(ret)); + CORBA::Object_var obj(_poa->id_to_reference(id)); + return SALOME::Transaction::_narrow(obj); +} + +SALOME::Transaction_ptr DataScopeServerTransaction::createRdExtVarTransac(const char *varName, const SALOME::ByteVec& constValue) +{ + TransactionRdExtVarCreate *ret(new TransactionRdExtVarCreate(this,varName,constValue)); + ret->checkNotAlreadyExisting(); + PortableServer::ObjectId_var id(_poa->activate_object(ret)); + CORBA::Object_var obj(_poa->id_to_reference(id)); + return SALOME::Transaction::_narrow(obj); +} + +SALOME::Transaction_ptr DataScopeServerTransaction::createRdWrVarTransac(const char *varName, const SALOME::ByteVec& constValue) +{ + TransactionRdWrVarCreate *ret(new TransactionRdWrVarCreate(this,varName,constValue)); + ret->checkNotAlreadyExisting(); PortableServer::ObjectId_var id(_poa->activate_object(ret)); CORBA::Object_var obj(_poa->id_to_reference(id)); return SALOME::Transaction::_narrow(obj); } +class TrustTransaction +{ +public: + TrustTransaction():_must_rollback(0),_ptr(0) { } + void setTransaction(Transaction *t, bool *mustRollback) { if(!t || !mustRollback) throw Exception("TrustTransaction Error #1"); _must_rollback=mustRollback; t->prepareRollBackInCaseOfFailure(); } + void operate() { _ptr->perform(); } + ~TrustTransaction() { if(!_ptr) return ; if(*_must_rollback) _ptr->rollBack(); } +private: + bool *_must_rollback; + Transaction *_ptr; +}; + void DataScopeServerTransaction::atomicApply(const SALOME::ListOfTransaction& transactions) { std::size_t sz(transactions.length()); @@ -340,8 +398,15 @@ void DataScopeServerTransaction::atomicApply(const SALOME::ListOfTransaction& tr transactionsCpp[i]=elt; transactionsCpp[i].setHolder(this); } - for(std::size_t i=0;iprepareRollBackInCaseOfFailure(); + {// important do not merge loops ! + std::vector transactions2(sz); + bool mustRollback(true); + for(std::size_t i=0;i getAllVarNames() const; CORBA::Object_var activateWithDedicatedPOA(BasicDataServer *ds); void checkNotAlreadyExistingVar(const std::string& varName); @@ -91,17 +89,21 @@ namespace SALOMESDS class SALOMESDS_EXPORT DataScopeServerTransaction : public DataScopeServerBase, public virtual POA_SALOME::DataScopeServerTransaction { - public: + public://not remotely callable DataScopeServerTransaction(CORBA::ORB_ptr orb, const std::string& scopeName); DataScopeServerTransaction(const DataScopeServerTransaction& other); + ~DataScopeServerTransaction(); + void createRdOnlyVarInternal(const std::string& varName, const SALOME::ByteVec& constValue); + void createRdExtVarInternal(const std::string& varName, const SALOME::ByteVec& constValue); + void createRdWrVarInternal(const std::string& varName, const SALOME::ByteVec& constValue); + public://remotely callable SALOME::Transaction_ptr createRdOnlyVarTransac(const char *varName, const SALOME::ByteVec& constValue); + SALOME::Transaction_ptr createRdExtVarTransac(const char *varName, const SALOME::ByteVec& constValue); + SALOME::Transaction_ptr createRdWrVarTransac(const char *varName, const SALOME::ByteVec& constValue); void atomicApply(const SALOME::ListOfTransaction& transactions); - ~DataScopeServerTransaction(); }; - /*SALOME::Transaction_ptr createRdOnlyVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constValue); - SALOME::Transaction_ptr createRdExtVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constValue); - SALOME::Transaction_ptr createRdWrVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constValue); + /* SALOME::Transaction_ptr addKeyValueInVarErrorIfAlreadyExisting(const char *varName, const char *scopeName, const SALOME::ByteVec& key, const SALOME::ByteVec& value); SALOME::Transaction_ptr addKeyValueInVarHard(const char *varName, const char *scopeName, const SALOME::ByteVec& key, const SALOME::ByteVec& value); SALOME::Transaction_ptr removeKeyInVarErrorIfNotAlreadyExisting(const char *varName, const char *scopeName, const SALOME::ByteVec& key); diff --git a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdExtServer.cxx b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdExtServer.cxx index 50e2e05f6..0b1a196cc 100644 --- a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdExtServer.cxx +++ b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdExtServer.cxx @@ -27,12 +27,12 @@ using namespace SALOMESDS; -PickelizedPyObjRdExtServer::PickelizedPyObjRdExtServer(DataScopeServer *father, const std::string& varName, const SALOME::ByteVec& value):PickelizedPyObjServer(father,varName,value) +PickelizedPyObjRdExtServer::PickelizedPyObjRdExtServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value):PickelizedPyObjServer(father,varName,value) { } //! obj is consumed -PickelizedPyObjRdExtServer::PickelizedPyObjRdExtServer(DataScopeServer *father, const std::string& varName, PyObject *obj):PickelizedPyObjServer(father,varName,obj) +PickelizedPyObjRdExtServer::PickelizedPyObjRdExtServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj):PickelizedPyObjServer(father,varName,obj) { } diff --git a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdExtServer.hxx b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdExtServer.hxx index 72ab70895..d982c165b 100644 --- a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdExtServer.hxx +++ b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdExtServer.hxx @@ -33,8 +33,8 @@ namespace SALOMESDS class PickelizedPyObjRdExtServer : public PickelizedPyObjServer, public virtual POA_SALOME::PickelizedPyObjRdExtServer { public: - PickelizedPyObjRdExtServer(DataScopeServer *father, const std::string& varName, const SALOME::ByteVec& value); - PickelizedPyObjRdExtServer(DataScopeServer *father, const std::string& varName, PyObject *obj); + PickelizedPyObjRdExtServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value); + PickelizedPyObjRdExtServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj); ~PickelizedPyObjRdExtServer(); SALOME::PickelizedPyObjRdExtServer_ptr invokePythonMethodOn(const char *method, const SALOME::ByteVec& args); private: diff --git a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdOnlyServer.cxx b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdOnlyServer.cxx index da86efb92..e8bef2342 100644 --- a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdOnlyServer.cxx +++ b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdOnlyServer.cxx @@ -22,11 +22,11 @@ using namespace SALOMESDS; -PickelizedPyObjRdOnlyServer::PickelizedPyObjRdOnlyServer(DataScopeServer *father, const std::string& varName, const SALOME::ByteVec& value):PickelizedPyObjServer(father,varName,value) +PickelizedPyObjRdOnlyServer::PickelizedPyObjRdOnlyServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value):PickelizedPyObjServer(father,varName,value) { } -PickelizedPyObjRdOnlyServer::PickelizedPyObjRdOnlyServer(DataScopeServer *father, const std::string& varName, PyObject *obj):PickelizedPyObjServer(father,varName,obj) +PickelizedPyObjRdOnlyServer::PickelizedPyObjRdOnlyServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj):PickelizedPyObjServer(father,varName,obj) { } diff --git a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdOnlyServer.hxx b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdOnlyServer.hxx index 9ae3bb221..a5047fdaa 100644 --- a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdOnlyServer.hxx +++ b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdOnlyServer.hxx @@ -33,8 +33,8 @@ namespace SALOMESDS class PickelizedPyObjRdOnlyServer : public PickelizedPyObjServer, public virtual POA_SALOME::PickelizedPyObjRdOnlyServer { public: - PickelizedPyObjRdOnlyServer(DataScopeServer *father, const std::string& varName, const SALOME::ByteVec& value); - PickelizedPyObjRdOnlyServer(DataScopeServer *father, const std::string& varName, PyObject *obj); + PickelizedPyObjRdOnlyServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value); + PickelizedPyObjRdOnlyServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj); ~PickelizedPyObjRdOnlyServer(); }; } diff --git a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdWrServer.cxx b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdWrServer.cxx index 5e982de50..cdb0d6922 100644 --- a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdWrServer.cxx +++ b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdWrServer.cxx @@ -27,16 +27,16 @@ using namespace SALOMESDS; -PickelizedPyObjRdWrServer::PickelizedPyObjRdWrServer(DataScopeServer *father, const std::string& typeName, const std::string& varName):PickelizedPyObjServer(father,varName,CreateDftObjFromType(father->getGlobals(),typeName)) +PickelizedPyObjRdWrServer::PickelizedPyObjRdWrServer(DataScopeServerBase *father, const std::string& typeName, const std::string& varName):PickelizedPyObjServer(father,varName,CreateDftObjFromType(father->getGlobals(),typeName)) { } -PickelizedPyObjRdWrServer::PickelizedPyObjRdWrServer(DataScopeServer *father, const std::string& varName, const SALOME::ByteVec& value):PickelizedPyObjServer(father,varName,value) +PickelizedPyObjRdWrServer::PickelizedPyObjRdWrServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value):PickelizedPyObjServer(father,varName,value) { } //! obj is consumed -PickelizedPyObjRdWrServer::PickelizedPyObjRdWrServer(DataScopeServer *father, const std::string& varName, PyObject *obj):PickelizedPyObjServer(father,varName,obj) +PickelizedPyObjRdWrServer::PickelizedPyObjRdWrServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj):PickelizedPyObjServer(father,varName,obj) { } diff --git a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdWrServer.hxx b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdWrServer.hxx index 858ca771d..b6fba2f21 100644 --- a/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdWrServer.hxx +++ b/src/SALOMESDS/SALOMESDS_PickelizedPyObjRdWrServer.hxx @@ -33,9 +33,9 @@ namespace SALOMESDS class PickelizedPyObjRdWrServer : public PickelizedPyObjServer, public virtual POA_SALOME::PickelizedPyObjRdWrServer { public: - PickelizedPyObjRdWrServer(DataScopeServer *father, const std::string& typeName, const std::string& varName); - PickelizedPyObjRdWrServer(DataScopeServer *father, const std::string& varName, const SALOME::ByteVec& value); - PickelizedPyObjRdWrServer(DataScopeServer *father, const std::string& varName, PyObject *obj); + PickelizedPyObjRdWrServer(DataScopeServerBase *father, const std::string& typeName, const std::string& varName); + PickelizedPyObjRdWrServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value); + PickelizedPyObjRdWrServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj); ~PickelizedPyObjRdWrServer(); void setSerializedContent(const SALOME::ByteVec& newValue); SALOME::PickelizedPyObjRdWrServer_ptr invokePythonMethodOn(const char *method, const SALOME::ByteVec& args); diff --git a/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.cxx b/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.cxx index 149425051..2bc0c120c 100644 --- a/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.cxx +++ b/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.cxx @@ -27,13 +27,13 @@ using namespace SALOMESDS; -PickelizedPyObjServer::PickelizedPyObjServer(DataScopeServer *father, const std::string& varName, const SALOME::ByteVec& value):BasicDataServer(father,varName),_self(0) +PickelizedPyObjServer::PickelizedPyObjServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value):BasicDataServer(father,varName),_self(0) { setSerializedContentInternal(value); } //! obj is consumed -PickelizedPyObjServer::PickelizedPyObjServer(DataScopeServer *father, const std::string& varName, PyObject *obj):BasicDataServer(father,varName),_self(0) +PickelizedPyObjServer::PickelizedPyObjServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj):BasicDataServer(father,varName),_self(0) { setNewPyObj(obj); } diff --git a/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.hxx b/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.hxx index 2d94ca1d6..e216262cd 100644 --- a/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.hxx +++ b/src/SALOMESDS/SALOMESDS_PickelizedPyObjServer.hxx @@ -33,8 +33,8 @@ 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(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value); + PickelizedPyObjServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj); ~PickelizedPyObjServer(); void setSerializedContent(const SALOME::ByteVec& newValue); SALOME::ByteVec *fetchSerializedContent(); diff --git a/src/SALOMESDS/SALOMESDS_Transaction.cxx b/src/SALOMESDS/SALOMESDS_Transaction.cxx index 3ceb547cd..31778707c 100644 --- a/src/SALOMESDS/SALOMESDS_Transaction.cxx +++ b/src/SALOMESDS/SALOMESDS_Transaction.cxx @@ -19,7 +19,6 @@ // Author : Anthony GEAY (EDF R&D) #include "SALOMESDS_Transaction.hxx" -#include "SALOMESDS_DataServerManager.hxx" #include "SALOMESDS_Exception.hxx" #include @@ -35,11 +34,47 @@ void Transaction::FromByteSeqToVB(const SALOME::ByteVec& bsToBeConv, std::vector buf[i]=bsToBeConv[i]; } -TransactionVarCreate::TransactionVarCreate(const std::string& varName, const SALOME::ByteVec& constValue):Transaction(varName) +void Transaction::FromVBToByteSeq(const std::vector& bsToBeConv, SALOME::ByteVec& ret) +{ + std::size_t sz(bsToBeConv.size()); + ret.length(sz); + for(std::size_t i=0;iexistVar(_var_name.c_str())) + _dsct->deleteVar(_var_name.c_str()); +} + +void TransactionRdOnlyVarCreate::perform() +{ + SALOME::ByteVec data2; + FromVBToByteSeq(_data,data2); + _dsct->createRdOnlyVarInternal(_var_name,data2); +} + +void TransactionRdExtVarCreate::perform() +{ + SALOME::ByteVec data2; + FromVBToByteSeq(_data,data2); + _dsct->createRdExtVarInternal(_var_name,data2); +} + +void TransactionRdWrVarCreate::perform() +{ + SALOME::ByteVec data2; + FromVBToByteSeq(_data,data2); + _dsct->createRdWrVarInternal(_var_name,data2); } diff --git a/src/SALOMESDS/SALOMESDS_Transaction.hxx b/src/SALOMESDS/SALOMESDS_Transaction.hxx index 5e8e513ec..805b8d647 100644 --- a/src/SALOMESDS/SALOMESDS_Transaction.hxx +++ b/src/SALOMESDS/SALOMESDS_Transaction.hxx @@ -25,6 +25,8 @@ #include CORBA_SERVER_HEADER(SALOME_SDS) #include "SALOMESDS_Defines.hxx" +#include "SALOMESDS_Exception.hxx" +#include "SALOMESDS_DataServerManager.hxx" #include #include @@ -34,20 +36,26 @@ namespace SALOMESDS class SALOMESDS_EXPORT Transaction : public virtual POA_SALOME::Transaction { public: - Transaction(const std::string& varName):_var_name(varName) { } + Transaction(DataScopeServerTransaction *dsct, const std::string& varName):_dsct(dsct),_var_name(varName) { if(!_dsct) throw Exception("Transaction constructor error !"); } std::string getVarName() const { return _var_name; } virtual void prepareRollBackInCaseOfFailure() = 0; + virtual void perform() = 0; + virtual void rollBack() = 0; public: static void FromByteSeqToVB(const SALOME::ByteVec& bsToBeConv, std::vector& ret); + static void FromVBToByteSeq(const std::vector& bsToBeConv, SALOME::ByteVec& ret); protected: + DataScopeServerTransaction *_dsct; std::string _var_name; }; class TransactionVarCreate : public Transaction { public: - TransactionVarCreate(const std::string& varName, const SALOME::ByteVec& constValue); + TransactionVarCreate(DataScopeServerTransaction *dsct, const std::string& varName, const SALOME::ByteVec& constValue); + void checkNotAlreadyExisting() { _dsct->checkNotAlreadyExistingVar(_var_name); } void prepareRollBackInCaseOfFailure(); + void rollBack(); protected: std::vector _data; }; @@ -55,7 +63,22 @@ namespace SALOMESDS class TransactionRdOnlyVarCreate : public TransactionVarCreate { public: - TransactionRdOnlyVarCreate(const std::string& varName, const SALOME::ByteVec& constValue):TransactionVarCreate(varName,constValue) { } + TransactionRdOnlyVarCreate(DataScopeServerTransaction *dsct, const std::string& varName, const SALOME::ByteVec& constValue):TransactionVarCreate(dsct,varName,constValue) { } + void perform(); + }; + + class TransactionRdExtVarCreate : public TransactionVarCreate + { + public: + TransactionRdExtVarCreate(DataScopeServerTransaction *dsct, const std::string& varName, const SALOME::ByteVec& constValue):TransactionVarCreate(dsct,varName,constValue) { } + void perform(); + }; + + class TransactionRdWrVarCreate : public TransactionVarCreate + { + public: + TransactionRdWrVarCreate(DataScopeServerTransaction *dsct, const std::string& varName, const SALOME::ByteVec& constValue):TransactionVarCreate(dsct,varName,constValue) { } + void perform(); }; } -- 2.39.2