Salome HOME
0020523: String notebook support
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTableOfReal.cxx
index bb7cf1f26a0772eef615f41afa0deb4dd086759d..8efbaaec563a19e2805efd3b41357d6f96ecc6aa 100644 (file)
@@ -1,38 +1,35 @@
-// Copyright (C) 2005  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 
-// Lesser General Public License for more details.
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// 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
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// See http://www.salome-platform.org/
+//  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
+//  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
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //  File   : SALOMEDS_AttributeTableOfReal.cxx
 //  Author : Sergey RUIN
 //  Module : SALOME
-
+//
 #include "SALOMEDS_AttributeTableOfReal.hxx"
 #include "SALOMEDS.hxx"
 
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TColStd_HSequenceOfInteger.hxx>
-#include <TColStd_HSequenceOfReal.hxx>
-#include <TColStd_HSequenceOfExtendedString.hxx>
-
+using namespace std;
 
 SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal
-                  (const Handle(SALOMEDSImpl_AttributeTableOfReal)& theAttr)
+                  (SALOMEDSImpl_AttributeTableOfReal* theAttr)
 :SALOMEDS_GenericAttribute(theAttr)
 {}
 
@@ -49,7 +46,7 @@ void SALOMEDS_AttributeTableOfReal::SetTitle(const std::string& theTitle)
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;     
-    Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str());
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetTitle(theTitle);
   }
   else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
 }
@@ -59,8 +56,7 @@ std::string SALOMEDS_AttributeTableOfReal::GetTitle()
   std::string aStr;
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfReal)::
-                                   DownCast(_local_impl)->GetTitle()).ToCString();
+    aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetTitle();
   }
   else aStr = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetTitle();
   return aStr;
@@ -71,8 +67,7 @@ void SALOMEDS_AttributeTableOfReal::SetRowTitle(int theIndex, const std::string&
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;     
-    Handle(SALOMEDSImpl_AttributeTableOfReal)::
-      DownCast(_local_impl)->SetRowTitle(theIndex, (char*)theTitle.c_str());
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowTitle(theIndex, theTitle);
   }
   else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
 }
@@ -84,9 +79,7 @@ void SALOMEDS_AttributeTableOfReal::SetRowTitles(const std::vector<std::string>&
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;     
-    Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
-    for (i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
-    Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowTitles(aSeq);
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowTitles(theTitles);
   }
   else {
     SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
@@ -102,10 +95,7 @@ std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowTitles()
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    Handle(TColStd_HSequenceOfExtendedString) aSeq;
-    aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowTitles();
-    aLength = aSeq->Length();
-    for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+    aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowTitles();
   }
   else {
     SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowTitles();
@@ -120,8 +110,7 @@ void SALOMEDS_AttributeTableOfReal::SetColumnTitle(int theIndex, const std::stri
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock; 
-    Handle(SALOMEDSImpl_AttributeTableOfReal)::
-      DownCast(_local_impl)->SetColumnTitle(theIndex, (char*)theTitle.c_str());
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
   }
   else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
 }
@@ -132,9 +121,7 @@ void SALOMEDS_AttributeTableOfReal::SetColumnTitles(const std::vector<std::strin
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock; 
-    Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
-    for (i = 0; i < aLength; i++) aSeq->Append((char*)theTitles[i].c_str());
-    Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetColumnTitles(aSeq);
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetColumnTitles(theTitles);
   }
   else {
     SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
@@ -150,10 +137,7 @@ std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetColumnTitles()
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    Handle(TColStd_HSequenceOfExtendedString) aSeq;
-    aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetColumnTitles();
-    aLength = aSeq->Length();
-    for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+    aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnTitles();
   }
   else {
     SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumnTitles();
@@ -168,8 +152,7 @@ void SALOMEDS_AttributeTableOfReal::SetRowUnit(int theIndex, const std::string&
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock; 
-    Handle(SALOMEDSImpl_AttributeTableOfReal)::
-      DownCast(_local_impl)->SetRowUnit(theIndex, (char*)theUnit.c_str());
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowUnit(theIndex, theUnit);
   }
   else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
 }
@@ -180,9 +163,7 @@ void SALOMEDS_AttributeTableOfReal::SetRowUnits(const std::vector<std::string>&
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock; 
-    Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString;
-    for (i = 0; i < aLength; i++) aSeq->Append((char*)theUnits[i].c_str());
-    Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetRowUnits(aSeq);
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetRowUnits(theUnits);
   }
   else {
     SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
@@ -198,15 +179,12 @@ std::vector<std::string> SALOMEDS_AttributeTableOfReal::GetRowUnits()
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    Handle(TColStd_HSequenceOfExtendedString) aSeq;
-    aSeq = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowUnits();
-    aLength = aSeq->Length();
-    for (i = 1; i <= aLength; i++) aVector.push_back(TCollection_AsciiString(aSeq->Value(i)).ToCString());
+    aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowUnits();
   }
   else {
     SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnits();
     aLength = aSeq->length();
-    for (i = 0; i < aLength; i++) aVector.push_back(TCollection_AsciiString((char*)aSeq[i].in()).ToCString());
+    for (i = 0; i < aLength; i++) aVector.push_back(string(aSeq[i].in()));
   }
   return aVector;
 }
@@ -216,7 +194,7 @@ int SALOMEDS_AttributeTableOfReal::GetNbRows()
   int aNb;
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    aNb = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetNbRows();
+    aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetNbRows();
   }
   else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbRows();
   return aNb;
@@ -227,7 +205,7 @@ int SALOMEDS_AttributeTableOfReal::GetNbColumns()
   int aNb;
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    aNb = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetNbColumns();
+    aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetNbColumns();
   }
   else aNb = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetNbColumns();
   return aNb;
@@ -239,12 +217,9 @@ void SALOMEDS_AttributeTableOfReal::AddRow(const std::vector<double>& theData)
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock; 
-    Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
-    aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
-    Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal;
-    for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
+    SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
     try {
-      aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
+      aTable->SetRowData(aTable->GetNbRows() + 1, theData);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
@@ -264,12 +239,9 @@ void SALOMEDS_AttributeTableOfReal::SetRow(int theRow, const std::vector<double>
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock; 
-    Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
-    aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
-    Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal;
-    for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
+    SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
     try {
-      aTable->SetRowData(theRow, aRow);
+      aTable->SetRowData(theRow, theData);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
@@ -289,13 +261,11 @@ std::vector<double> SALOMEDS_AttributeTableOfReal::GetRow(int theRow)
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    Handle(TColStd_HSequenceOfReal) aRow; 
-    aRow = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetRowData(theRow);
-    aLength = aRow->Length();
-    for (i = 1; i <= aLength; i++) aVector.push_back(aRow->Value(i));
+    aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowData(theRow);
   }
   else {
     SALOMEDS::DoubleSeq_var aRow = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRow(theRow);
+    aLength = aRow->length();
     for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
   }
 
@@ -308,12 +278,9 @@ void SALOMEDS_AttributeTableOfReal::AddColumn(const std::vector<double>& theData
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock; 
-    Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
-    aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
-    Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal;
-    for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
+    SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
     try {
-      aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
+      aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
@@ -333,12 +300,9 @@ void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vector<d
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock; 
-    Handle(SALOMEDSImpl_AttributeTableOfReal) aTable;
-    aTable = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl);
-    Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal;
-    for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
+    SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl);
     try {
-      aTable->SetRowData(theColumn, aColumn);
+      aTable->SetColumnData(theColumn, theData);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
@@ -348,7 +312,7 @@ void SALOMEDS_AttributeTableOfReal::SetColumn(int theColumn, const std::vector<d
     SALOMEDS::DoubleSeq_var aColumn = new SALOMEDS::DoubleSeq();
     aColumn->length(aLength);
     for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
-    SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
+    SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
   }
 }
 
@@ -358,13 +322,11 @@ std::vector<double> SALOMEDS_AttributeTableOfReal::GetColumn(int theColumn)
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    Handle(TColStd_HSequenceOfReal) aColumn; 
-    aColumn = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetColumnData(theColumn);
-    aLength = aColumn->Length();
-    for (i = 1; i <= aLength; i++) aVector.push_back(aColumn->Value(i));
+    aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnData(theColumn);
   }
   else {
     SALOMEDS::DoubleSeq_var aColumn = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumn(theColumn);
+    aLength = aColumn->length();
     for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
   }
   return aVector;
@@ -376,8 +338,7 @@ void SALOMEDS_AttributeTableOfReal::PutValue(double theValue, int theRow, int th
     CheckLocked();
     SALOMEDS::Locker lock; 
     try {
-      Handle(SALOMEDSImpl_AttributeTableOfReal)::
-        DownCast(_local_impl)->PutValue(theValue, theRow, theColumn);
+      dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->PutValue(theValue, theRow, theColumn);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
@@ -393,7 +354,7 @@ bool SALOMEDS_AttributeTableOfReal::HasValue(int theRow, int theColumn)
   bool ret;
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    ret = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->HasValue(theRow, theColumn);
+    ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->HasValue(theRow, theColumn);
   }
   else ret = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->HasValue(theRow, theColumn);
   return ret;
@@ -405,7 +366,7 @@ double SALOMEDS_AttributeTableOfReal::GetValue(int theRow, int theColumn)
   if (_isLocal) {
     SALOMEDS::Locker lock; 
     try {
-      aValue = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetValue(theRow, theColumn);
+      aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetValue(theRow, theColumn);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
@@ -423,13 +384,11 @@ std::vector<int> SALOMEDS_AttributeTableOfReal::GetRowSetIndices(int theRow)
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    Handle(TColStd_HSequenceOfInteger) aSet; 
-    aSet = Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->GetSetRowIndices(theRow);
-    aLength = aSet->Length();
-    for (i = 1; i <= aLength; i++) aVector.push_back(aSet->Value(i));
+    aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetSetRowIndices(theRow);
   }
   else {
     SALOMEDS::LongSeq_var aSet = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowSetIndices(theRow);
+    aLength = aSet->length();
     for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
   }
   return aVector;
@@ -439,7 +398,7 @@ void SALOMEDS_AttributeTableOfReal::SetNbColumns(int theNbColumns)
 {
   if (_isLocal) {
     SALOMEDS::Locker lock; 
-    Handle(SALOMEDSImpl_AttributeTableOfReal)::DownCast(_local_impl)->SetNbColumns(theNbColumns);
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SetNbColumns(theNbColumns);
   }
   else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
 }