From 19f7bede98e38c57fb86afa3eed80da205713780 Mon Sep 17 00:00:00 2001 From: caremoli Date: Mon, 3 Jan 2011 14:00:38 +0000 Subject: [PATCH] CCAR: add a new operation (SetAttrString) to SObject CORBA interface to be able to set an attribute value (of type string) without creating the intermediate Attribute object (faster) --- idl/SALOMEDS.idl | 7 +++++++ src/Basics/Basics_Utils.hxx | 12 ++++++++++++ src/SALOMEDS/SALOMEDS_SObject.cxx | 13 +++++++++++++ src/SALOMEDS/SALOMEDS_SObject.hxx | 1 + src/SALOMEDS/SALOMEDS_SObject_i.cxx | 11 +++++++++++ src/SALOMEDS/SALOMEDS_SObject_i.hxx | 1 + src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx | 1 + src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx | 7 +++++++ src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx | 1 + 9 files changed, 54 insertions(+) diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 0cc5780ca..85efbab4c 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -1091,6 +1091,13 @@ Gets the list of open studies */ string GetIOR(); +/*! + Set an attribute value (of type string) + \param name the name of the attribute + \param value the value of the attribute +*/ + void SetAttrString(in string name, in string value); + /*! Private method, returns an implementation of this SObject. \param theHostname is a hostname of the caller diff --git a/src/Basics/Basics_Utils.hxx b/src/Basics/Basics_Utils.hxx index 7442518b9..ce0513c49 100644 --- a/src/Basics/Basics_Utils.hxx +++ b/src/Basics/Basics_Utils.hxx @@ -28,6 +28,8 @@ #include "SALOME_Basics.hxx" #include +#include +#include namespace Kernel_Utils { @@ -52,4 +54,14 @@ namespace Kernel_Utils BASICS_EXPORT std::string GetGUID( GUIDtype ); } +#define START_TIMING(name) static long name##tcount=0;static long name##cumul;long name##tt0; timeval name##tv; gettimeofday(&name##tv,0); \ + name##tt0=name##tv.tv_usec+name##tv.tv_sec*1000000; \ + if(name##tcount==0)std::cerr<<__FILE__<<":"<<__LINE__<<":"<<#name<::IsAlreadyExisting()); _orb = init(0 , 0 ) ; } + +void SALOMEDS_SObject::SetAttrString(const std::string& name, const std::string& value) +{ + if(_isLocal) + { + SALOMEDS::Locker lock; + _local_impl->SetAttrString(name,value); + } + else + { + _corba_impl->SetAttrString(name.c_str(),value.c_str()); + } +} diff --git a/src/SALOMEDS/SALOMEDS_SObject.hxx b/src/SALOMEDS/SALOMEDS_SObject.hxx index 7866ec901..e7d4b3aee 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.hxx +++ b/src/SALOMEDS/SALOMEDS_SObject.hxx @@ -66,6 +66,7 @@ public: virtual std::string GetName(); virtual std::string GetComment(); virtual std::string GetIOR(); + virtual void SetAttrString(const std::string& name, const std::string& value); virtual int Tag(); virtual int Depth(); diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index 76cd689b0..8de5670dd 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -318,6 +318,17 @@ char* SALOMEDS_SObject_i::GetIOR() return aStr._retn(); } +//============================================================================ +/*! Function : SetAttrString + * Purpose : + */ +//============================================================================ +void SALOMEDS_SObject_i::SetAttrString(const char* name, const char* value) +{ + SALOMEDS::Locker lock; + _impl->SetAttrString(name,value); +} + //=========================================================================== // PRIVATE FUNCTIONS //=========================================================================== diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.hxx b/src/SALOMEDS/SALOMEDS_SObject_i.hxx index c9dd3c123..d56372308 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.hxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.hxx @@ -71,6 +71,7 @@ public: virtual char* GetName(); virtual char* GetComment(); virtual char* GetIOR(); + virtual void SetAttrString(const char*, const char*); virtual CORBA::Short Tag(); virtual CORBA::Short Depth(); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx index 1762ec9a0..668e1a142 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx @@ -41,6 +41,7 @@ static CORBA::ORB_var getORB() void IORGenericObjDecref(const std::string& anIOR) { + if(anIOR=="")return; CORBA::Object_var obj; SALOME::GenericObj_var gobj; try diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx index d2028fe7b..7cf41a0f8 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.cxx @@ -292,3 +292,10 @@ bool SALOMEDSImpl_SObject::IsComponent() const return SALOMEDSImpl_SComponent::IsA(_lab); } +void SALOMEDSImpl_SObject::SetAttrString(const std::string& name, const std::string& value) +{ + if(name=="AttributeName")SALOMEDSImpl_AttributeName::Set(GetLabel(), value); + else if(name=="AttributeIOR")SALOMEDSImpl_AttributeIOR::Set(GetLabel(), value); + else if(name=="AttributeString")SALOMEDSImpl_AttributeString::Set(GetLabel(), value); + else if(name=="AttributePixMap")SALOMEDSImpl_AttributePixMap::Set(GetLabel(), value); +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx index 5c049fba3..54a799953 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx @@ -67,6 +67,7 @@ public: virtual std::string GetName() const ; virtual std::string GetComment() const; virtual std::string GetIOR() const; + virtual void SetAttrString(const std::string& name,const std::string& value); virtual int Tag() const { return _lab.Tag(); } virtual int Depth() const { return _lab.Depth(); } -- 2.39.2