X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSALOMEDS%2FSALOMEDS_AttributeTableOfReal_i.cxx;h=b6b5f34282af438977deea6f1770433a40d22a31;hb=49d7ff1f37af9eeac672bf53e137f360a75dedec;hp=c550cf38b9838af8e4bb34a724682172045ad041;hpb=bd0aa83cc3573de6b62b2a56e168dd372097bd45;p=modules%2Fyacs.git diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx index c550cf38b..b6b5f3428 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx @@ -1,333 +1,393 @@ -// SALOME SALOMEDS : data structure of SALOME and sources of Salome data server +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 CEA/DEN, EDF R&D +// 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 +// 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_i.cxx -// Author : Michael Ponikarov +// Author : Sergey RUIN // Module : SALOME -// $Header$ - +// #include "SALOMEDS_AttributeTableOfReal_i.hxx" +#include "SALOMEDS.hxx" -#include -#include -#include -#include - -#include +#include #include +#include #include "Utils_ExceptHandlers.hxx" -UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTableOfReal::IncorrectIndex); -UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength); - -#define SEPARATOR '\1' - -using namespace std; +UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTable::IncorrectIndex); +UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectArgumentLength); -static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString) +void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle) { - TCollection_ExtendedString aString(theString); - int aPos = aString.Search(SEPARATOR); - if(aPos <= 0 || aPos == aString.Length() ) return TCollection_ExtendedString(); - return aString.Split(aPos); -} - -static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString) -{ - TCollection_ExtendedString aString(theString); - int aPos = aString.Search(SEPARATOR); - if(aPos < 1) return aString; - if(aPos == 1) return TCollection_ExtendedString(); - aString.Split(aPos-1); - return aString; -} - -void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle) { + SALOMEDS::Locker lock; CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); CORBA::String_var aStr = CORBA::string_dup(theTitle); - aTable->SetTitle(TCollection_ExtendedString(aStr)); + aTable->SetTitle(std::string(aStr)); } -char* SALOMEDS_AttributeTableOfReal_i::GetTitle() { - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString()); +char* SALOMEDS_AttributeTableOfReal_i::GetTitle() +{ + SALOMEDS::Locker lock; + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + CORBA::String_var c_s = CORBA::string_dup(aTable->GetTitle().c_str()); return c_s._retn(); } void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) - throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) + throw (SALOMEDS::AttributeTable::IncorrectIndex) { + SALOMEDS::Locker lock; Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); - CORBA::String_var aStr = CORBA::string_dup(theTitle); - TCollection_ExtendedString aTitle(aStr); - TCollection_ExtendedString aUnit = getUnit(aTable->GetRowTitle(theIndex)); - if(aUnit.Length() > 0) { - aTitle += SEPARATOR; - aTitle += aUnit; - } + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + aTable->SetRowTitle(theIndex, std::string(theTitle)); +} - aTable->SetRowTitle(theIndex, aTitle); +char* SALOMEDS_AttributeTableOfReal_i::GetRowTitle(CORBA::Long theIndex) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch (ATR_IncorrectIndex); + CheckLocked(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowTitle(theIndex).c_str()); + return c_s._retn(); } void SALOMEDS_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) - throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) + throw (SALOMEDS::AttributeTable::IncorrectArgumentLength) { + SALOMEDS::Locker lock; Unexpect aCatch (ATR_IncorrectArgumentLength); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength(); for (int i = 0; i < theTitles.length(); i++) { - SetRowTitle(i + 1, theTitles[i]); + aTable->SetRowTitle(i + 1, (char*)theTitles[i].in()); } } -SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles() { - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles() +{ + SALOMEDS::Locker lock; + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; aTitles->length(aTable->GetNbRows()); for(int i = 0; i < aTitles->length(); i++) - aTitles[i] = CORBA::string_dup(TCollection_AsciiString(getTitle(aTable->GetRowTitle(i + 1))).ToCString()); + aTitles[i] = CORBA::string_dup(aTable->GetRowTitle(i + 1).c_str()); return aTitles._retn(); } void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) - throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) + throw (SALOMEDS::AttributeTable::IncorrectIndex) { + SALOMEDS::Locker lock; Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); CORBA::String_var aStr = CORBA::string_dup(theTitle); - aTable->SetColumnTitle(theIndex, TCollection_ExtendedString(aStr)); + aTable->SetColumnTitle(theIndex, std::string(aStr)); +} + +char* SALOMEDS_AttributeTableOfReal_i::GetColumnTitle(CORBA::Long theIndex) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch (ATR_IncorrectIndex); + CheckLocked(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + CORBA::String_var c_s = CORBA::string_dup(aTable->GetColumnTitle(theIndex).c_str()); + return c_s._retn(); } void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) - throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) + throw (SALOMEDS::AttributeTable::IncorrectArgumentLength) { + SALOMEDS::Locker lock; Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength(); for (int i = 0; i < theTitles.length(); i++) { - SetColumnTitle(i + 1, theTitles[i]); + aTable->SetColumnTitle(i + 1, (char*)theTitles[i].in()); } } -SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles() { - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles() +{ + SALOMEDS::Locker lock; + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; aTitles->length(aTable->GetNbColumns()); for(int i = 0; i < aTitles->length(); i++) - aTitles[i] = CORBA::string_dup(TCollection_AsciiString(aTable->GetColumnTitle(i + 1)).ToCString()); + aTitles[i] = CORBA::string_dup(aTable->GetColumnTitle(i + 1).c_str()); return aTitles._retn(); } //Units support void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) - throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) + throw (SALOMEDS::AttributeTable::IncorrectIndex) { + SALOMEDS::Locker lock; Unexpect aCatch (ATR_IncorrectIndex); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); - CORBA::String_var aStr = CORBA::string_dup(theUnit); - TCollection_ExtendedString aTitle = getTitle(aTable->GetRowTitle(theIndex)); - TCollection_ExtendedString aUnit(aStr); - aTitle += SEPARATOR; - aTitle += aUnit; - aTable->SetRowTitle(theIndex, aTitle); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + aTable->SetRowUnit(theIndex, std::string(theUnit)); +} + +char* SALOMEDS_AttributeTableOfReal_i::GetRowUnit(CORBA::Long theIndex) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch (ATR_IncorrectIndex); + CheckLocked(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowUnit(theIndex).c_str()); + return c_s._retn(); } void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) - throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) + throw (SALOMEDS::AttributeTable::IncorrectArgumentLength) { + SALOMEDS::Locker lock; Unexpect aCatch (ATR_IncorrectArgumentLength); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength(); for (int i = 0; i < theUnits.length(); i++) { - SetRowUnit(i + 1, theUnits[i]); + aTable->SetRowUnit(i + 1, (char*)theUnits[i].in()); } } -SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowUnits() { - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowUnits() +{ + SALOMEDS::Locker lock; + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq; aUnits->length(aTable->GetNbRows()); for(int i = 0; i < aUnits->length(); i++) - aUnits[i] = CORBA::string_dup(TCollection_AsciiString(getUnit(aTable->GetRowTitle(i + 1))).ToCString()); + aUnits[i] = CORBA::string_dup(aTable->GetRowUnit(i + 1).c_str()); return aUnits._retn(); } -CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbRows() { - return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->GetNbRows(); +CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbRows() +{ + SALOMEDS::Locker lock; + return dynamic_cast(_impl)->GetNbRows(); } -CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbColumns() { - return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->GetNbColumns(); + +CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbColumns() +{ + SALOMEDS::Locker lock; + return dynamic_cast(_impl)->GetNbColumns(); } void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData) - throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) + throw (SALOMEDS::AttributeTable::IncorrectArgumentLength) { + SALOMEDS::Locker lock; Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); - Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal; - for (int i = 0; i < theData.length(); i++) aRow->Append(theData[i]); + std::vector aRow; + for (int i = 0; i < theData.length(); i++) aRow.push_back(theData[i]); aTable->SetRowData(aTable->GetNbRows() + 1, aRow); } void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData) - throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex) + throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex) { + SALOMEDS::Locker lock; Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); - Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal; - for (int i = 0; i < theData.length(); i++) aRow->Append(theData[i]); + std::vector aRow; + for (int i = 0; i < theData.length(); i++) aRow.push_back(theData[i]); aTable->SetRowData(theRow, aRow); } SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow) - throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) + throw (SALOMEDS::AttributeTable::IncorrectIndex) { + SALOMEDS::Locker lock; Unexpect aCatch(ATR_IncorrectIndex); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq; - Handle(TColStd_HSequenceOfReal) aRow = aTable->GetRowData(theRow); - CorbaSeq->length(aRow->Length()); - for (int i = 0; i < aRow->Length(); i++) { - CorbaSeq[i] = aRow->Value(i + 1); + std::vector aRow = aTable->GetRowData(theRow); + CorbaSeq->length(aRow.size()); + for (int i = 0; i < aRow.size(); i++) { + CorbaSeq[i] = aRow[i]; } return CorbaSeq._retn(); } void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theData) - throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) + throw (SALOMEDS::AttributeTable::IncorrectArgumentLength) { + SALOMEDS::Locker lock; Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); - Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal; - for (int i = 0; i < theData.length(); i++) aColumn->Append(theData[i]); + std::vector aColumn; + for (int i = 0; i < theData.length(); i++) aColumn.push_back(theData[i]); aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn); } void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData) - throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex) + throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex) { + SALOMEDS::Locker lock; Unexpect aCatch(ATR_IncorrectArgumentLength); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); - Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal; - for (int i = 0; i < theData.length(); i++) aColumn->Append(theData[i]); + std::vector aColumn; + for (int i = 0; i < theData.length(); i++) aColumn.push_back(theData[i]); aTable->SetColumnData(theColumn, aColumn); } SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theColumn) - throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) + throw (SALOMEDS::AttributeTable::IncorrectIndex) { + SALOMEDS::Locker lock; Unexpect aCatch(ATR_IncorrectIndex); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq; - Handle(TColStd_HSequenceOfReal) aColumn = aTable->GetColumnData(theColumn); - CorbaSeq->length(aColumn->Length()); - for (int i = 0; i < aColumn->Length(); i++) { - CorbaSeq[i] = aColumn->Value(i + 1); + std::vector aColumn = aTable->GetColumnData(theColumn); + CorbaSeq->length(aColumn.size()); + for (int i = 0; i < aColumn.size(); i++) { + CorbaSeq[i] = aColumn[i]; } return CorbaSeq._retn(); } void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn) - throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) + throw (SALOMEDS::AttributeTable::IncorrectIndex) { + SALOMEDS::Locker lock; Unexpect aCatch(ATR_IncorrectIndex); CheckLocked(); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); aTable->PutValue(theValue, theRow, theColumn); } -CORBA::Boolean SALOMEDS_AttributeTableOfReal_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) { - return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn); +CORBA::Boolean SALOMEDS_AttributeTableOfReal_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) +{ + SALOMEDS::Locker lock; + return dynamic_cast(_impl)->HasValue(theRow, theColumn); } CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) - throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) + throw (SALOMEDS::AttributeTable::IncorrectIndex) { + SALOMEDS::Locker lock; Unexpect aCatch(ATR_IncorrectIndex); - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); CORBA::Double aValue; try { aValue = aTable->GetValue(theRow, theColumn); } - catch(Standard_Failure) { - throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + catch(...) { + throw SALOMEDS::AttributeTable::IncorrectIndex(); } return aValue; } +void SALOMEDS_AttributeTableOfReal_i::RemoveValue(CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + + try { + aTable->RemoveValue(theRow, theColumn); + } + catch(...) { + throw SALOMEDS::AttributeTable::IncorrectIndex(); + } +} SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::GetRowSetIndices(CORBA::Long theRow) { - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDS::Locker lock; + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); - if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; - Handle(TColStd_HSequenceOfInteger) aSeq = aTable->GetSetRowIndices(theRow); - CorbaSeq->length(aSeq->Length()); - for (int i = 0; i < aSeq->Length(); i++) { - CorbaSeq[i] = aSeq->Value(i + 1); + std::vector aSeq = aTable->GetSetRowIndices(theRow); + int len = aSeq.size(); + CorbaSeq->length(len); + for (int i = 0; i < len; i++) { + CorbaSeq[i] = aSeq[i]; } return CorbaSeq._retn(); } - void SALOMEDS_AttributeTableOfReal_i::SetNbColumns(CORBA::Long theNbColumns) { - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDS::Locker lock; + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); aTable->SetNbColumns(theNbColumns); } bool SALOMEDS_AttributeTableOfReal_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) { - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDS::Locker lock; + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); - istrstream aStream((char*)&theStream[0], theStream.length()); - return aTable->RestoreFromString(aStream); + std::string aStream((char*)&theStream[0], theStream.length()); + aTable->Load(aStream); + return true; } SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfReal_i::SaveToFile() { - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); - - ostrstream ostr; - string aString; - aTable->ConvertToString(ostr); - - aString = ostr.rdbuf()->str(); + SALOMEDS::Locker lock; + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + std::string aString = aTable->Save(); char* aBuffer = (char*)CORBA::string_dup(aString.c_str()); int aBufferSize = strlen((char*)aBuffer); @@ -338,20 +398,167 @@ SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfReal_i::SaveToFile() return aStreamFile._retn(); } -char* SALOMEDS_AttributeTableOfReal_i::Store() { - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortRow(CORBA::Long theRow, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); + CheckLocked(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; + try { + aSeq = aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + } + catch(...) { + throw SALOMEDS::AttributeTable::IncorrectIndex(); + } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); +} + +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortColumn(CORBA::Long theColumn, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); + CheckLocked(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); - ostrstream ostr; - aTable->ConvertToString(ostr); - string aString = ostr.rdbuf()->str(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; + try { + aSeq = aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + } + catch(...) { + throw SALOMEDS::AttributeTable::IncorrectIndex(); + } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); +} + +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortByRow(CORBA::Long theRow, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); + CheckLocked(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); - CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str()); - return aBuffer._retn(); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; + try { + aSeq = aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + } + catch(...) { + throw SALOMEDS::AttributeTable::IncorrectIndex(); + } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); } -void SALOMEDS_AttributeTableOfReal_i::Restore(const char* value) { - Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortByColumn(CORBA::Long theColumn, + SALOMEDS::AttributeTable::SortOrder sortOrder, + SALOMEDS::AttributeTable::SortPolicy sortPolicy) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); + CheckLocked(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); - istrstream aStream(value, strlen(value)); - aTable->RestoreFromString(aStream); + std::vector aSeq; + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; + try { + aSeq = aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder, + (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy); + } + catch(...) { + throw SALOMEDS::AttributeTable::IncorrectIndex(); + } + CorbaSeq->length(aSeq.size()); + for (int i = 0; i < aSeq.size(); i++) { + CorbaSeq[i] = aSeq[i]; + } + return CorbaSeq._retn(); +} + +void SALOMEDS_AttributeTableOfReal_i::SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1, + CORBA::Long theRow2, CORBA::Long theColumn2) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); + CheckLocked(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theRow1 < 1 || theRow1 > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + if (theColumn1 < 1 || theColumn1 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + if (theRow2 < 1 || theRow2 > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + if (theColumn2 < 1 || theColumn2 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + + try { + aTable->SwapCells(theRow1, theColumn1, theRow2, theColumn2); + } + catch(...) { + throw SALOMEDS::AttributeTable::IncorrectIndex(); + } +} + +void SALOMEDS_AttributeTableOfReal_i::SwapRows(CORBA::Long theRow1, CORBA::Long theRow2) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); + CheckLocked(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theRow1 < 1 || theRow1 > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + if (theRow2 < 1 || theRow2 > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + + try { + aTable->SwapRows(theRow1, theRow2); + } + catch(...) { + throw SALOMEDS::AttributeTable::IncorrectIndex(); + } +} + +void SALOMEDS_AttributeTableOfReal_i::SwapColumns(CORBA::Long theColumn1, CORBA::Long theColumn2) + throw (SALOMEDS::AttributeTable::IncorrectIndex) +{ + SALOMEDS::Locker lock; + Unexpect aCatch(ATR_IncorrectIndex); + CheckLocked(); + SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast(_impl); + if (theColumn1 < 1 || theColumn1 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + if (theColumn2 < 1 || theColumn2 > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex(); + + try { + aTable->SwapColumns(theColumn1, theColumn2); + } + catch(...) { + throw SALOMEDS::AttributeTable::IncorrectIndex(); + } }