//! This exception is raised when sequence of incorrect length is passed as parameter.
exception IncorrectArgumentLength {};
+ //! Sort order
+ enum SortOrder {
+ AscendingOrder, //!< The items are sorted ascending
+ DescendingOrder //!< The items are sorted descending
+ };
+
+ //! Sort policy (specifies how empty cells are taken into account when sorting)
+ enum SortPolicy {
+ EmptyLowest, //!< Empty cells are considered as lowest values
+ EmptyHighest, //!< Empty cells are considered as highest values
+ EmptyFirst, //!< Empty cells are always first
+ EmptyLast, //!< Empty cells are always last
+ EmptyIgnore //!< Empty cells are ignored (stay at initial positions)
+ };
+
/*!
\brief Sets the main title of the table.
\param title title being set to the table
(or if row/column index is/are out of range)
*/
boolean HasValue(in long row, in long column);
+ /*!
+ \brief Clear value in the specified table cell.
+
+ Raises an exception if \a row or \a column is out of range.
+
+ \param row row index
+ \param column column index
+ \sa HasValue()
+ */
+ void RemoveValue(in long row, in long column) raises(IncorrectIndex);
/*!
\brief Sets the maximum number of colums in the table.
If new number of columns is less than the current one, the table is truncated
(extra columns are removed).
-
+
\note It is recommended to set number of columns before assigning data to the table.
\param columns total number of columns being set for the table
\return list of column indices
*/
LongSeq GetRowSetIndices(in long row) raises(IncorrectIndex);
+ /*!
+ \brief Sort values in the specified table row.
+
+ Sort order is specified by the \a order parameter. The \a policy
+ specifies how to process empty cells (put to the first place, ignore, etc).
+
+ Raises an exception if \a row is out of range.
+
+ \note Other table rows are not affected.
+
+ \param row row index
+ \param order sort order (ascending/descending)
+ \param policy sort policy (specifies how to process empty cells)
+ */
+ void SortRow(in long row, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex);
+ /*!
+ \brief Sort values in the specified table column.
+
+ Sort order is specified by the \a order parameter. The \a policy
+ specifies how to process empty cells (put to the first place, ignore, etc).
+
+ Raises an exception if \a column is out of range.
+
+ \note Other table columns are not affected.
+
+ \param column column index
+ \param order sort order (ascending/descending)
+ \param policy sort policy (specifies how to process empty cells)
+ */
+ void SortColumn(in long column, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex);
+ /*!
+ \brief Sort table columns by the specified row.
+
+ All the table columns are sorted according to the values in the specified
+ row. Sort order is specified by the \a order parameter. The \a policy
+ specifies how to process empty cells (put to the first place, ignore, etc).
+
+ Raises an exception if \a row is out of range.
+
+ \param row row index
+ \param order sort order (ascending/descending)
+ \param policy sort policy (specifies how to process empty cells)
+ */
+ void SortByRow(in long row, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex);
+ /*!
+ \brief Sort table rows by the specified column.
+
+ All the table rows are sorted according to the values in the specified
+ column. Sort order is specified by the \a order parameter. The \a policy
+ specifies how to process empty cells (put to the first place, ignore, etc).
+
+ Raises an exception if \a column is out of range.
+
+ \param column column index
+ \param order sort order (ascending/descending)
+ \param policy sort policy (specifies how to process empty cells)
+ */
+ void SortByColumn(in long column, in SortOrder order, in SortPolicy policy) raises(IncorrectIndex);
+ /*!
+ \brief Swap values in two table cells.
+
+ Raises an exception if any specified index is out of range.
+
+ \param row1 first cell's row index
+ \param column1 first cell's column index
+ \param row2 second cell's row index
+ \param column2 second cell's column index
+ */
+ void SwapCells(in long row1, in long column1, in long row2, in long column2) raises(IncorrectIndex);
+ /*!
+ \brief Swap two table rows.
+
+ Raises an exception if any \a row1 or \a row2 is out of range.
+
+ \param row1 first row's index
+ \param row2 second row's index
+ */
+ void SwapRows(in long row1, in long row2) raises(IncorrectIndex);
+ /*!
+ \brief Swap two table columns.
+
+ Raises an exception if any \a column1 or \a column2 is out of range.
+
+ \param column1 first column's index
+ \param column2 second column's index
+ */
+ void SwapColumns(in long column1, in long column2) raises(IncorrectIndex);
/*!
\brief Reads a table from a byte stream.
\param fileStream byte stream
#include "SALOMEDS_AttributeTableOfInteger.hxx"
#include "SALOMEDS.hxx"
-using namespace std;
-
SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger
(SALOMEDSImpl_AttributeTableOfInteger* theAttr)
:SALOMEDS_GenericAttribute(theAttr)
if (_isLocal) {
CheckLocked();
SALOMEDS::Locker lock;
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
for (i = 0; i < aLength; i++) aSeq.push_back(theTitles[i]);
dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetRowTitles(aSeq);
}
if (_isLocal) {
CheckLocked();
SALOMEDS::Locker lock;
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
for (i = 0; i < aLength; i++) aSeq.push_back(theTitles[i]);
dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SetColumnTitles(aSeq);
}
return aValue;
}
+void SALOMEDS_AttributeTableOfInteger::RemoveValue(int theRow, int theColumn)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->RemoveValue(theRow, theColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->RemoveValue(theRow, theColumn);
+ }
+}
+
std::vector<int> SALOMEDS_AttributeTableOfInteger::GetRowSetIndices(int theRow)
{
std::vector<int> aVector;
}
else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
}
+
+void SALOMEDS_AttributeTableOfInteger::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortByRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortByRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortByColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortByColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger::SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger::SwapRows(int theRow1, int theRow2)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SwapRows(theRow1, theRow2);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SwapRows(theRow1, theRow2);
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger::SwapColumns(int theColumn1, int theColumn2)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SwapColumns(theColumn1, theColumn2);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SwapColumns(theColumn1, theColumn2);
+ }
+}
virtual void PutValue(int theValue, int theRow, int theColumn);
virtual bool HasValue(int theRow, int theColumn);
virtual int GetValue(int theRow, int theColumn);
+ virtual void RemoveValue(int theRow, int theColumn);
virtual std::vector<int> GetRowSetIndices(int theRow);
virtual void SetNbColumns(int theNbColumns);
+ virtual void SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2);
+ virtual void SwapRows(int theRow1, int theRow2);
+ virtual void SwapColumns(int theColumn1, int theColumn2);
};
#endif
#include <string>
#include <vector>
-using namespace std;
-
UNEXPECT_CATCH(ATI_IncorrectIndex, SALOMEDS::AttributeTable::IncorrectIndex);
UNEXPECT_CATCH(ATI_IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectArgumentLength);
SALOMEDS::Locker lock;
CheckLocked();
CORBA::String_var aStr = CORBA::string_dup(theTitle);
- dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl)->SetTitle(string(aStr));
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl)->SetTitle(std::string(aStr));
}
char* SALOMEDS_AttributeTableOfInteger_i::GetTitle()
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
- aTable->SetRowTitle(theIndex, string(theTitle));
+ if (theIndex < 1 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ aTable->SetRowTitle(theIndex, std::string(theTitle));
}
char* SALOMEDS_AttributeTableOfInteger_i::GetRowTitle(CORBA::Long theIndex)
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ if (theIndex < 1 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowTitle(theIndex).c_str());
return c_s._retn();
}
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ if (theIndex < 1 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
CORBA::String_var aStr = CORBA::string_dup(theTitle);
- aTable->SetColumnTitle(theIndex, string(aStr));
+ aTable->SetColumnTitle(theIndex, std::string(aStr));
}
char* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitle(CORBA::Long theIndex)
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ if (theIndex < 1 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
CORBA::String_var c_s = CORBA::string_dup(aTable->GetColumnTitle(theIndex).c_str());
return c_s._retn();
}
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
- aTable->SetRowUnit(theIndex, string(theUnit));
+ if (theIndex < 1 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ aTable->SetRowUnit(theIndex, std::string(theUnit));
}
char* SALOMEDS_AttributeTableOfInteger_i::GetRowUnit(CORBA::Long theIndex)
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ if (theIndex < 1 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowUnit(theIndex).c_str());
return c_s._retn();
}
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- vector<int> aRow;
+ std::vector<int> aRow;
for (int i = 0; i < theData.length(); i++) aRow.push_back(theData[i]);
try {
aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- vector<int> aRow;
+ std::vector<int> aRow;
for (int i = 0; i < theData.length(); i++) aRow.push_back(theData[i]);
try {
aTable->SetRowData(theRow, aRow);
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
- vector<int> aRow = aTable->GetRowData(theRow);
+ std::vector<int> aRow = aTable->GetRowData(theRow);
CorbaSeq->length(aRow.size());
for (int i = 0; i < aRow.size(); i++) {
CorbaSeq[i] = aRow[i];
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- vector<int> aColumn;
+ std::vector<int> aColumn;
for (int i = 0; i < theData.length(); i++) aColumn.push_back(theData[i]);
try {
aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- vector<int> aColumn;
+ std::vector<int> aColumn;
for (int i = 0; i < theData.length(); i++) aColumn.push_back(theData[i]);
try {
aTable->SetColumnData(theColumn, aColumn);
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
- vector<int> aColumn = aTable->GetColumnData(theColumn);
+ std::vector<int> aColumn = aTable->GetColumnData(theColumn);
CorbaSeq->length(aColumn.size());
for (int i = 0; i < aColumn.size(); i++) {
CorbaSeq[i] = aColumn[i];
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
CORBA::Long aValue;
try {
return aValue;
}
+void SALOMEDS_AttributeTableOfInteger_i::RemoveValue(CORBA::Long theRow, CORBA::Long theColumn)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATI_IncorrectIndex);
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_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_AttributeTableOfInteger_i::GetRowSetIndices(CORBA::Long theRow)
{
SALOMEDS::Locker lock;
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ if(theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
- vector<int> aSeq = aTable->GetSetRowIndices(theRow);
+ std::vector<int> aSeq = aTable->GetSetRowIndices(theRow);
CorbaSeq->length(aSeq.size());
for (int i = 0; i < aSeq.size(); i++) {
CorbaSeq[i] = aSeq[i];
return CorbaSeq._retn();
}
-
void SALOMEDS_AttributeTableOfInteger_i::SetNbColumns(CORBA::Long theNbColumns)
{
SALOMEDS::Locker lock;
SALOMEDS::Locker lock;
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- string aStream((char*)&theStream[0], theStream.length());
+ std::string aStream((char*)&theStream[0], theStream.length());
aTable->Load(aStream);
return true;
}
-SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfInteger_i::SaveToFile()
+SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfInteger_i::SaveToFile()
{
SALOMEDS::Locker lock;
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- string aString = aTable->Save();
+ std::string aString = aTable->Save();
char* aBuffer = (char*)CORBA::string_dup(aString.c_str());
int aBufferSize = strlen((char*)aBuffer);
return aStreamFile._retn();
}
+void SALOMEDS_AttributeTableOfInteger_i::SortRow(CORBA::Long theRow,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATI_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
+ if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger_i::SortColumn(CORBA::Long theColumn,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATI_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
+ if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger_i::SortByRow(CORBA::Long theRow,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATI_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
+ if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+void SALOMEDS_AttributeTableOfInteger_i::SortByColumn(CORBA::Long theColumn,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATI_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
+ if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+void SALOMEDS_AttributeTableOfInteger_i::SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1,
+ CORBA::Long theRow2, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATI_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_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_AttributeTableOfInteger_i::SwapRows(CORBA::Long theRow1, CORBA::Long theRow2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATI_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_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_AttributeTableOfInteger_i::SwapColumns(CORBA::Long theColumn1, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATI_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_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();
+ }
+}
class SALOMEDS_AttributeTableOfInteger_i: public virtual POA_SALOMEDS::AttributeTableOfInteger,
public virtual SALOMEDS_GenericAttribute_i
{
-
public:
-
SALOMEDS_AttributeTableOfInteger_i(SALOMEDSImpl_AttributeTableOfInteger* theAttr, CORBA::ORB_ptr orb)
:SALOMEDS_GenericAttribute_i(theAttr, orb) {};
virtual CORBA::Boolean HasValue(CORBA::Long theRow, CORBA::Long theColumn);
virtual CORBA::Long GetValue(CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void RemoveValue(CORBA::Long theRow, CORBA::Long theColumn)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual SALOMEDS::LongSeq* GetRowSetIndices(CORBA::Long theRow);
virtual void SetNbColumns(CORBA::Long theNbColumns);
+ virtual void SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SortByColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+
+ virtual void SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1,
+ CORBA::Long theRow2, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SwapRows(CORBA::Long theRow1, CORBA::Long theRow2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SwapColumns(CORBA::Long theColumn1, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
};
return aValue;
}
+void SALOMEDS_AttributeTableOfReal::RemoveValue(int theRow, int theColumn)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->RemoveValue(theRow, theColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->RemoveValue(theRow, theColumn);
+ }
+}
+
std::vector<int> SALOMEDS_AttributeTableOfReal::GetRowSetIndices(int theRow)
{
std::vector<int> aVector;
}
else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
}
+
+void SALOMEDS_AttributeTableOfReal::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfReal::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfReal::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortByRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortByRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfReal::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortByColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortByColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfReal::SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
+ }
+}
+
+void SALOMEDS_AttributeTableOfReal::SwapRows(int theRow1, int theRow2)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SwapRows(theRow1, theRow2);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SwapRows(theRow1, theRow2);
+ }
+}
+
+void SALOMEDS_AttributeTableOfReal::SwapColumns(int theColumn1, int theColumn2)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SwapColumns(theColumn1, theColumn2);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SwapColumns(theColumn1, theColumn2);
+ }
+}
virtual void PutValue(double theValue, int theRow, int theColumn);
virtual bool HasValue(int theRow, int theColumn);
virtual double GetValue(int theRow, int theColumn);
+ virtual void RemoveValue(int theRow, int theColumn);
virtual std::vector<int> GetRowSetIndices(int theRow);
virtual void SetNbColumns(int theNbColumns);
+ virtual void SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2);
+ virtual void SwapRows(int theRow1, int theRow2);
+ virtual void SwapColumns(int theColumn1, int theColumn2);
};
#endif
#include <string>
#include <vector>
-using namespace std;
-
#include "Utils_ExceptHandlers.hxx"
UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTable::IncorrectIndex);
UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
CORBA::String_var aStr = CORBA::string_dup(theTitle);
- aTable->SetTitle(string(aStr));
+ aTable->SetTitle(std::string(aStr));
}
char* SALOMEDS_AttributeTableOfReal_i::GetTitle()
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
- aTable->SetRowTitle(theIndex, string(theTitle));
+ aTable->SetRowTitle(theIndex, std::string(theTitle));
}
char* SALOMEDS_AttributeTableOfReal_i::GetRowTitle(CORBA::Long theIndex)
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
CORBA::String_var aStr = CORBA::string_dup(theTitle);
- aTable->SetColumnTitle(theIndex, string(aStr));
+ aTable->SetColumnTitle(theIndex, std::string(aStr));
}
char* SALOMEDS_AttributeTableOfReal_i::GetColumnTitle(CORBA::Long theIndex)
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
- aTable->SetRowUnit(theIndex, string(theUnit));
+ aTable->SetRowUnit(theIndex, std::string(theUnit));
}
char* SALOMEDS_AttributeTableOfReal_i::GetRowUnit(CORBA::Long theIndex)
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- vector<double> aRow;
+ std::vector<double> aRow;
for (int i = 0; i < theData.length(); i++) aRow.push_back(theData[i]);
aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
}
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- vector<double> aRow;
+ std::vector<double> aRow;
for (int i = 0; i < theData.length(); i++) aRow.push_back(theData[i]);
aTable->SetRowData(theRow, aRow);
}
if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq;
- vector<double> aRow = aTable->GetRowData(theRow);
+ std::vector<double> aRow = aTable->GetRowData(theRow);
CorbaSeq->length(aRow.size());
for (int i = 0; i < aRow.size(); i++) {
CorbaSeq[i] = aRow[i];
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- vector<double> aColumn;
+ std::vector<double> aColumn;
for (int i = 0; i < theData.length(); i++) aColumn.push_back(theData[i]);
aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
}
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- vector<double> aColumn;
+ std::vector<double> aColumn;
for (int i = 0; i < theData.length(); i++) aColumn.push_back(theData[i]);
aTable->SetColumnData(theColumn, aColumn);
}
if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq;
- vector<double> aColumn = aTable->GetColumnData(theColumn);
+ std::vector<double> aColumn = aTable->GetColumnData(theColumn);
CorbaSeq->length(aColumn.size());
for (int i = 0; i < aColumn.size(); i++) {
CorbaSeq[i] = aColumn[i];
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<SALOMEDSImpl_AttributeTableOfReal*>(_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)
{
if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
- vector<int> aSeq = aTable->GetSetRowIndices(theRow);
+ std::vector<int> aSeq = aTable->GetSetRowIndices(theRow);
int len = aSeq.size();
CorbaSeq->length(len);
for (int i = 0; i < len; i++) {
return CorbaSeq._retn();
}
-
void SALOMEDS_AttributeTableOfReal_i::SetNbColumns(CORBA::Long theNbColumns)
{
SALOMEDS::Locker lock;
SALOMEDS::Locker lock;
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- string aStream((char*)&theStream[0], theStream.length());
+ std::string aStream((char*)&theStream[0], theStream.length());
aTable->Load(aStream);
return true;
}
SALOMEDS::Locker lock;
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- string aString = aTable->Save();
+ std::string aString = aTable->Save();
char* aBuffer = (char*)CORBA::string_dup(aString.c_str());
int aBufferSize = strlen((char*)aBuffer);
return aStreamFile._retn();
}
+
+void 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<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+void 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<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+void 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<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+void 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<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+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<SALOMEDSImpl_AttributeTableOfReal*>(_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<SALOMEDSImpl_AttributeTableOfReal*>(_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<SALOMEDSImpl_AttributeTableOfReal*>(_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();
+ }
+}
#include "SALOMEDS_GenericAttribute_i.hxx"
#include "SALOMEDSImpl_AttributeTableOfReal.hxx"
-class SALOMEDS_AttributeTableOfReal_i: public virtual POA_SALOMEDS::AttributeTableOfReal,
- public virtual SALOMEDS_GenericAttribute_i {
-
+class SALOMEDS_AttributeTableOfReal_i : public virtual POA_SALOMEDS::AttributeTableOfReal,
+ public virtual SALOMEDS_GenericAttribute_i
+{
public:
-
SALOMEDS_AttributeTableOfReal_i(SALOMEDSImpl_AttributeTableOfReal* theAttr, CORBA::ORB_ptr orb)
- :SALOMEDS_GenericAttribute_i(theAttr, orb) {};
-
+ : SALOMEDS_GenericAttribute_i(theAttr, orb) {};
+
~SALOMEDS_AttributeTableOfReal_i() {};
-
- virtual void SetTitle(const char* theTitle);
+
+ virtual void SetTitle(const char* theTitle);
virtual char* GetTitle();
virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle)
throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual CORBA::Boolean HasValue(CORBA::Long theRow, CORBA::Long theColumn);
virtual CORBA::Double GetValue(CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void RemoveValue(CORBA::Long theRow, CORBA::Long theColumn)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual SALOMEDS::LongSeq* GetRowSetIndices(CORBA::Long theRow);
virtual void SetNbColumns(CORBA::Long theNbColumns);
+ virtual void SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SortByColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+
+ virtual void SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1,
+ CORBA::Long theRow2, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SwapRows(CORBA::Long theRow1, CORBA::Long theRow2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SwapColumns(CORBA::Long theColumn1, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
return aValue;
}
+void SALOMEDS_AttributeTableOfString::RemoveValue(int theRow, int theColumn)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->RemoveValue(theRow, theColumn);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->RemoveValue(theRow, theColumn);
+ }
+}
+
std::vector<int> SALOMEDS_AttributeTableOfString::GetRowSetIndices(int theRow)
{
std::vector<int> aVector;
}
else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetNbColumns(theNbColumns);
}
+
+void SALOMEDS_AttributeTableOfString::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfString::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfString::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortByRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortByRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfString::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortByColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortByColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ }
+}
+
+void SALOMEDS_AttributeTableOfString::SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SwapCells(theRow1, theColumn1, theRow2, theColumn2);
+ }
+}
+
+void SALOMEDS_AttributeTableOfString::SwapRows(int theRow1, int theRow2)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SwapRows(theRow1, theRow2);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SwapRows(theRow1, theRow2);
+ }
+}
+
+void SALOMEDS_AttributeTableOfString::SwapColumns(int theColumn1, int theColumn2)
+{
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SwapColumns(theColumn1, theColumn2);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SwapColumns(theColumn1, theColumn2);
+ }
+}
virtual void PutValue(const std::string& theValue, int theRow, int theColumn);
virtual bool HasValue(int theRow, int theColumn);
virtual std::string GetValue(int theRow, int theColumn);
+ virtual void RemoveValue(int theRow, int theColumn);
virtual std::vector<int> GetRowSetIndices(int theRow);
virtual void SetNbColumns(int theNbColumns);
+ virtual void SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy);
+ virtual void SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2);
+ virtual void SwapRows(int theRow1, int theRow2);
+ virtual void SwapColumns(int theColumn1, int theColumn2);
};
#endif
#include "Utils_ExceptHandlers.hxx"
-using namespace std;
-
UNEXPECT_CATCH(ATS_IncorrectIndex, SALOMEDS::AttributeTable::IncorrectIndex);
UNEXPECT_CATCH(ATS_IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
CORBA::String_var aStr = CORBA::string_dup(theTitle);
- aTable->SetTitle(string(aStr));
+ aTable->SetTitle(std::string(aStr));
}
char* SALOMEDS_AttributeTableOfString_i::GetTitle()
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
- aTable->SetRowTitle(theIndex, string(theTitle));
+ aTable->SetRowTitle(theIndex, std::string(theTitle));
}
char* SALOMEDS_AttributeTableOfString_i::GetRowTitle(CORBA::Long theIndex)
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
- aTable->SetRowTitle(i + 1, string((char*)theTitles[i].in()));
+ aTable->SetRowTitle(i + 1, std::string((char*)theTitles[i].in()));
}
}
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
- aTable->SetColumnTitle(theIndex, string((char*)theTitle));
+ aTable->SetColumnTitle(theIndex, std::string((char*)theTitle));
}
char* SALOMEDS_AttributeTableOfString_i::GetColumnTitle(CORBA::Long theIndex)
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
- aTable->SetColumnTitle(i + 1, string((char*)theTitles[i].in()));
+ aTable->SetColumnTitle(i + 1, std::string((char*)theTitles[i].in()));
}
}
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
- aTable->SetRowUnit(theIndex, string((char*)theUnit));
+ aTable->SetRowUnit(theIndex, std::string((char*)theUnit));
}
char* SALOMEDS_AttributeTableOfString_i::GetRowUnit(CORBA::Long theIndex)
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
for (int i = 0; i < theUnits.length(); i++) {
- aTable->SetRowUnit(i + 1, string((char*)theUnits[i].in()));
+ aTable->SetRowUnit(i + 1, std::string((char*)theUnits[i].in()));
}
}
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- vector<string> aRow;
- for (int i = 0; i < theData.length(); i++) aRow.push_back(string(CORBA::string_dup(theData[i])));
+ std::vector<std::string> aRow;
+ for (int i = 0; i < theData.length(); i++) aRow.push_back(std::string(CORBA::string_dup(theData[i])));
aTable->SetRowData(aTable->GetNbRows() + 1, aRow);
}
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- vector<string> aRow;
- for (int i = 0; i < theData.length(); i++) aRow.push_back(string(CORBA::string_dup(theData[i].in())));
+ std::vector<std::string> aRow;
+ for (int i = 0; i < theData.length(); i++) aRow.push_back(std::string(CORBA::string_dup(theData[i].in())));
aTable->SetRowData(theRow, aRow);
}
if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
- vector<string> aRow = aTable->GetRowData(theRow);
+ std::vector<std::string> aRow = aTable->GetRowData(theRow);
CorbaSeq->length(aRow.size());
for (int i = 0; i < aRow.size(); i++) {
CorbaSeq[i] = CORBA::string_dup(aRow[i].c_str());
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- vector<string> aColumn;
- for (int i = 0; i < theData.length(); i++) aColumn.push_back(string(CORBA::string_dup(theData[i])));
+ std::vector<std::string> aColumn;
+ for (int i = 0; i < theData.length(); i++) aColumn.push_back(std::string(CORBA::string_dup(theData[i])));
aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn);
}
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- vector<string> aColumn;
- for (int i = 0; i < theData.length(); i++) aColumn.push_back(string(CORBA::string_dup(theData[i])));
+ std::vector<std::string> aColumn;
+ for (int i = 0; i < theData.length(); i++) aColumn.push_back(std::string(CORBA::string_dup(theData[i])));
aTable->SetColumnData(theColumn, aColumn);
}
if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq;
- vector<string> aColumn = aTable->GetColumnData(theColumn);
+ std::vector<std::string> aColumn = aTable->GetColumnData(theColumn);
CorbaSeq->length(aColumn.size());
for (int i = 0; i < aColumn.size(); i++) {
CorbaSeq[i] = CORBA::string_dup(aColumn[i].c_str());
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
- string aValue;
+ std::string aValue;
try {
aValue = aTable->GetValue(theRow, theColumn);
}
return CORBA::string_dup(aValue.c_str());
}
+void SALOMEDS_AttributeTableOfString_i::RemoveValue(CORBA::Long theRow, CORBA::Long theColumn)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATS_IncorrectIndex);
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::GetRowSetIndices(CORBA::Long theRow)
{
if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
- vector<int> aSeq = aTable->GetSetRowIndices(theRow);
+ std::vector<int> aSeq = aTable->GetSetRowIndices(theRow);
CorbaSeq->length(aSeq.size());
for (int i = 0; i < aSeq.size(); i++) {
CorbaSeq[i] = aSeq[i];
return CorbaSeq._retn();
}
-
void SALOMEDS_AttributeTableOfString_i::SetNbColumns(CORBA::Long theNbColumns)
{
SALOMEDS::Locker lock;
SALOMEDS::Locker lock;
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- string aStream((char*)&theStream[0], theStream.length());
+ std::string aStream((char*)&theStream[0], theStream.length());
aTable->Load(aStream);
return true;
}
SALOMEDS::Locker lock;
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- string aString = aTable->Save();
+ std::string aString = aTable->Save();
char* aBuffer = (char*)CORBA::string_dup(aString.c_str());
int aBufferSize = strlen((char*)aBuffer);
return aStreamFile._retn();
}
+void SALOMEDS_AttributeTableOfString_i::SortRow(CORBA::Long theRow,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATS_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
+ if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+void SALOMEDS_AttributeTableOfString_i::SortColumn(CORBA::Long theColumn,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATS_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
+ if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+void SALOMEDS_AttributeTableOfString_i::SortByRow(CORBA::Long theRow,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATS_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
+ if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+void SALOMEDS_AttributeTableOfString_i::SortByColumn(CORBA::Long theColumn,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATS_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
+ if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ try {
+ aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+}
+
+void SALOMEDS_AttributeTableOfString_i::SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1,
+ CORBA::Long theRow2, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATS_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::SwapRows(CORBA::Long theRow1, CORBA::Long theRow2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATS_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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_AttributeTableOfString_i::SwapColumns(CORBA::Long theColumn1, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATS_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_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();
+ }
+}
virtual CORBA::Boolean HasValue(CORBA::Long theRow, CORBA::Long theColumn);
virtual char* GetValue(CORBA::Long theRow, CORBA::Long theColumn)
throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void RemoveValue(CORBA::Long theRow, CORBA::Long theColumn)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual SALOMEDS::LongSeq* GetRowSetIndices(CORBA::Long theRow);
virtual void SetNbColumns(CORBA::Long theNbColumns);
+ virtual void SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SortByColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+
+ virtual void SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1,
+ CORBA::Long theRow2, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SwapRows(CORBA::Long theRow1, CORBA::Long theRow2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual void SwapColumns(CORBA::Long theColumn1, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+
virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream);
virtual SALOMEDS::TMPFile* SaveToFile();
-
};
#endif
SALOMEDSClient_AttributeSequenceOfInteger.hxx \
SALOMEDSClient_AttributeSequenceOfReal.hxx \
SALOMEDSClient_AttributeStudyProperties.hxx \
+ SALOMEDSClient_AttributeTable.hxx \
SALOMEDSClient_AttributeTableOfInteger.hxx \
SALOMEDSClient_AttributeTableOfReal.hxx \
SALOMEDSClient_AttributeTableOfString.hxx \
--- /dev/null
+// Copyright (C) 2007-2008 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
+// 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 : SALOMEDSClient_AttributeTable.hxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+
+#ifndef SALOMEDSClient_AttributeTable_HeaderFile
+#define SALOMEDSClient_AttributeTable_HeaderFile
+
+#include <vector>
+#include <string>
+#include "SALOMEDSClient_definitions.hxx"
+#include "SALOMEDSClient_GenericAttribute.hxx"
+
+class SALOMEDSClient_AttributeTable: public virtual SALOMEDSClient_GenericAttribute
+{
+public:
+ typedef enum {
+ AscendingOrder,
+ DescendingOrder,
+ } SortOrder;
+
+ typedef enum {
+ EmptyLowest,
+ EmptyHighest,
+ EmptyFirst,
+ EmptyLast,
+ EmptyIgnore,
+ } SortPolicy;
+
+ virtual void SetTitle(const std::string& theTitle) = 0;
+ virtual std::string GetTitle() = 0;
+ virtual void SetRowTitle(int theIndex, const std::string& theTitle) = 0;
+ virtual std::string GetRowTitle(int theIndex) = 0;
+ virtual void SetRowTitles(const std::vector<std::string>& theTitles) = 0;
+ virtual std::vector<std::string> GetRowTitles() = 0;
+ virtual void SetColumnTitle(int theIndex, const std::string& theTitle) = 0;
+ virtual std::string GetColumnTitle(int theIndex) = 0;
+ virtual void SetColumnTitles(const std::vector<std::string>& theTitles) = 0;
+ virtual std::vector<std::string> GetColumnTitles() = 0;
+ virtual void SetRowUnit(int theIndex, const std::string& theUnit) = 0;
+ virtual std::string GetRowUnit(int theIndex) = 0;
+ virtual void SetRowUnits(const std::vector<std::string>& theUnits) = 0;
+ virtual std::vector<std::string> GetRowUnits() = 0;
+
+ virtual int GetNbRows() = 0;
+ virtual int GetNbColumns() = 0;
+ virtual bool HasValue(int theRow, int theColumn) = 0;
+ virtual void RemoveValue(int theRow, int theColumn) = 0;
+
+ virtual std::vector<int> GetRowSetIndices(int theRow) = 0;
+ virtual void SetNbColumns(int theNbColumns) = 0;
+
+ virtual void SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) = 0;
+ virtual void SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) = 0;
+ virtual void SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) = 0;
+ virtual void SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) = 0;
+ virtual void SwapCells(int theRow1, int theColumn1, int theRow2, int theColumn2) = 0;
+ virtual void SwapRows(int theRow1, int theRow2) = 0;
+ virtual void SwapColumns(int theColumn1, int theColumn2) = 0;
+};
+
+#endif // SALOMEDSClient_AttributeTable_HeaderFile
#include <vector>
#include <string>
#include "SALOMEDSClient_definitions.hxx"
-#include "SALOMEDSClient_GenericAttribute.hxx"
+#include "SALOMEDSClient_AttributeTable.hxx"
-class SALOMEDSClient_AttributeTableOfInteger: public virtual SALOMEDSClient_GenericAttribute
+class SALOMEDSClient_AttributeTableOfInteger: public SALOMEDSClient_AttributeTable
{
-
public:
-
- virtual void SetTitle(const std::string& theTitle) = 0;
- virtual std::string GetTitle() = 0;
- virtual void SetRowTitle(int theIndex, const std::string& theTitle) = 0;
- virtual std::string GetRowTitle(int theIndex) = 0;
- virtual void SetRowTitles(const std::vector<std::string>& theTitles) = 0;
- virtual std::vector<std::string> GetRowTitles() = 0;
- virtual void SetColumnTitle(int theIndex, const std::string& theTitle) = 0;
- virtual std::string GetColumnTitle(int theIndex) = 0;
- virtual void SetColumnTitles(const std::vector<std::string>& theTitles) = 0;
- virtual std::vector<std::string> GetColumnTitles() = 0;
- virtual void SetRowUnit(int theIndex, const std::string& theUnit) = 0;
- virtual std::string GetRowUnit(int theIndex) = 0;
- virtual void SetRowUnits(const std::vector<std::string>& theUnits) = 0;
- virtual std::vector<std::string> GetRowUnits() = 0;
-
- virtual int GetNbRows() = 0;
- virtual int GetNbColumns() = 0;
virtual void AddRow(const std::vector<int>& theData) = 0;
virtual void SetRow(int theRow, const std::vector<int>& theData) = 0;
virtual std::vector<int> GetRow(int theRow) = 0;
virtual void SetColumn(int theColumn, const std::vector<int>& theData) = 0;
virtual std::vector<int> GetColumn(int theColumn) = 0;
virtual void PutValue(int theValue, int theRow, int theColumn) = 0;
- virtual bool HasValue(int theRow, int theColumn) = 0;
virtual int GetValue(int theRow, int theColumn) = 0;
-
- virtual std::vector<int> GetRowSetIndices(int theRow) = 0;
- virtual void SetNbColumns(int theNbColumns) = 0;
-
};
-#endif
+#endif // SALOMEDSClient_AttributeTableOfInteger_HeaderFile
#include <vector>
#include <string>
#include "SALOMEDSClient_definitions.hxx"
-#include "SALOMEDSClient_GenericAttribute.hxx"
+#include "SALOMEDSClient_AttributeTable.hxx"
-class SALOMEDSClient_AttributeTableOfReal: public virtual SALOMEDSClient_GenericAttribute
+class SALOMEDSClient_AttributeTableOfReal: public SALOMEDSClient_AttributeTable
{
-
public:
-
- virtual void SetTitle(const std::string& theTitle) = 0;
- virtual std::string GetTitle() = 0;
- virtual void SetRowTitle(int theIndex, const std::string& theTitle) = 0;
- virtual std::string GetRowTitle(int theIndex) = 0;
- virtual void SetRowTitles(const std::vector<std::string>& theTitles) = 0;
- virtual std::vector<std::string> GetRowTitles() = 0;
- virtual void SetColumnTitle(int theIndex, const std::string& theTitle) = 0;
- virtual std::string GetColumnTitle(int theIndex) = 0;
- virtual void SetColumnTitles(const std::vector<std::string>& theTitles) = 0;
- virtual std::vector<std::string> GetColumnTitles() = 0;
- virtual void SetRowUnit(int theIndex, const std::string& theUnit) = 0;
- virtual std::string GetRowUnit(int theIndex) = 0;
- virtual void SetRowUnits(const std::vector<std::string>& theUnits) = 0;
- virtual std::vector<std::string> GetRowUnits() = 0;
-
- virtual int GetNbRows() = 0;
- virtual int GetNbColumns() = 0;
virtual void AddRow(const std::vector<double>& theData) = 0;
virtual void SetRow(int theRow, const std::vector<double>& theData) = 0;
virtual std::vector<double> GetRow(int theRow) = 0;
virtual void SetColumn(int theColumn, const std::vector<double>& theData) = 0;
virtual std::vector<double> GetColumn(int theColumn) = 0;
virtual void PutValue(double theValue, int theRow, int theColumn) = 0;
- virtual bool HasValue(int theRow, int theColumn) = 0;
virtual double GetValue(int theRow, int theColumn) = 0;
-
- virtual std::vector<int> GetRowSetIndices(int theRow) = 0;
- virtual void SetNbColumns(int theNbColumns) = 0;
-
};
-#endif
+#endif // SALOMEDSClient_AttributeTableOfReal_HeaderFile
#include <vector>
#include <string>
#include "SALOMEDSClient_definitions.hxx"
-#include "SALOMEDSClient_GenericAttribute.hxx"
+#include "SALOMEDSClient_AttributeTable.hxx"
-class SALOMEDSClient_AttributeTableOfString: public virtual SALOMEDSClient_GenericAttribute
+class SALOMEDSClient_AttributeTableOfString: public SALOMEDSClient_AttributeTable
{
public:
-
- virtual void SetTitle(const std::string& theTitle) = 0;
- virtual std::string GetTitle() = 0;
- virtual void SetRowTitle(int theIndex, const std::string& theTitle) = 0;
- virtual std::string GetRowTitle(int theIndex) = 0;
- virtual void SetRowTitles(const std::vector<std::string>& theTitles) = 0;
- virtual std::vector<std::string> GetRowTitles() = 0;
- virtual void SetColumnTitle(int theIndex, const std::string& theTitle) = 0;
- virtual std::string GetColumnTitle(int theIndex) = 0;
- virtual void SetColumnTitles(const std::vector<std::string>& theTitles) = 0;
- virtual std::vector<std::string> GetColumnTitles() = 0;
- virtual void SetRowUnit(int theIndex, const std::string& theUnit) = 0;
- virtual std::string GetRowUnit(int theIndex) = 0;
- virtual void SetRowUnits(const std::vector<std::string>& theUnits) = 0;
- virtual std::vector<std::string> GetRowUnits() = 0;
-
- virtual int GetNbRows() = 0;
- virtual int GetNbColumns() = 0;
virtual void AddRow(const std::vector<std::string>& theData) = 0;
virtual void SetRow(int theRow, const std::vector<std::string>& theData) = 0;
virtual std::vector<std::string> GetRow(int theRow) = 0;
virtual void SetColumn(int theColumn, const std::vector<std::string>& theData) = 0;
virtual std::vector<std::string> GetColumn(int theColumn) = 0;
virtual void PutValue(const std::string& theValue, int theRow, int theColumn) = 0;
- virtual bool HasValue(int theRow, int theColumn) = 0;
virtual std::string GetValue(int theRow, int theColumn) = 0;
-
- virtual std::vector<int> GetRowSetIndices(int theRow) = 0;
- virtual void SetNbColumns(int theNbColumns) = 0;
-
};
-#endif
+#endif // SALOMEDSClient_AttributeTableOfString_HeaderFile
SALOMEDSImpl_AttributePixMap.hxx \
SALOMEDSImpl_AttributeLocalID.hxx \
SALOMEDSImpl_AttributeTarget.hxx \
+ SALOMEDSImpl_AttributeTable.hxx \
SALOMEDSImpl_AttributeTableOfInteger.hxx \
SALOMEDSImpl_AttributeTableOfReal.hxx \
SALOMEDSImpl_AttributeTableOfString.hxx \
SALOMEDSImpl_AttributeSequenceOfReal.hxx \
SALOMEDSImpl_Attributes.hxx \
SALOMEDSImpl_AttributeStudyProperties.hxx \
+ SALOMEDSImpl_AttributeTable.hxx \
SALOMEDSImpl_AttributeTableOfInteger.hxx \
SALOMEDSImpl_AttributeTableOfReal.hxx \
SALOMEDSImpl_AttributeTableOfString.hxx \
--- /dev/null
+// Copyright (C) 2007-2008 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
+// 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 : SALOMEDSImpl_AttributeTable.hxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+
+#ifndef _SALOMEDSImpl_AttributeTable_HeaderFile
+#define _SALOMEDSImpl_AttributeTable_HeaderFile
+
+#include "SALOMEDSImpl_Defines.hxx"
+
+class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTable
+{
+public:
+ //! Sort order
+ typedef enum {
+ AscendingOrder, //!< The items are sorted ascending
+ DescendingOrder, //!< The items are sorted descending
+ } SortOrder;
+
+ //! Sort policy (specifies how empty cells are taken into account when sorting)
+ typedef enum {
+ EmptyLowest, //!< Empty cells are considered as lowest values
+ EmptyHighest, //!< Empty cells are considered as highest values
+ EmptyFirst, //!< Empty cells are always first
+ EmptyLast, //!< Empty cells are always last
+ EmptyIgnore, //!< Empty cells are ignored (stay at initial positions)
+ } SortPolicy;
+};
+
+template <class TTable> class TableSorter
+{
+ TTable* myTable;
+ SALOMEDSImpl_AttributeTable::SortOrder mySortOrder;
+ SALOMEDSImpl_AttributeTable::SortPolicy mySortPolicy;
+ int myIndex;
+ bool myIsRow;
+
+public:
+ TableSorter( TTable* table,
+ SALOMEDSImpl_AttributeTable::SortOrder so,
+ SALOMEDSImpl_AttributeTable::SortPolicy sp,
+ int index,
+ bool sortRow)
+ : myTable( table ), mySortOrder( so ), mySortPolicy( sp ),
+ myIndex( index ), myIsRow( sortRow ) {}
+
+ bool operator() ( int idx1, int idx2 )
+ {
+ bool hasValue1 = myIsRow ? myTable->HasValue( myIndex, idx1 ) : myTable->HasValue( idx1, myIndex );
+ bool hasValue2 = myIsRow ? myTable->HasValue( myIndex, idx2 ) : myTable->HasValue( idx2, myIndex );
+ if ( !hasValue1 && !hasValue2 ) {
+ return false;
+ }
+ else if ( !hasValue1 || !hasValue2 ) {
+ switch ( mySortPolicy ) {
+ case SALOMEDSImpl_AttributeTable::EmptyLowest:
+ return (!hasValue1) ?
+ (mySortOrder == SALOMEDSImpl_AttributeTable::AscendingOrder) :
+ (mySortOrder == SALOMEDSImpl_AttributeTable::DescendingOrder);
+ case SALOMEDSImpl_AttributeTable::EmptyHighest:
+ return (!hasValue1) ?
+ (mySortOrder != SALOMEDSImpl_AttributeTable::AscendingOrder) :
+ (mySortOrder != SALOMEDSImpl_AttributeTable::DescendingOrder);
+ case SALOMEDSImpl_AttributeTable::EmptyFirst:
+ return (!hasValue1);
+ case SALOMEDSImpl_AttributeTable::EmptyLast:
+ return hasValue1;
+ case SALOMEDSImpl_AttributeTable::EmptyIgnore:
+ default:
+ // should not go here
+ return false;
+ }
+ }
+ else {
+ if ( myIsRow ) {
+ return mySortOrder == SALOMEDSImpl_AttributeTable::AscendingOrder ?
+ myTable->GetValue( myIndex, idx1 ) < myTable->GetValue( myIndex, idx2 ) :
+ myTable->GetValue( myIndex, idx2 ) < myTable->GetValue( myIndex, idx1 );
+ }
+ else {
+ return mySortOrder == SALOMEDSImpl_AttributeTable::AscendingOrder ?
+ myTable->GetValue( idx1, myIndex ) < myTable->GetValue( idx2, myIndex ) :
+ myTable->GetValue( idx2, myIndex ) < myTable->GetValue( idx1, myIndex );
+ }
+ }
+ }
+};
+
+#endif // _SALOMEDSImpl_AttributeTable_HeaderFile
// Author : Michael Ponikarov
// Module : SALOME
//
+
#include "SALOMEDSImpl_AttributeTableOfInteger.hxx"
-#include <sstream>
-using namespace std;
+#include <sstream>
+#include <algorithm>
#define SEPARATOR '\1'
-typedef map<int, int>::const_iterator MI;
+typedef std::map<int, int>::const_iterator MI;
static std::string getUnit(std::string theString)
{
CheckLocked();
Backup();
- map<int, int> aMap;
+ std::map<int, int> aMap;
aMap = myTable;
myTable.clear();
-
for(MI p = aMap.begin(); p != aMap.end(); p++) {
int aRow = (int)(p->first/myNbColumns) + 1;
int aCol = (int)(p->first - myNbColumns*(aRow-1));
}
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
-
}
void SALOMEDSImpl_AttributeTableOfInteger::SetTitle(const std::string& theTitle)
CheckLocked();
Backup();
myTitle = theTitle;
-
+
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
}
void SALOMEDSImpl_AttributeTableOfInteger::SetRowData(const int theRow,
- const vector<int>& theData)
+ const std::vector<int>& theData)
{
CheckLocked();
if(theData.size() > myNbColumns) SetNbColumns(theData.size());
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-vector<int> SALOMEDSImpl_AttributeTableOfInteger::GetRowData(const int theRow)
+std::vector<int> SALOMEDSImpl_AttributeTableOfInteger::GetRowData(const int theRow)
{
- vector<int> aSeq;
+ std::vector<int> aSeq;
int i, aShift = (theRow-1)*myNbColumns;
for(i = 1; i <= myNbColumns; i++) {
if(myTable.find(aShift+i) != myTable.end())
{
CheckLocked();
Backup();
- string aTitle(theTitle), aUnit = GetRowUnit(theRow);
+ std::string aTitle(theTitle), aUnit = GetRowUnit(theRow);
if(aUnit.size()>0) {
aTitle += SEPARATOR;
aTitle += aUnit;
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-void SALOMEDSImpl_AttributeTableOfInteger::SetRowUnits(const vector<string>& theUnits)
+void SALOMEDSImpl_AttributeTableOfInteger::SetRowUnits(const std::vector<std::string>& theUnits)
{
if (theUnits.size() != GetNbRows()) throw DFexception("Invalid number of rows");
int aLength = theUnits.size(), i;
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-vector<string> SALOMEDSImpl_AttributeTableOfInteger::GetRowUnits()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfInteger::GetRowUnits()
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int aLength = myRows.size(), i;
for(i=0; i<aLength; i++) aSeq.push_back(getUnit(myRows[i]));
return aSeq;
}
-void SALOMEDSImpl_AttributeTableOfInteger::SetRowTitles(const vector<string>& theTitles)
+void SALOMEDSImpl_AttributeTableOfInteger::SetRowTitles(const std::vector<std::string>& theTitles)
{
if (theTitles.size() != GetNbRows()) throw DFexception("Invalid number of rows");
int aLength = theTitles.size(), i;
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-vector<string> SALOMEDSImpl_AttributeTableOfInteger::GetRowTitles()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfInteger::GetRowTitles()
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int aLength = myRows.size(), i;
for(i=0; i<aLength; i++) aSeq.push_back(getTitle(myRows[i]));
return aSeq;
}
-
std::string SALOMEDSImpl_AttributeTableOfInteger::GetRowTitle(const int theRow) const
{
return getTitle(myRows[theRow-1]);
}
-
std::string SALOMEDSImpl_AttributeTableOfInteger::GetRowUnit(const int theRow) const
{
return getUnit(myRows[theRow-1]);
}
-
void SALOMEDSImpl_AttributeTableOfInteger::SetColumnData(const int theColumn,
- const vector<int>& theData)
+ const std::vector<int>& theData)
{
CheckLocked();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
}
-vector<int> SALOMEDSImpl_AttributeTableOfInteger::GetColumnData(const int theColumn)
+std::vector<int> SALOMEDSImpl_AttributeTableOfInteger::GetColumnData(const int theColumn)
{
- vector<int> aSeq;
+ std::vector<int> aSeq;
int i, anIndex;
for(i = 1; i <= myNbRows; i++) {
anIndex = myNbColumns*(i-1) + theColumn;
}
void SALOMEDSImpl_AttributeTableOfInteger::SetColumnTitle(const int theColumn,
- const std::string& theTitle)
+ const std::string& theTitle)
{
CheckLocked();
Backup();
return myCols[theColumn-1];
}
-void SALOMEDSImpl_AttributeTableOfInteger::SetColumnTitles(const vector<string>& theTitles)
+void SALOMEDSImpl_AttributeTableOfInteger::SetColumnTitles(const std::vector<std::string>& theTitles)
{
if (theTitles.size() != myNbColumns) throw DFexception("Invalid number of columns");
int aLength = theTitles.size(), i;
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-vector<string> SALOMEDSImpl_AttributeTableOfInteger::GetColumnTitles()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfInteger::GetColumnTitles()
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int aLength = myCols.size(), i;
for(i=0; i<aLength; i++) aSeq.push_back(myCols[i]);
return aSeq;
const int theColumn)
{
CheckLocked();
+ //Backup();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
int anIndex = (theRow-1)*myNbColumns + theColumn;
const int theColumn)
{
if(theRow > myNbRows || theRow < 1) throw DFexception("Invalid cell index");
- if(theColumn > myNbColumns || theColumn < 1) DFexception("Invalid cell index");
+ if(theColumn > myNbColumns || theColumn < 1) throw DFexception("Invalid cell index");
int anIndex = (theRow-1)*myNbColumns + theColumn;
if(myTable.find(anIndex) != myTable.end()) return myTable[anIndex];
return 0;
}
+void SALOMEDSImpl_AttributeTableOfInteger::RemoveValue(const int theRow, const int theColumn)
+{
+ CheckLocked();
+ if(theRow > myNbRows || theRow < 1) throw DFexception("Invalid cell index");
+ if(theColumn > myNbColumns || theColumn < 1) throw DFexception("Invalid cell index");
+
+ int anIndex = (theRow-1)*myNbColumns + theColumn;
+ if (myTable.find(anIndex) != myTable.end()) {
+ //Backup();
+ myTable.erase(anIndex);
+ SetModifyFlag(); // table is modified
+ }
+}
+
const std::string& SALOMEDSImpl_AttributeTableOfInteger::ID() const
{
return GetID();
aTable->myCols.push_back(GetColumnTitle(anIndex));
}
-
-vector<int> SALOMEDSImpl_AttributeTableOfInteger::GetSetRowIndices(const int theRow)
+std::vector<int> SALOMEDSImpl_AttributeTableOfInteger::GetSetRowIndices(const int theRow)
{
- vector<int> aSeq;
+ std::vector<int> aSeq;
int i, aShift = myNbColumns*(theRow-1);
for(i = 1; i <= myNbColumns; i++) {
return aSeq;
}
-vector<int> SALOMEDSImpl_AttributeTableOfInteger::GetSetColumnIndices(const int theColumn)
+std::vector<int> SALOMEDSImpl_AttributeTableOfInteger::GetSetColumnIndices(const int theColumn)
{
- vector<int> aSeq;
+ std::vector<int> aSeq;
int i, anIndex;
for(i = 1; i <= myNbRows; i++) {
return aSeq;
}
-
-string SALOMEDSImpl_AttributeTableOfInteger::Save()
+std::string SALOMEDSImpl_AttributeTableOfInteger::Save()
{
- string aString;
+ std::string aString;
char* buffer = new char[1024];
int i, j, l;
return aString;
}
-
-
-void SALOMEDSImpl_AttributeTableOfInteger::Load(const string& value)
+void SALOMEDSImpl_AttributeTableOfInteger::Load(const std::string& value)
{
- vector<string> v;
+ std::vector<std::string> v;
int i, j, l, pos, aSize = (int)value.size();
for(i = 0, pos = 0; i<aSize; i++) {
if(value[i] == '\n') {
myTable[aKey] = aValue;
}
}
+
+void SALOMEDSImpl_AttributeTableOfInteger::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theRow > 0 && theRow <= myNbRows ) {
+ std::vector<int> indices( myNbColumns );
+ int cnt = 0;
+ for ( int i = 0; i < myNbColumns; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(theRow, i+1) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfInteger> sorter( this, sortOrder, sortPolicy, theRow, true );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbColumns );
+ cnt = 0;
+ for( int i = 0; i < myNbColumns; i++ )
+ other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int col = 0; col < indices.size(); col++ ) {
+ int idx = indices[col];
+ if ( col+1 == idx ) continue;
+ SwapCells(theRow, col+1, theRow, idx);
+ int idx1 = 0;
+ for ( int i = col+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == col+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfInteger::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theColumn > 0 && theColumn <= myNbColumns ) {
+ std::vector<int> indices( myNbRows );
+ int cnt = 0;
+ for ( int i = 0; i < myNbRows; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(i+1, theColumn) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfInteger> sorter( this, sortOrder, sortPolicy, theColumn, false );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbRows );
+ cnt = 0;
+ for( int i = 0; i < myNbRows; i++ )
+ other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int row = 0; row < indices.size(); row++ ) {
+ int idx = indices[row];
+ if ( row+1 == idx ) continue;
+ SwapCells(row+1, theColumn, idx, theColumn);
+ int idx1 = 0;
+ for ( int i = row+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == row+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfInteger::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theRow > 0 && theRow <= myNbRows ) {
+ std::vector<int> indices( myNbColumns );
+ int cnt = 0;
+ for ( int i = 0; i < myNbColumns; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(theRow, i+1) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfInteger> sorter( this, sortOrder, sortPolicy, theRow, true );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbColumns );
+ cnt = 0;
+ for( int i = 0; i < myNbColumns; i++ )
+ other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int col = 0; col < indices.size(); col++ ) {
+ int idx = indices[col];
+ if ( col+1 == idx ) continue;
+ SwapColumns(col+1, idx);
+ int idx1 = 0;
+ for ( int i = col+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == col+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapColumns()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfInteger::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theColumn > 0 && theColumn <= myNbColumns ) {
+ std::vector<int> indices( myNbRows );
+ int cnt = 0;
+ for ( int i = 0; i < myNbRows; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(i+1, theColumn) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfInteger> sorter( this, sortOrder, sortPolicy, theColumn, false );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbRows );
+ cnt = 0;
+ for( int i = 0; i < myNbRows; i++ )
+ other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int row = 0; row < indices.size(); row++ ) {
+ int idx = indices[row];
+ if ( row+1 == idx ) continue;
+ SwapRows(row+1, idx);
+ int idx1 = 0;
+ for ( int i = row+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == row+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapRows()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfInteger::SwapCells(const int theRow1, const int theColumn1,
+ const int theRow2, const int theColumn2)
+{
+ CheckLocked();
+ if (theRow1 > myNbRows || theRow1 < 1) throw DFexception("Invalid cell index");
+ if (theRow2 > myNbRows || theRow2 < 1) throw DFexception("Invalid cell index");
+ if (theColumn1 > myNbColumns || theColumn1 < 1) throw DFexception("Invalid cell index");
+ if (theColumn2 > myNbColumns || theColumn2 < 1) throw DFexception("Invalid cell index");
+
+ int anIndex1 = (theRow1-1)*myNbColumns + theColumn1;
+ int anIndex2 = (theRow2-1)*myNbColumns + theColumn2;
+
+ bool hasValue1 = myTable.find(anIndex1) != myTable.end();
+ bool hasValue2 = myTable.find(anIndex2) != myTable.end();
+
+ if (!hasValue1 && !hasValue2) return; // nothing changed
+
+ int value1 = hasValue1 ? myTable[anIndex1] : 0;
+ int value2 = hasValue2 ? myTable[anIndex2] : 0;
+
+ if (hasValue1 && hasValue2 && value1 == value2) return; // nothing changed
+
+ if (hasValue1) myTable[anIndex2] = value1;
+ else myTable.erase(anIndex2);
+ if (hasValue2) myTable[anIndex1] = value2;
+ else myTable.erase(anIndex1);
+
+ SetModifyFlag(); // table is modified
+}
+
+void SALOMEDSImpl_AttributeTableOfInteger::SwapRows(const int theRow1, const int theRow2)
+{
+ CheckLocked();
+ for (int i = 1; i <= myNbColumns; i++)
+ SwapCells(theRow1, i, theRow2, i);
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+}
+
+void SALOMEDSImpl_AttributeTableOfInteger::SwapColumns(const int theColumn1, const int theColumn2)
+{
+ CheckLocked();
+ for (int i = 1; i <= myNbRows; i++)
+ SwapCells(i, theColumn1, i, theColumn2);
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+}
+
#include "DF_Attribute.hxx"
#include "DF_Label.hxx"
#include "SALOMEDSImpl_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeTable.hxx"
#include <string>
#include <vector>
class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTableOfInteger :
- public SALOMEDSImpl_GenericAttribute
+ public SALOMEDSImpl_GenericAttribute, public SALOMEDSImpl_AttributeTable
{
public:
- virtual std::string Save();
- virtual void Load(const std::string&);
- static const std::string& GetID() ;
- static SALOMEDSImpl_AttributeTableOfInteger* Set(const DF_Label& label) ;
+ virtual std::string Save();
+ virtual void Load(const std::string&);
+
+ static const std::string& GetID();
+ static SALOMEDSImpl_AttributeTableOfInteger* Set(const DF_Label& label);
+
SALOMEDSImpl_AttributeTableOfInteger();
- void SetNbColumns(const int theNbColumns);
- void SetTitle(const std::string& theTitle) ;
- std::string GetTitle() const;
- void SetRowData(const int theRow,const std::vector<int>& theData) ;
- std::vector<int> GetRowData(const int theRow) ;
- void SetRowTitle(const int theRow,const std::string& theTitle) ;
- void SetRowUnit(const int theRow,const std::string& theUnit) ;
- std::string GetRowUnit(const int theRow) const;
- void SetRowUnits(const std::vector<std::string>& theUnits) ;
+
+ void SetNbColumns(const int theNbColumns);
+ void SetTitle(const std::string& theTitle);
+ std::string GetTitle() const;
+ void SetRowData(const int theRow, const std::vector<int>& theData);
+ std::vector<int> GetRowData(const int theRow);
+ void SetRowTitle(const int theRow, const std::string& theTitle);
+ void SetRowUnit(const int theRow, const std::string& theUnit);
+ std::string GetRowUnit(const int theRow) const;
+ void SetRowUnits(const std::vector<std::string>& theUnits);
std::vector<std::string> GetRowUnits();
- void SetRowTitles(const std::vector<std::string>& theTitles) ;
+ void SetRowTitles(const std::vector<std::string>& theTitles);
std::vector<std::string> GetRowTitles();
- std::string GetRowTitle(const int theRow) const;
- void SetColumnData(const int theColumn,const std::vector<int>& theData) ;
- std::vector<int> GetColumnData(const int theColumn) ;
- void SetColumnTitle(const int theColumn,const std::string& theTitle) ;
- std::string GetColumnTitle(const int theColumn) const;
- void SetColumnTitles(const std::vector<std::string>& theTitles);
+ std::string GetRowTitle(const int theRow) const;
+ void SetColumnData(const int theColumn, const std::vector<int>& theData);
+ std::vector<int> GetColumnData(const int theColumn);
+ void SetColumnTitle(const int theColumn, const std::string& theTitle);
+ std::string GetColumnTitle(const int theColumn) const;
+ void SetColumnTitles(const std::vector<std::string>& theTitles);
std::vector<std::string> GetColumnTitles();
- int GetNbRows() const;
- int GetNbColumns() const;
+ int GetNbRows() const;
+ int GetNbColumns() const;
+
+ void PutValue(const int theValue, const int theRow, const int theColumn);
+ bool HasValue(const int theRow, const int theColumn);
+ int GetValue(const int theRow, const int theColumn);
+ void RemoveValue(const int theRow, const int theColumn);
+ const std::string& ID() const;
+ void Restore(DF_Attribute* with);
+ DF_Attribute* NewEmpty() const;
+ void Paste(DF_Attribute* into);
+
+ std::vector<int> GetSetRowIndices(const int theRow);
+ std::vector<int> GetSetColumnIndices(const int theColumn);
- void PutValue(const int theValue,const int theRow,const int theColumn) ;
- bool HasValue(const int theRow,const int theColumn) ;
- int GetValue(const int theRow,const int theColumn) ;
- const std::string& ID() const;
- void Restore(DF_Attribute* with) ;
- DF_Attribute* NewEmpty() const;
- void Paste(DF_Attribute* into);
+ void SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ void SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy);
+ void SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ void SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy);
- std::vector<int> GetSetRowIndices(const int theRow);
- std::vector<int> GetSetColumnIndices(const int theColumn);
+ void SwapCells(const int theRow1, const int theColumn1, const int theRow2, const int theColumn2);
+ void SwapRows(const int theRow1, const int theRow2);
+ void SwapColumns(const int theColumn1, const int theColumn2);
~SALOMEDSImpl_AttributeTableOfInteger() {}
private:
-
- std::map<int, int> myTable;
- std::string myTitle;
+ std::map<int, int> myTable;
+ std::string myTitle;
std::vector<std::string> myRows;
std::vector<std::string> myCols;
- int myNbRows;
- int myNbColumns;
-
+ int myNbRows;
+ int myNbColumns;
};
#endif
// Author : Michael Ponikarov
// Module : SALOME
//
+
#include "SALOMEDSImpl_AttributeTableOfReal.hxx"
-#include <stdio.h>
+
#include <sstream>
+#include <algorithm>
#define SEPARATOR '\1'
-
typedef std::map<int, double>::const_iterator MI;
static std::string getUnit(const std::string& theString)
return aSeq;
}
-
void SALOMEDSImpl_AttributeTableOfReal::SetRowTitle(const int theRow,
const std::string& theTitle)
{
return aSeq;
}
-
std::string SALOMEDSImpl_AttributeTableOfReal::GetRowTitle(const int theRow) const
{
return getTitle(myRows[theRow-1]);
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-
std::vector<double> SALOMEDSImpl_AttributeTableOfReal::GetColumnData(const int theColumn)
{
std::vector<double> aSeq;
const int theColumn)
{
CheckLocked();
+ //Backup();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
int anIndex = (theRow-1)*myNbColumns + theColumn;
return 0.;
}
+void SALOMEDSImpl_AttributeTableOfReal::RemoveValue(const int theRow, const int theColumn)
+{
+ CheckLocked();
+ if(theRow > myNbRows || theRow < 1) throw DFexception("Invalid cell index");
+ if(theColumn > myNbColumns || theColumn < 1) throw DFexception("Invalid cell index");
+
+ int anIndex = (theRow-1)*myNbColumns + theColumn;
+ if (myTable.find(anIndex) != myTable.end()) {
+ //Backup();
+ myTable.erase(anIndex);
+ SetModifyFlag(); // table is modified
+ }
+}
+
const std::string& SALOMEDSImpl_AttributeTableOfReal::ID() const
{
return GetID();
aTable->myCols.push_back(GetColumnTitle(anIndex));
}
-
std::vector<int> SALOMEDSImpl_AttributeTableOfReal::GetSetRowIndices(const int theRow)
{
std::vector<int> aSeq;
}
}
+
+void SALOMEDSImpl_AttributeTableOfReal::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theRow > 0 && theRow <= myNbRows ) {
+ std::vector<int> indices( myNbColumns );
+ int cnt = 0;
+ for ( int i = 0; i < myNbColumns; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(theRow, i+1) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfReal> sorter( this, sortOrder, sortPolicy, theRow, true );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbColumns );
+ cnt = 0;
+ for( int i = 0; i < myNbColumns; i++ )
+ other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int col = 0; col < indices.size(); col++ ) {
+ int idx = indices[col];
+ if ( col+1 == idx ) continue;
+ SwapCells(theRow, col+1, theRow, idx);
+ int idx1 = 0;
+ for ( int i = col+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == col+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfReal::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theColumn > 0 && theColumn <= myNbColumns ) {
+ std::vector<int> indices( myNbRows );
+ int cnt = 0;
+ for ( int i = 0; i < myNbRows; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(i+1, theColumn) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfReal> sorter( this, sortOrder, sortPolicy, theColumn, false );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbRows );
+ cnt = 0;
+ for( int i = 0; i < myNbRows; i++ )
+ other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int row = 0; row < indices.size(); row++ ) {
+ int idx = indices[row];
+ if ( row+1 == idx ) continue;
+ SwapCells(row+1, theColumn, idx, theColumn);
+ int idx1 = 0;
+ for ( int i = row+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == row+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfReal::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theRow > 0 && theRow <= myNbRows ) {
+ std::vector<int> indices( myNbColumns );
+ int cnt = 0;
+ for ( int i = 0; i < myNbColumns; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(theRow, i+1) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfReal> sorter( this, sortOrder, sortPolicy, theRow, true );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbColumns );
+ cnt = 0;
+ for( int i = 0; i < myNbColumns; i++ )
+ other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int col = 0; col < indices.size(); col++ ) {
+ int idx = indices[col];
+ if ( col+1 == idx ) continue;
+ SwapColumns(col+1, idx);
+ int idx1 = 0;
+ for ( int i = col+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == col+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapColumns()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfReal::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theColumn > 0 && theColumn <= myNbColumns ) {
+ std::vector<int> indices( myNbRows );
+ int cnt = 0;
+ for ( int i = 0; i < myNbRows; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(i+1, theColumn) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfReal> sorter( this, sortOrder, sortPolicy, theColumn, false );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbRows );
+ cnt = 0;
+ for( int i = 0; i < myNbRows; i++ )
+ other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int row = 0; row < indices.size(); row++ ) {
+ int idx = indices[row];
+ if ( row+1 == idx ) continue;
+ SwapRows(row+1, idx);
+ int idx1 = 0;
+ for ( int i = row+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == row+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapRows()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfReal::SwapCells(const int theRow1, const int theColumn1,
+ const int theRow2, const int theColumn2)
+{
+ CheckLocked();
+ if (theRow1 > myNbRows || theRow1 < 1) throw DFexception("Invalid cell index");
+ if (theRow2 > myNbRows || theRow2 < 1) throw DFexception("Invalid cell index");
+ if (theColumn1 > myNbColumns || theColumn1 < 1) throw DFexception("Invalid cell index");
+ if (theColumn2 > myNbColumns || theColumn2 < 1) throw DFexception("Invalid cell index");
+
+ int anIndex1 = (theRow1-1)*myNbColumns + theColumn1;
+ int anIndex2 = (theRow2-1)*myNbColumns + theColumn2;
+
+ bool hasValue1 = myTable.find(anIndex1) != myTable.end();
+ bool hasValue2 = myTable.find(anIndex2) != myTable.end();
+
+ if (!hasValue1 && !hasValue2) return; // nothing changed
+
+ double value1 = hasValue1 ? myTable[anIndex1] : 0;
+ double value2 = hasValue2 ? myTable[anIndex2] : 0;
+
+ if (hasValue1 && hasValue2 && value1 == value2) return; // nothing changed
+
+ if (hasValue1) myTable[anIndex2] = value1;
+ else myTable.erase(anIndex2);
+ if (hasValue2) myTable[anIndex1] = value2;
+ else myTable.erase(anIndex1);
+
+ SetModifyFlag(); // table is modified
+}
+
+void SALOMEDSImpl_AttributeTableOfReal::SwapRows(const int theRow1, const int theRow2)
+{
+ CheckLocked();
+ for (int i = 1; i <= myNbColumns; i++)
+ SwapCells(theRow1, i, theRow2, i);
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+}
+
+void SALOMEDSImpl_AttributeTableOfReal::SwapColumns(const int theColumn1, const int theColumn2)
+{
+ CheckLocked();
+ for (int i = 1; i <= myNbRows; i++)
+ SwapCells(i, theColumn1, i, theColumn2);
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+}
+
#include "DF_Attribute.hxx"
#include "DF_Label.hxx"
#include "SALOMEDSImpl_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeTable.hxx"
#include <string>
#include <vector>
#include <map>
class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTableOfReal :
- public SALOMEDSImpl_GenericAttribute
+ public SALOMEDSImpl_GenericAttribute, public SALOMEDSImpl_AttributeTable
{
public:
- virtual std::string Save();
- virtual void Load(const std::string&);
- static const std::string& GetID() ;
- static SALOMEDSImpl_AttributeTableOfReal* Set(const DF_Label& label) ;
+ virtual std::string Save();
+ virtual void Load(const std::string&);
+
+ static const std::string& GetID();
+ static SALOMEDSImpl_AttributeTableOfReal* Set(const DF_Label& label);
+
SALOMEDSImpl_AttributeTableOfReal();
- void SetNbColumns(const int theNbColumns);
- void SetTitle(const std::string& theTitle) ;
- std::string GetTitle() const;
- void SetRowData(const int theRow,const std::vector<double>& theData) ;
- std::vector<double> GetRowData(const int theRow) ;
- void SetRowTitle(const int theRow,const std::string& theTitle) ;
- void SetRowUnit(const int theRow,const std::string& theUnit) ;
- std::string GetRowUnit(const int theRow) const;
- void SetRowUnits(const std::vector<std::string>& theUnits) ;
+
+ void SetNbColumns(const int theNbColumns);
+ void SetTitle(const std::string& theTitle);
+ std::string GetTitle() const;
+ void SetRowData(const int theRow, const std::vector<double>& theData);
+ std::vector<double> GetRowData(const int theRow);
+ void SetRowTitle(const int theRow, const std::string& theTitle);
+ void SetRowUnit(const int theRow, const std::string& theUnit);
+ std::string GetRowUnit(const int theRow) const;
+ void SetRowUnits(const std::vector<std::string>& theUnits);
std::vector<std::string> GetRowUnits();
- void SetRowTitles(const std::vector<std::string>& theTitles) ;
+ void SetRowTitles(const std::vector<std::string>& theTitles);
std::vector<std::string> GetRowTitles();
- std::string GetRowTitle(const int theRow) const;
- void SetColumnData(const int theColumn,const std::vector<double>& theData) ;
- std::vector<double> GetColumnData(const int theColumn) ;
- void SetColumnTitle(const int theColumn,const std::string& theTitle) ;
- void SetColumnTitles(const std::vector<std::string>& theTitles);
+ std::string GetRowTitle(const int theRow) const;
+ void SetColumnData(const int theColumn, const std::vector<double>& theData);
+ std::vector<double> GetColumnData(const int theColumn);
+ void SetColumnTitle(const int theColumn, const std::string& theTitle);
+ void SetColumnTitles(const std::vector<std::string>& theTitles);
std::vector<std::string> GetColumnTitles();
- std::string GetColumnTitle(const int theColumn) const;
- int GetNbRows() const;
- int GetNbColumns() const;
+ std::string GetColumnTitle(const int theColumn) const;
+ int GetNbRows() const;
+ int GetNbColumns() const;
- void PutValue(const double& theValue,const int theRow,const int theColumn) ;
- bool HasValue(const int theRow,const int theColumn) ;
- double GetValue(const int theRow,const int theColumn) ;
- const std::string& ID() const;
- void Restore(DF_Attribute* with) ;
- DF_Attribute* NewEmpty() const;
- void Paste(DF_Attribute* into);
+ void PutValue(const double& theValue, const int theRow, const int theColumn);
+ bool HasValue(const int theRow, const int theColumn);
+ double GetValue(const int theRow, const int theColumn);
+ void RemoveValue(const int theRow, const int theColumn);
+ const std::string& ID() const;
+ void Restore(DF_Attribute* with);
+ DF_Attribute* NewEmpty() const;
+ void Paste(DF_Attribute* into);
- std::vector<int> GetSetRowIndices(const int theRow);
- std::vector<int> GetSetColumnIndices(const int theColumn);
+ std::vector<int> GetSetRowIndices(const int theRow);
+ std::vector<int> GetSetColumnIndices(const int theColumn);
+
+ void SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ void SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy);
+ void SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ void SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy);
+
+ void SwapCells(const int theRow1, const int theColumn1, const int theRow2, const int theColumn2);
+ void SwapRows(const int theRow1, const int theRow2);
+ void SwapColumns(const int theColumn1, const int theColumn2);
~SALOMEDSImpl_AttributeTableOfReal() {}
private:
- std::map<int, double> myTable;
- std::string myTitle;
+ std::map<int, double> myTable;
+ std::string myTitle;
std::vector<std::string> myRows;
std::vector<std::string> myCols;
- int myNbRows;
- int myNbColumns;
-
+ int myNbRows;
+ int myNbColumns;
};
#endif
// Author : Sergey Ruin
// Module : SALOME
//
+
#include "SALOMEDSImpl_AttributeTableOfString.hxx"
-#include <stdio.h>
-#include <stdlib.h>
-#include <sstream>
-using namespace std;
+#include <sstream>
+#include <algorithm>
#define SEPARATOR '\1'
-
-typedef map<int, string>::const_iterator MI;
+typedef std::map<int, std::string>::const_iterator MI;
static std::string getUnit(std::string theString)
{
CheckLocked();
Backup();
- map<int, string> aMap;
+ std::map<int, std::string> aMap;
aMap = myTable;
myTable.clear();
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-void SALOMEDSImpl_AttributeTableOfString::SetRowUnits(const vector<string>& theUnits)
+void SALOMEDSImpl_AttributeTableOfString::SetRowUnits(const std::vector<std::string>& theUnits)
{
if (theUnits.size() != GetNbRows()) throw DFexception("Invalid number of rows");
int aLength = theUnits.size(), i;
for(i = 1; i <= aLength; i++) SetRowUnit(i, theUnits[i-1]);
}
-vector<string> SALOMEDSImpl_AttributeTableOfString::GetRowUnits()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfString::GetRowUnits()
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int aLength = myRows.size(), i;
for(i=0; i<aLength; i++) aSeq.push_back(getUnit(myRows[i]));
return aSeq;
}
-void SALOMEDSImpl_AttributeTableOfString::SetRowTitles(const vector<string>& theTitles)
+void SALOMEDSImpl_AttributeTableOfString::SetRowTitles(const std::vector<std::string>& theTitles)
{
if (theTitles.size() != GetNbRows()) throw DFexception("Invalid number of rows");
int aLength = theTitles.size(), i;
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-vector<string> SALOMEDSImpl_AttributeTableOfString::GetRowTitles()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfString::GetRowTitles()
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int aLength = myRows.size(), i;
for(i=0; i<aLength; i++) aSeq.push_back(getTitle(myRows[i]));
return aSeq;
}
-
std::string SALOMEDSImpl_AttributeTableOfString::GetRowTitle(const int theRow) const
{
return getTitle(myRows[theRow-1]);
}
-
std::string SALOMEDSImpl_AttributeTableOfString::GetRowUnit(const int theRow) const
{
return getUnit(myRows[theRow-1]);
}
void SALOMEDSImpl_AttributeTableOfString::SetRowData(const int theRow,
- const vector<string>& theData)
+ const std::vector<std::string>& theData)
{
CheckLocked();
if(theData.size() > myNbColumns) SetNbColumns(theData.size());
return myTitle;
}
-vector<string> SALOMEDSImpl_AttributeTableOfString::GetRowData(const int theRow)
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfString::GetRowData(const int theRow)
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int i, aShift = (theRow-1)*myNbColumns;
for(i = 1; i <= myNbColumns; i++) {
if(myTable.find(aShift+i) != myTable.end())
}
void SALOMEDSImpl_AttributeTableOfString::SetColumnData(const int theColumn,
- const vector<string>& theData)
+ const std::vector<std::string>& theData)
{
CheckLocked();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-
-vector<string> SALOMEDSImpl_AttributeTableOfString::GetColumnData(const int theColumn)
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfString::GetColumnData(const int theColumn)
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int i, anIndex;
for(i = 1; i <= myNbRows; i++) {
return myCols[theColumn-1];
}
-
-void SALOMEDSImpl_AttributeTableOfString::SetColumnTitles(const vector<string>& theTitles)
+void SALOMEDSImpl_AttributeTableOfString::SetColumnTitles(const std::vector<std::string>& theTitles)
{
if (theTitles.size() != myNbColumns) throw DFexception("Invalid number of columns");
int aLength = theTitles.size(), i;
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-vector<string> SALOMEDSImpl_AttributeTableOfString::GetColumnTitles()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfString::GetColumnTitles()
{
- vector<string> aSeq;
+ std::vector<std::string> aSeq;
int aLength = myCols.size(), i;
for(i=0; i<aLength; i++) aSeq.push_back(myCols[i]);
return aSeq;
}
-
int SALOMEDSImpl_AttributeTableOfString::GetNbRows() const
{
return myNbRows;
const int theColumn)
{
CheckLocked();
+ //Backup();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
int anIndex = (theRow-1)*myNbColumns + theColumn;
return "";
}
+void SALOMEDSImpl_AttributeTableOfString::RemoveValue(const int theRow, const int theColumn)
+{
+ CheckLocked();
+ if(theRow > myNbRows || theRow < 1) throw DFexception("Invalid cell index");
+ if(theColumn > myNbColumns || theColumn < 1) throw DFexception("Invalid cell index");
+
+ int anIndex = (theRow-1)*myNbColumns + theColumn;
+ if (myTable.find(anIndex) != myTable.end()) {
+ //Backup();
+ myTable.erase(anIndex);
+ SetModifyFlag(); // table is modified
+ }
+}
+
const std::string& SALOMEDSImpl_AttributeTableOfString::ID() const
{
return GetID();
aTable->myCols.push_back(GetColumnTitle(anIndex));
}
-
-vector<int> SALOMEDSImpl_AttributeTableOfString::GetSetRowIndices(const int theRow)
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::GetSetRowIndices(const int theRow)
{
- vector<int> aSeq;
+ std::vector<int> aSeq;
int i, aShift = myNbColumns*(theRow-1);
for(i = 1; i <= myNbColumns; i++) {
return aSeq;
}
-vector<int> SALOMEDSImpl_AttributeTableOfString::GetSetColumnIndices(const int theColumn)
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::GetSetColumnIndices(const int theColumn)
{
- vector<int> aSeq;
+ std::vector<int> aSeq;
int i, anIndex;
for(i = 1; i <= myNbRows; i++) {
return aSeq;
}
-
-
-string SALOMEDSImpl_AttributeTableOfString::Save()
+std::string SALOMEDSImpl_AttributeTableOfString::Save()
{
- string aString;
+ std::string aString;
char* buffer = new char[1024];
int i, j, l;
return aString;
}
-void SALOMEDSImpl_AttributeTableOfString::Load(const string& value)
+void SALOMEDSImpl_AttributeTableOfString::Load(const std::string& value)
{
- vector<string> v;
+ std::vector<std::string> v;
int i, j, l, pos, aSize = (int)value.size();
for(i = 0, pos = 0; i<aSize; i++) {
if(value[i] == '\n') {
for(i=1; i<=l; i++) {
aStr = v[pos++]; //Ket as a string
int aKey = strtol(aStr.c_str(), NULL, 10);
- string aValue;
+ std::string aValue;
if(aStr[0] == '0') //If the first character of the key is 0, then empty value
aValue = "";
else {
myTable[aKey] = aValue;
}
}
+
+void SALOMEDSImpl_AttributeTableOfString::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theRow > 0 && theRow <= myNbRows ) {
+ std::vector<int> indices( myNbColumns );
+ int cnt = 0;
+ for ( int i = 0; i < myNbColumns; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(theRow, i+1) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfString> sorter( this, sortOrder, sortPolicy, theRow, true );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbColumns );
+ cnt = 0;
+ for( int i = 0; i < myNbColumns; i++ )
+ other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int col = 0; col < indices.size(); col++ ) {
+ int idx = indices[col];
+ if ( col+1 == idx ) continue;
+ SwapCells(theRow, col+1, theRow, idx);
+ int idx1 = 0;
+ for ( int i = col+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == col+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfString::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theColumn > 0 && theColumn <= myNbColumns ) {
+ std::vector<int> indices( myNbRows );
+ int cnt = 0;
+ for ( int i = 0; i < myNbRows; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(i+1, theColumn) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfString> sorter( this, sortOrder, sortPolicy, theColumn, false );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbRows );
+ cnt = 0;
+ for( int i = 0; i < myNbRows; i++ )
+ other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int row = 0; row < indices.size(); row++ ) {
+ int idx = indices[row];
+ if ( row+1 == idx ) continue;
+ SwapCells(row+1, theColumn, idx, theColumn);
+ int idx1 = 0;
+ for ( int i = row+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == row+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfString::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theRow > 0 && theRow <= myNbRows ) {
+ std::vector<int> indices( myNbColumns );
+ int cnt = 0;
+ for ( int i = 0; i < myNbColumns; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(theRow, i+1) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfString> sorter( this, sortOrder, sortPolicy, theRow, true );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbColumns );
+ cnt = 0;
+ for( int i = 0; i < myNbColumns; i++ )
+ other[i] = HasValue(theRow, i+1) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int col = 0; col < indices.size(); col++ ) {
+ int idx = indices[col];
+ if ( col+1 == idx ) continue;
+ SwapColumns(col+1, idx);
+ int idx1 = 0;
+ for ( int i = col+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == col+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapColumns()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfString::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ if ( theColumn > 0 && theColumn <= myNbColumns ) {
+ std::vector<int> indices( myNbRows );
+ int cnt = 0;
+ for ( int i = 0; i < myNbRows; i++ ) {
+ if ( sortPolicy != EmptyIgnore || HasValue(i+1, theColumn) ) {
+ indices[cnt++] = i+1;
+ }
+ }
+ indices.resize(cnt);
+
+ TableSorter<SALOMEDSImpl_AttributeTableOfString> sorter( this, sortOrder, sortPolicy, theColumn, false );
+ std::stable_sort( indices.begin(), indices.end(), sorter );
+
+ if ( sortPolicy == EmptyIgnore ) {
+ std::vector<int> other( myNbRows );
+ cnt = 0;
+ for( int i = 0; i < myNbRows; i++ )
+ other[i] = HasValue(i+1, theColumn) ? indices[cnt++] : i+1;
+ indices = other;
+ }
+
+ for ( int row = 0; row < indices.size(); row++ ) {
+ int idx = indices[row];
+ if ( row+1 == idx ) continue;
+ SwapRows(row+1, idx);
+ int idx1 = 0;
+ for ( int i = row+1; i < indices.size() && idx1 == 0; i++)
+ if ( indices[i] == row+1 ) idx1 = i;
+ indices[idx1] = idx;
+ }
+ // no need for SetModifyFlag(), since it is done by SwapRows()
+ }
+}
+
+void SALOMEDSImpl_AttributeTableOfString::SwapCells(const int theRow1, const int theColumn1,
+ const int theRow2, const int theColumn2)
+{
+ CheckLocked();
+ if (theRow1 > myNbRows || theRow1 < 1) throw DFexception("Invalid cell index");
+ if (theRow2 > myNbRows || theRow2 < 1) throw DFexception("Invalid cell index");
+ if (theColumn1 > myNbColumns || theColumn1 < 1) throw DFexception("Invalid cell index");
+ if (theColumn2 > myNbColumns || theColumn2 < 1) throw DFexception("Invalid cell index");
+
+ int anIndex1 = (theRow1-1)*myNbColumns + theColumn1;
+ int anIndex2 = (theRow2-1)*myNbColumns + theColumn2;
+
+ bool hasValue1 = myTable.find(anIndex1) != myTable.end();
+ bool hasValue2 = myTable.find(anIndex2) != myTable.end();
+
+ if (!hasValue1 && !hasValue2) return; // nothing changed
+
+ std::string value1 = hasValue1 ? myTable[anIndex1] : 0;
+ std::string value2 = hasValue2 ? myTable[anIndex2] : 0;
+
+ if (hasValue1 && hasValue2 && value1 == value2) return; // nothing changed
+
+ if (hasValue1) myTable[anIndex2] = value1;
+ else myTable.erase(anIndex2);
+ if (hasValue2) myTable[anIndex1] = value2;
+ else myTable.erase(anIndex1);
+
+ SetModifyFlag(); // table is modified
+}
+
+void SALOMEDSImpl_AttributeTableOfString::SwapRows(const int theRow1, const int theRow2)
+{
+ CheckLocked();
+ for (int i = 1; i <= myNbColumns; i++)
+ SwapCells(theRow1, i, theRow2, i);
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+}
+
+void SALOMEDSImpl_AttributeTableOfString::SwapColumns(const int theColumn1, const int theColumn2)
+{
+ CheckLocked();
+ for (int i = 1; i <= myNbRows; i++)
+ SwapCells(i, theColumn1, i, theColumn2);
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+}
#include "DF_Label.hxx"
#include "DF_Attribute.hxx"
#include "SALOMEDSImpl_GenericAttribute.hxx"
+#include "SALOMEDSImpl_AttributeTable.hxx"
#include <string>
#include <vector>
#include <map>
class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTableOfString :
- public SALOMEDSImpl_GenericAttribute
+ public SALOMEDSImpl_GenericAttribute, public SALOMEDSImpl_AttributeTable
{
public:
- virtual std::string Save();
- virtual void Load(const std::string&);
- static const std::string& GetID() ;
- static SALOMEDSImpl_AttributeTableOfString* Set(const DF_Label& label) ;
+ virtual std::string Save();
+ virtual void Load(const std::string&);
+
+ static const std::string& GetID();
+ static SALOMEDSImpl_AttributeTableOfString* Set(const DF_Label& label);
+
SALOMEDSImpl_AttributeTableOfString();
- void SetNbColumns(const int theNbColumns);
- void SetTitle(const std::string& theTitle) ;
- std::string GetTitle() const;
- void SetRowData(const int theRow,const std::vector<std::string>& theData) ;
- std::vector<std::string> GetRowData(const int theRow) ;
- void SetRowTitle(const int theRow,const std::string& theTitle) ;
- void SetRowUnit(const int theRow,const std::string& theUnit) ;
- std::string GetRowUnit(const int theRow) const;
- void SetRowUnits(const std::vector<std::string>& theUnits) ;
+ void SetNbColumns(const int theNbColumns);
+ void SetTitle(const std::string& theTitle);
+ std::string GetTitle() const;
+ void SetRowData(const int theRow, const std::vector<std::string>& theData);
+ std::vector<std::string> GetRowData(const int theRow);
+ void SetRowTitle(const int theRow, const std::string& theTitle);
+ void SetRowUnit(const int theRow, const std::string& theUnit);
+ std::string GetRowUnit(const int theRow) const;
+ void SetRowUnits(const std::vector<std::string>& theUnits);
std::vector<std::string> GetRowUnits();
- void SetRowTitles(const std::vector<std::string>& theTitles) ;
+ void SetRowTitles(const std::vector<std::string>& theTitles);
std::vector<std::string> GetRowTitles();
- std::string GetRowTitle(const int theRow) const;
- void SetColumnData(const int theColumn,const std::vector<std::string>& theData) ;
- std::vector<std::string> GetColumnData(const int theColumn) ;
- void SetColumnTitle(const int theColumn,const std::string& theTitle) ;
- std::string GetColumnTitle(const int theColumn) const;
- void SetColumnTitles(const std::vector<std::string>& theTitles);
+ std::string GetRowTitle(const int theRow) const;
+ void SetColumnData(const int theColumn, const std::vector<std::string>& theData);
+ std::vector<std::string> GetColumnData(const int theColumn);
+ void SetColumnTitle(const int theColumn, const std::string& theTitle);
+ std::string GetColumnTitle(const int theColumn) const;
+ void SetColumnTitles(const std::vector<std::string>& theTitles);
std::vector<std::string> GetColumnTitles();
- int GetNbRows() const;
- int GetNbColumns() const;
+ int GetNbRows() const;
+ int GetNbColumns() const;
+
+ void PutValue(const std::string& theValue, const int theRow, const int theColumn);
+ bool HasValue(const int theRow, const int theColumn);
+ std::string GetValue(const int theRow, const int theColumn);
+ void RemoveValue(const int theRow, const int theColumn);
+ const std::string& ID() const;
+ void Restore(DF_Attribute* with);
+ DF_Attribute* NewEmpty() const;
+ void Paste(DF_Attribute* into);
- void PutValue(const std::string& theValue,const int theRow,const int theColumn) ;
- bool HasValue(const int theRow,const int theColumn) ;
- std::string GetValue(const int theRow,const int theColumn) ;
- const std::string& ID() const;
- void Restore(DF_Attribute* with) ;
- DF_Attribute* NewEmpty() const;
- void Paste(DF_Attribute* into);
+ std::vector<int> GetSetRowIndices(const int theRow);
+ std::vector<int> GetSetColumnIndices(const int theColumn);
- std::vector<int> GetSetRowIndices(const int theRow);
- std::vector<int> GetSetColumnIndices(const int theColumn);
+ void SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ void SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy);
+ void SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ void SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy);
+
+ void SwapCells(const int theRow1, const int theColumn1, const int theRow2, const int theColumn2);
+ void SwapRows(const int theRow1, const int theRow2);
+ void SwapColumns(const int theColumn1, const int theColumn2);
~SALOMEDSImpl_AttributeTableOfString() {}
private:
-
std::map<int, std::string> myTable;
- std::string myTitle;
- std::vector<std::string> myRows;
- std::vector<std::string> myCols;
- int myNbRows;
- int myNbColumns;
-
+ std::string myTitle;
+ std::vector<std::string> myRows;
+ std::vector<std::string> myCols;
+ int myNbRows;
+ int myNbColumns;
};
#endif