Salome HOME
Issue 0020194: EDF 977 ALL: Get rid of warnings PACKAGE_VERSION already defined
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTableOfInteger.cxx
index a7bbc04514d51c5bd8b2f124be5489dacb74626b..5223779180934250651915554f9bbf633404c4c7 100644 (file)
@@ -1,37 +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/ or email : webmaster.salome@opencascade.com
+//  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_AttributeTableOfInteger.cxx
 //  Author : Sergey RUIN
 //  Module : SALOME
-
+//
 #include "SALOMEDS_AttributeTableOfInteger.hxx"
 #include "SALOMEDS.hxx"
 
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TColStd_HSequenceOfInteger.hxx>
-#include <TColStd_HSequenceOfExtendedString.hxx>
-
+using namespace std;
 
 SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger
-                  (const Handle(SALOMEDSImpl_AttributeTableOfInteger)& theAttr)
+                  (SALOMEDSImpl_AttributeTableOfInteger* theAttr)
 :SALOMEDS_GenericAttribute(theAttr)
 {}
 
@@ -49,7 +47,7 @@ void SALOMEDS_AttributeTableOfInteger::SetTitle(const std::string& theTitle)
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetTitle((char*)theTitle.c_str());
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetTitle(theTitle);
   }
   else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetTitle(theTitle.c_str());
 }
@@ -59,8 +57,7 @@ std::string SALOMEDS_AttributeTableOfInteger::GetTitle()
   std::string aStr;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    aStr = TCollection_AsciiString(Handle(SALOMEDSImpl_AttributeTableOfInteger)::
-                                   DownCast(_local_impl)->GetTitle()).ToCString();
+    aStr = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetTitle();
   }
   else aStr = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetTitle();
   return aStr;
@@ -71,8 +68,7 @@ void SALOMEDS_AttributeTableOfInteger::SetRowTitle(int theIndex, const std::stri
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTableOfInteger)::
-      DownCast(_local_impl)->SetRowTitle(theIndex, (char*)theTitle.c_str());
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowTitle(theIndex, theTitle);
   }
   else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
 }
@@ -83,9 +79,9 @@ void SALOMEDS_AttributeTableOfInteger::SetRowTitles(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_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowTitles(aSeq);
+    vector<string> aSeq;
+    for (i = 0; i < aLength; i++) aSeq.push_back(theTitles[i]);
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowTitles(aSeq);
   }
   else {
     SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
@@ -102,10 +98,7 @@ std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowTitles()
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(TColStd_HSequenceOfExtendedString) aSeq;
-    aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::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_AttributeTableOfInteger*>(_local_impl)->GetRowTitles();
   }
   else {
     SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowTitles();
@@ -120,8 +113,7 @@ void SALOMEDS_AttributeTableOfInteger::SetColumnTitle(int theIndex, const std::s
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTableOfInteger)::
-      DownCast(_local_impl)->SetColumnTitle(theIndex, (char*)theTitle.c_str());
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetColumnTitle(theIndex, theTitle);
   }
   else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
 }
@@ -132,9 +124,9 @@ void SALOMEDS_AttributeTableOfInteger::SetColumnTitles(const std::vector<std::st
   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_AttributeTableOfInteger)::DownCast(_local_impl)->SetColumnTitles(aSeq);
+    vector<string> aSeq;
+    for (i = 0; i < aLength; i++) aSeq.push_back(theTitles[i]);
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetColumnTitles(aSeq);
   }
   else {
     SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
@@ -150,10 +142,7 @@ std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetColumnTitles()
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(TColStd_HSequenceOfExtendedString) aSeq;
-    aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::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_AttributeTableOfInteger*>(_local_impl)->GetColumnTitles();
   }
   else {
     SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumnTitles();
@@ -168,8 +157,7 @@ void SALOMEDS_AttributeTableOfInteger::SetRowUnit(int theIndex, const std::strin
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTableOfInteger)::
-      DownCast(_local_impl)->SetRowUnit(theIndex, (char*)theUnit.c_str());
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowUnit(theIndex, theUnit);
   }
   else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
 }
@@ -180,9 +168,7 @@ void SALOMEDS_AttributeTableOfInteger::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_AttributeTableOfInteger)::DownCast(_local_impl)->SetRowUnits(aSeq);
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowUnits(theUnits);
   }
   else {
     SALOMEDS::StringSeq_var aSeq = new SALOMEDS::StringSeq();
@@ -198,10 +184,7 @@ std::vector<std::string> SALOMEDS_AttributeTableOfInteger::GetRowUnits()
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(TColStd_HSequenceOfExtendedString) aSeq;
-    aSeq = Handle(SALOMEDSImpl_AttributeTableOfInteger)::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_AttributeTableOfInteger*>(_local_impl)->GetRowUnits();
   }
   else {
     SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowUnits();
@@ -216,7 +199,7 @@ int SALOMEDS_AttributeTableOfInteger::GetNbRows()
   int aNb;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbRows();
+    aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetNbRows();
   }
   else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbRows();
   return aNb;
@@ -227,7 +210,7 @@ int SALOMEDS_AttributeTableOfInteger::GetNbColumns()
   int aNb;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    aNb = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetNbColumns();
+    aNb = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetNbColumns();
   }
   else aNb = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetNbColumns();
   return aNb;
@@ -240,12 +223,9 @@ void SALOMEDS_AttributeTableOfInteger::AddRow(const std::vector<int>& theData)
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
-    aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
-    Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger;
-    for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
+    SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
     try {
-      aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
+      aTable->SetRowData(aTable->GetNbRows() + 1, theData);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
@@ -265,12 +245,9 @@ void SALOMEDS_AttributeTableOfInteger::SetRow(int theRow, const std::vector<int>
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
-    aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
-    Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger;
-    for (int i = 0; i < aLength; i++) aRow->Append(theData[i]);
+    SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
     try {
-      aTable->SetRowData(theRow, aRow);
+      aTable->SetRowData(theRow, theData);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
@@ -290,13 +267,11 @@ std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRow(int theRow)
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(TColStd_HSequenceOfInteger) aRow; 
-    aRow = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetRowData(theRow);
-    aLength = aRow->Length();
-    for (i = 1; i <= aLength; i++) aVector.push_back(aRow->Value(i));
+    aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowData(theRow);
   }
   else {
     SALOMEDS::LongSeq_var aRow = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRow(theRow);
+    aLength = aRow->length();
     for (i = 0; i < aLength; i++) aVector.push_back(aRow[i]);
   }
 
@@ -309,12 +284,9 @@ void SALOMEDS_AttributeTableOfInteger::AddColumn(const std::vector<int>& theData
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
-    aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
-    Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
-    for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
+    SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
     try {
-      aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
+      aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
@@ -334,12 +306,9 @@ void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vecto
   if (_isLocal) {
     CheckLocked();
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTableOfInteger) aTable;
-    aTable = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl);
-    Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger;
-    for (int i = 0; i < aLength; i++) aColumn->Append(theData[i]);
+    SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl);
     try {
-      aTable->SetRowData(theColumn, aColumn);
+      aTable->SetColumnData(theColumn, theData);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
@@ -349,7 +318,7 @@ void SALOMEDS_AttributeTableOfInteger::SetColumn(int theColumn, const std::vecto
     SALOMEDS::LongSeq_var aColumn = new SALOMEDS::LongSeq();
     aColumn->length(aLength);
     for (i = 0; i < aLength; i++) aColumn[i] = theData[i];
-    SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRow(theColumn, aColumn);
+    SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumn(theColumn, aColumn);
   }
 }
 
@@ -359,13 +328,11 @@ std::vector<int> SALOMEDS_AttributeTableOfInteger::GetColumn(int theColumn)
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(TColStd_HSequenceOfInteger) aColumn; 
-    aColumn = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetColumnData(theColumn);
-    aLength = aColumn->Length();
-    for (i = 1; i <= aLength; i++) aVector.push_back(aColumn->Value(i));
+    aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetColumnData(theColumn);
   }
   else {
     SALOMEDS::LongSeq_var aColumn = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumn(theColumn);
+    aLength = aColumn->length();
     for (i = 0; i < aLength; i++) aVector.push_back(aColumn[i]);
   }
   return aVector;
@@ -377,8 +344,7 @@ void SALOMEDS_AttributeTableOfInteger::PutValue(int theValue, int theRow, int th
     CheckLocked();
     SALOMEDS::Locker lock;
     try {
-      Handle(SALOMEDSImpl_AttributeTableOfInteger)::
-        DownCast(_local_impl)->PutValue(theValue, theRow, theColumn);
+      dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->PutValue(theValue, theRow, theColumn);
     }
     catch(...) {
       throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
@@ -394,7 +360,7 @@ bool SALOMEDS_AttributeTableOfInteger::HasValue(int theRow, int theColumn)
   bool ret;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    ret = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->HasValue(theRow, theColumn);
+    ret = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->HasValue(theRow, theColumn);
   }
   else ret = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->HasValue(theRow, theColumn);
   return ret;
@@ -406,8 +372,7 @@ int SALOMEDS_AttributeTableOfInteger::GetValue(int theRow, int theColumn)
   if (_isLocal) {
     SALOMEDS::Locker lock;
     try {
-      aValue = Handle(SALOMEDSImpl_AttributeTableOfInteger)::
-        DownCast(_local_impl)->GetValue(theRow, theColumn);
+      aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetValue(theRow, theColumn);
     }   
     catch(...) {
       throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
@@ -425,14 +390,12 @@ std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRowSetIndices(int theRow)
   int aLength, i;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(TColStd_HSequenceOfInteger) aSet; 
-    aSet = Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->GetSetRowIndices(theRow);
-    aLength = aSet->Length();
-    for (i = 1; i <= aLength; i++) aVector.push_back(aSet->Value(i));
+    aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetSetRowIndices(theRow);
   }
   else {
     SALOMEDS::LongSeq_var aSet =
       SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowSetIndices(theRow);
+    aLength = aSet->length();  
     for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
   }
   return aVector;
@@ -442,7 +405,7 @@ void SALOMEDS_AttributeTableOfInteger::SetNbColumns(int theNbColumns)
 {
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    Handle(SALOMEDSImpl_AttributeTableOfInteger)::DownCast(_local_impl)->SetNbColumns(theNbColumns);
+    dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetNbColumns(theNbColumns);
   }
   else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
 }