Salome HOME
Merge remote-tracking branch 'origin/master'
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeParameter_i.cxx
index ff5023dbfd9020ff047b0082d5aa2a0b72eb9caa..40eca2d82045177638d3f2b04349be405915f552 100644 (file)
@@ -1,34 +1,36 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
+//
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // Lesser General Public License for more details.
 //
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  File   : SALOMEDS_AttributeParameter_i.cxx
 //  Author : Sergey RUIN
 //  Module : SALOME
-
-
+//
 #include "SALOMEDS_AttributeParameter_i.hxx"
 #include "SALOMEDS.hxx"
-#include <TCollection_AsciiString.hxx>
 
 #include <vector>
 
-using namespace std;
+#include "Utils_ExceptHandlers.hxx"
+UNEXPECT_CATCH(AP_InvalidIdentifier, SALOMEDS::AttributeParameter::InvalidIdentifier);
 
 //=======================================================================
 /*!
@@ -40,7 +42,7 @@ void SALOMEDS_AttributeParameter_i::SetInt(const char* theID, CORBA::Long theVal
 {
   SALOMEDS::Locker lock; 
   CheckLocked();
-  Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetInt(theID, theValue);
+  dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetInt(theID, theValue);
 }
 
 //=======================================================================
@@ -50,9 +52,11 @@ void SALOMEDS_AttributeParameter_i::SetInt(const char* theID, CORBA::Long theVal
  */
 //=======================================================================
 CORBA::Long SALOMEDS_AttributeParameter_i::GetInt(const char* theID)
+  throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
 {
   SALOMEDS::Locker lock; 
-  return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetInt(theID);
+  Unexpect aCatch (AP_InvalidIdentifier);
+  return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetInt(theID);
 }
 
 //=======================================================================
@@ -61,11 +65,11 @@ CORBA::Long SALOMEDS_AttributeParameter_i::GetInt(const char* theID)
  * Purpose  : Associates a double value with the ID
  */
 //=======================================================================
-void SALOMEDS_AttributeParameter_i::SetReal(const char* theID, const CORBA::Double theValue)
+void SALOMEDS_AttributeParameter_i::SetReal(const char* theID, CORBA::Double theValue)
 {
   SALOMEDS::Locker lock; 
   CheckLocked();
-  Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetReal(theID, theValue);
+  dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetReal(theID, theValue);
 }
 
 //=======================================================================
@@ -75,9 +79,11 @@ void SALOMEDS_AttributeParameter_i::SetReal(const char* theID, const CORBA::Doub
  */
 //=======================================================================
 CORBA::Double SALOMEDS_AttributeParameter_i::GetReal(const char* theID)
+  throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
 {
   SALOMEDS::Locker lock; 
-  return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetReal(theID);
+  Unexpect aCatch (AP_InvalidIdentifier);
+  return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetReal(theID);
 }
 
 //=======================================================================
@@ -90,7 +96,7 @@ void SALOMEDS_AttributeParameter_i::SetString(const char* theID, const char* the
 {
   SALOMEDS::Locker lock; 
   CheckLocked();
-  Handle(SALOMEDSImpl_AttributeParameter) impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl);
+  SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
   impl->SetString(theID, theValue);
 }
 
@@ -101,9 +107,11 @@ void SALOMEDS_AttributeParameter_i::SetString(const char* theID, const char* the
  */
 //=======================================================================
 char* SALOMEDS_AttributeParameter_i::GetString(const char* theID)
+  throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
 {
   SALOMEDS::Locker lock; 
-  Handle(SALOMEDSImpl_AttributeParameter) impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl);
+  Unexpect aCatch (AP_InvalidIdentifier);
+  SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
   CORBA::String_var c_s = CORBA::string_dup(impl->GetString(theID).c_str());
   return c_s._retn();
 }
@@ -118,7 +126,7 @@ void SALOMEDS_AttributeParameter_i::SetBool(const char* theID, CORBA::Boolean th
 {
   SALOMEDS::Locker lock; 
   CheckLocked();
-  Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetBool(theID, theValue);
+  dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetBool(theID, theValue);
 }
 
 //=======================================================================
@@ -128,9 +136,11 @@ void SALOMEDS_AttributeParameter_i::SetBool(const char* theID, CORBA::Boolean th
  */
 //=======================================================================
 CORBA::Boolean SALOMEDS_AttributeParameter_i::GetBool(const char* theID)
+  throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
 {
   SALOMEDS::Locker lock; 
-  return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetBool(theID);
+  Unexpect aCatch (AP_InvalidIdentifier);
+  return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetBool(theID);
 }
   
 //=======================================================================
@@ -143,13 +153,13 @@ void SALOMEDS_AttributeParameter_i::SetRealArray(const char* theID, const SALOME
 {
   SALOMEDS::Locker lock; 
   CheckLocked();
-  vector<double> v;
+  std::vector<double> v;
   int length = theArray.length();
   if(length) {
     v.resize(length);
     for(int i = 0; i<length; i++) v[i] = theArray[i];
   }
-  Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetRealArray(theID, v);
+  dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetRealArray(theID, v);
 }
 
 //=======================================================================
@@ -159,10 +169,12 @@ void SALOMEDS_AttributeParameter_i::SetRealArray(const char* theID, const SALOME
  */
 //=======================================================================
 SALOMEDS::DoubleSeq* SALOMEDS_AttributeParameter_i::GetRealArray(const char* theID)
+  throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
 {
   SALOMEDS::Locker lock; 
+  Unexpect aCatch (AP_InvalidIdentifier);
   SALOMEDS::DoubleSeq_var aSeq = new SALOMEDS::DoubleSeq;
-  vector<double> v = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetRealArray(theID);
+  std::vector<double> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetRealArray(theID);
   int length = v.size();
   if(length) {
     aSeq->length(length);
@@ -181,13 +193,13 @@ void SALOMEDS_AttributeParameter_i::SetIntArray(const char* theID, const SALOMED
 {
   SALOMEDS::Locker lock; 
   CheckLocked();
-  vector<int> v;
+  std::vector<int> v;
   int length = theArray.length();
   if(length) {
     v.resize(length);
     for(int i = 0; i<length; i++) v[i] = theArray[i];
   }
-  Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetIntArray(theID, v);
+  dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetIntArray(theID, v);
 }
 
 //=======================================================================
@@ -197,10 +209,12 @@ void SALOMEDS_AttributeParameter_i::SetIntArray(const char* theID, const SALOMED
  */
 //=======================================================================
 SALOMEDS::LongSeq* SALOMEDS_AttributeParameter_i::GetIntArray(const char* theID)
+  throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
 {
   SALOMEDS::Locker lock; 
+  Unexpect aCatch (AP_InvalidIdentifier);
   SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq;
-  vector<int> v = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetIntArray(theID);
+  std::vector<int> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetIntArray(theID);
   int length = v.size();
   if(length) {
     aSeq->length(length);
@@ -219,13 +233,13 @@ void SALOMEDS_AttributeParameter_i::SetStrArray(const char* theID, const SALOMED
 {
   SALOMEDS::Locker lock; 
   CheckLocked();
-  vector<string> v;
+  std::vector<std::string> v;
   int length = theArray.length();
   if(length) {
     v.resize(length);
-    for(int i = 0; i<length; i++) v[i] = string(theArray[i].in());
+    for(int i = 0; i<length; i++) v[i] = std::string(theArray[i].in());
   }
-  Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->SetStrArray(theID, v);
+  dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->SetStrArray(theID, v);
 }
 
 //=======================================================================
@@ -235,10 +249,12 @@ void SALOMEDS_AttributeParameter_i::SetStrArray(const char* theID, const SALOMED
  */
 //=======================================================================
 SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetStrArray(const char* theID)
+  throw (SALOMEDS::AttributeParameter::InvalidIdentifier)
 {
   SALOMEDS::Locker lock; 
+  Unexpect aCatch (AP_InvalidIdentifier);
   SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq;
-  vector<string> v = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetStrArray(theID);
+  std::vector<std::string> v = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetStrArray(theID);
   int length = v.size();
   if(length) {
     aSeq->length(length);
@@ -258,7 +274,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetStrArray(const char* theI
 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsSet(const char* theID, CORBA::Long theType)
 {
   SALOMEDS::Locker lock; 
-  return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->IsSet(theID, (Parameter_Types)theType);
+  return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->IsSet(theID, (Parameter_Types)theType);
 }
 
 //=======================================================================
@@ -271,7 +287,7 @@ CORBA::Boolean SALOMEDS_AttributeParameter_i::RemoveID(const char* theID, CORBA:
 {
   SALOMEDS::Locker lock; 
   CheckLocked();
-  return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->RemoveID(theID, (Parameter_Types)theType);
+  return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->RemoveID(theID, (Parameter_Types)theType);
 }
 
 //=======================================================================
@@ -283,7 +299,7 @@ CORBA::Boolean SALOMEDS_AttributeParameter_i::RemoveID(const char* theID, CORBA:
 SALOMEDS::AttributeParameter_ptr SALOMEDS_AttributeParameter_i::GetFather()
 {
   SALOMEDS::Locker lock; 
-  Handle(SALOMEDSImpl_AttributeParameter) impl = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl);
+  SALOMEDSImpl_AttributeParameter* impl = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl);
   SALOMEDS_AttributeParameter_i* attr = new SALOMEDS_AttributeParameter_i(impl, _orb);
   return attr->AttributeParameter::_this();
 }
@@ -297,19 +313,19 @@ SALOMEDS::AttributeParameter_ptr SALOMEDS_AttributeParameter_i::GetFather()
 CORBA::Boolean SALOMEDS_AttributeParameter_i::HasFather()
 {
   SALOMEDS::Locker lock; 
-  return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->HasFather();
+  return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->HasFather();
 }
 
 //=======================================================================
 /*!
  * Function : IsRoot
- * Purpose  : Returns True is the attribute is highest in an hierachy
+ * Purpose  : Returns True is the attribute is highest in an hierarchy
  */
 //=======================================================================
 CORBA::Boolean SALOMEDS_AttributeParameter_i::IsRoot()
 {
   SALOMEDS::Locker lock; 
-  return Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->IsRoot();
+  return dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->IsRoot();
 }
 
 //=======================================================================
@@ -321,7 +337,7 @@ CORBA::Boolean SALOMEDS_AttributeParameter_i::IsRoot()
 void SALOMEDS_AttributeParameter_i::Clear()
 {
   SALOMEDS::Locker lock; 
-  Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->Clear();
+  dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->Clear();
 }
 
 
@@ -335,7 +351,7 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeParameter_i::GetIDs(CORBA::Long theType)
 {
   SALOMEDS::Locker lock; 
   SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
-  vector<string> A = Handle(SALOMEDSImpl_AttributeParameter)::DownCast(_impl)->GetIDs((Parameter_Types)theType);
+  std::vector<std::string> A = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(_impl)->GetIDs((Parameter_Types)theType);
 
   if(A.size()) {
     int length = A.size();