Salome HOME
Merge from branch CCRT_Port_V220.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTableOfInteger_i.cxx
index ffa2450528966a25bd081e6c0dbe0f8c9b64741e..ba6c5914e4281779fbb92efd696b18b39c918225 100644 (file)
@@ -1,24 +1,33 @@
-using namespace std;
-//  File      : SALOMEDS_AttributeTableOfInteger_i.cxx
-//  Created   : Tue Oct  8 10:13:30 2002
-//  Author    : Michael Ponikarov
-//  Project   : SALOME
-//  Module    : SALOMEDS
-//  Copyright : Open CASCADE
+//  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
+//
+//  Copyright (C) 2003  CEA/DEN, EDF R&D
+//
+//
+//
+//  File   : SALOMEDS_AttributeTableOfInteger_i.cxx
+//  Author : Michael Ponikarov
+//  Module : SALOME
 //  $Header$
 
-
-#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 #include <TColStd_HSequenceOfInteger.hxx>
+#include <TCollection_AsciiString.hxx>
 #include <Standard_Failure.hxx>
-#include <Standard_ErrorHandler.hxx>
 
+#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
+#include "SALOMEDS.hxx"
+#include "Utils_ExceptHandlers.hxx"
+
+#include <stdexcept>
 #include <strstream>
 #include <string>
 
+using namespace std;
+
 #define SEPARATOR '\1'
 
+UNEXPECT_CATCH(ATI_IncorrectIndex, SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+UNEXPECT_CATCH(ATI_IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength);
+
 static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString)
 {
   TCollection_ExtendedString aString(theString);
@@ -37,9 +46,9 @@ static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString)
   return aString;
 }
 
-
-
 void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle) {
+  SALOMEDS::Locker lock;
+
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   CORBA::String_var aStr = CORBA::string_dup(theTitle);
@@ -47,6 +56,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle) {
 }
 
 char* SALOMEDS_AttributeTableOfInteger_i::GetTitle() {
+  SALOMEDS::Locker lock;
+
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString());
   return c_s._retn();
@@ -55,6 +66,9 @@ char* SALOMEDS_AttributeTableOfInteger_i::GetTitle() {
 void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch (ATI_IncorrectIndex);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
@@ -72,6 +86,9 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const
 void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch (ATI_IncorrectArgumentLength);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
@@ -81,6 +98,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq&
 }
 
 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowTitles() {
+  SALOMEDS::Locker lock;
+
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
   aTitles->length(aTable->GetNbRows());
@@ -92,6 +111,9 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowTitles() {
 void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch (ATI_IncorrectIndex);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
@@ -102,6 +124,9 @@ void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, co
 void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch(ATI_IncorrectArgumentLength);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
@@ -111,6 +136,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringS
 }
 
 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitles() {
+  SALOMEDS::Locker lock;
+
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq;
   aTitles->length(aTable->GetNbColumns());
@@ -123,6 +150,9 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitles() {
 void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch (ATI_IncorrectIndex);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
@@ -137,6 +167,9 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const
 void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch (ATI_IncorrectArgumentLength);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
@@ -146,6 +179,8 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq&
 }
 
 SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowUnits() {
+  SALOMEDS::Locker lock;
+
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq;
   aUnits->length(aTable->GetNbRows());
@@ -155,15 +190,22 @@ SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowUnits() {
 }
 
 CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbRows() {
+  SALOMEDS::Locker lock;
+
   return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->GetNbRows();
 }
 CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbColumns() {
+  SALOMEDS::Locker lock;
+
   return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->GetNbColumns();
 }
 
 void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch(ATI_IncorrectArgumentLength);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   
@@ -180,6 +222,9 @@ void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData
 void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch(ATI_IncorrectArgumentLength);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   
@@ -196,6 +241,9 @@ void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOME
 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch(ATI_IncorrectIndex);
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
 
@@ -211,6 +259,9 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow
 void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theData)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch(ATI_IncorrectArgumentLength);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   
@@ -227,6 +278,9 @@ void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theD
 void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch(ATI_IncorrectArgumentLength);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   
@@ -243,6 +297,9 @@ void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const
 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long theColumn)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch(ATI_IncorrectIndex);
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
 
@@ -258,6 +315,9 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long the
 void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch(ATI_IncorrectIndex);
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
 
@@ -270,12 +330,17 @@ void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::L
 }
 
 CORBA::Boolean SALOMEDS_AttributeTableOfInteger_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) {
+  SALOMEDS::Locker lock;
+
   return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn);
 }
 
 CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
      throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
 {
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch(ATI_IncorrectIndex);
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
 
@@ -291,6 +356,8 @@ CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, COR
 
 SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowSetIndices(CORBA::Long theRow) 
 {
+  SALOMEDS::Locker lock;
+
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
 
   if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
@@ -307,12 +374,16 @@ SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowSetIndices(CORBA::L
 
 void SALOMEDS_AttributeTableOfInteger_i::SetNbColumns(CORBA::Long theNbColumns)
 {
+  SALOMEDS::Locker lock;
+
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
   aTable->SetNbColumns(theNbColumns);
 }
 
 bool SALOMEDS_AttributeTableOfInteger_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) 
 {
+  SALOMEDS::Locker lock;
+
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
 
   istrstream aStream((char*)&theStream[0], theStream.length());
@@ -321,6 +392,8 @@ bool SALOMEDS_AttributeTableOfInteger_i::ReadFromFile(const SALOMEDS::TMPFile& t
 
 SALOMEDS::TMPFile*  SALOMEDS_AttributeTableOfInteger_i::SaveToFile()
 {
+  SALOMEDS::Locker lock;
+
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
 
   ostrstream ostr;
@@ -339,3 +412,24 @@ SALOMEDS::TMPFile*  SALOMEDS_AttributeTableOfInteger_i::SaveToFile()
   return aStreamFile._retn();
 }
 
+char* SALOMEDS_AttributeTableOfInteger_i::Store() {
+  SALOMEDS::Locker lock;
+
+  Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+
+  ostrstream ostr;
+  aTable->ConvertToString(ostr);
+  string aString = ostr.rdbuf()->str();
+
+  CORBA::String_var aBuffer = CORBA::string_dup(aString.c_str());
+  return aBuffer._retn();
+}
+
+void SALOMEDS_AttributeTableOfInteger_i::Restore(const char* value) {
+  SALOMEDS::Locker lock;
+
+  Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
+
+  istrstream aStream(value, strlen(value));
+  aTable->RestoreFromString(aStream);
+}