*/
void Remove(in SObject anObject);
};
- //==========================================================================
- /*! \brief %AttributeTableOfInteger interface
- This attribute allows to store a table of integers (indexing from 1 like in CASCADE)
- and string titles of this table, of each row, of each column.
+ //==========================================================================
+ /*!
+ \brief Generic table attribute.
-<em>See \ref example21 for an example of usage of these methods in batchmode of %SALOME application.</em>
+ Used as base interface for the AttributeTableOfInteger, AttributeTableOfReal
+ and AttributeTableOfString. Provides functions which are common for all table
+ attributes.
-*/
+ \note The indices of rows and columns in the table start from 1.
+ \sa AttributeTableOfInteger, AttributeTableOfReal, AttributeTableOfString
+ */
//==========================================================================
- interface AttributeTableOfInteger : GenericAttribute
+ interface AttributeTable : GenericAttribute
{
-//! This exception is raised when an incorrect index is passed as parameter.
+ //! This exception is raised when an invalid (out of range) index is passed as parameter.
exception IncorrectIndex {};
-//! This exception is raised when an incorrect length of the argument is passed as parameter.
+ //! This exception is raised when sequence of incorrect length is passed as parameter.
exception IncorrectArgumentLength {};
- // titles: for table, for each row, for each column
-/*!
- Sets the title of the table.
-*/
- void SetTitle(in string theTitle);
-/*!
- Returns the title of the table.
-*/
+ //! 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
+ \sa GetTitle()
+ */
+ void SetTitle(in string title);
+ /*!
+ \brief Returns the title of the table.
+ \return table title (empty string if not set)
+ \sa SetTitle()
+ */
string GetTitle();
-/*!
- Sets the title of a row with a definite index.
-*/
- void SetRowTitle(in long theIndex, in string theTitle) raises(IncorrectIndex);
-/*!
- Sets the titles for all rows of the table.
-*/
- void SetRowTitles(in StringSeq theTitles) raises(IncorrectArgumentLength);
-/*!
- Returns the titles of all rows of the table.
-*/
+ /*!
+ \brief Sets the title of a row with specified index.
+
+ Raises an exception if \a row is out of range.
+
+ \param row row index
+ \param title title being set to the row
+ \sa GetRowTitle()
+ */
+ void SetRowTitle(in long row, in string title) raises(IncorrectIndex);
+ /*!
+ \brief Returns the title of a row with specified index.
+
+ Raises an exception if \a row is out of range.
+
+ \param row row index
+ \return row title (empty string if not set)
+ \sa SetRowTitle()
+ */
+ string GetRowTitle(in long row) raises(IncorrectIndex);
+ /*!
+ \brief Sets the titles for all rows in the table.
+
+ Raises an exception if length of the \a titles parameter is not equal
+ to the number of rows in the table.
+
+ \param titles titles being set to the table rows
+ \sa GetRowTitles()
+ */
+ void SetRowTitles(in StringSeq titles) raises(IncorrectArgumentLength);
+ /*!
+ \brief Returns the titles of all rows of the table.
+ \return list of all rows titles
+ \sa SetRowTitles()
+ */
StringSeq GetRowTitles();
-/*!
- Sets the title of a column with a definite index.
-*/
- void SetColumnTitle(in long theIndex, in string theTitle) raises(IncorrectIndex);
-/*!
- Sets the titles for all columns of the table.
-*/
- void SetColumnTitles(in StringSeq theTitles) raises(IncorrectArgumentLength);
-/*!
- Returns the titles of all columns of the table.
-*/
+ /*!
+ \brief Sets the title of a column with specified index.
+
+ Raises an exception if \a column is out of range.
+
+ \param column column index
+ \param title title being set to the column
+ \sa GetColumnTitle()
+ */
+ void SetColumnTitle(in long column, in string title) raises(IncorrectIndex);
+ /*!
+ \brief Returns the title of a column with specified index.
+
+ Raises an exception if \a column is out of range.
+
+ \param column column index
+ \return column title (empty string if not set)
+ \sa SetColumnTitle()
+ */
+ string GetColumnTitle(in long column) raises(IncorrectIndex);
+ /*!
+ \brief Sets the titles for all columns in the table.
+
+ Raises an exception if length of the \a titles parameter is not equal
+ to the number of columns in the table.
+
+ \param titles titles being set to the table columns
+ \sa GetColumnTitles()
+ */
+ void SetColumnTitles(in StringSeq titles) raises(IncorrectArgumentLength);
+ /*!
+ \brief Returns the titles of all columns of the table.
+ \return list of all columns titles
+ \sa SetColumnTitles()
+ */
StringSeq GetColumnTitles();
-
- //Rows units
-/*!
- Sets the unit of a row with a definite index.
-*/
- void SetRowUnit(in long theIndex, in string theUnit) raises(IncorrectIndex);
-/*!
- Sets the units for all rows of the table.
-*/
- void SetRowUnits(in StringSeq theUnits) raises(IncorrectArgumentLength);
-/*!
- Returns the units of all rows of the table.
-*/
+ /*!
+ \brief Assigns the unit label to the row with specified index.
+
+ Raises an exception if \a row is out of range.
+
+ \param row row index
+ \param unit unit label being set to the row
+ \sa GetRowUnit()
+ */
+ void SetRowUnit(in long row, in string unit) raises(IncorrectIndex);
+ /*!
+ \brief Returns the unit label of a row with specified index.
+
+ Raises an exception if \a row is out of range.
+
+ \param row row index
+ \return row unit label (empty string if not set)
+ \sa SetRowUnit()
+ */
+ string GetRowUnit(in long row) raises(IncorrectIndex);
+ /*!
+ \brief Sets the unit labels for all rows in the table.
+
+ Raises an exception if length of the \a units parameter is not equal
+ to the number of rows in the table.
+
+ \param units unit labels being set to the table rows
+ \sa GetRowUnits()
+ */
+ void SetRowUnits(in StringSeq units) raises(IncorrectArgumentLength);
+ /*!
+ \brief Returns the unit labels of all rows of the table.
+ \return list of all rows unit labels
+ \sa SetRowUnits()
+ */
StringSeq GetRowUnits();
-
- // table information
-/*!
- Returns the number of rows of the table.
-*/
+ /*!
+ \brief Returns the number of rows of the table.
+ \return rows count
+ \sa GetNbColumns()
+ */
long GetNbRows();
-/*!
- Returns the number of columns of the table.
-*/
+ /*!
+ \brief Returns the number of columns of the table.
+ \return columns count
+ \sa GetNbRows(), SetNbColumns()
+ */
long GetNbColumns();
-
- // operations with rows
-/*!
- Adds a row to the end of the table.
- \param theData A sequence of long values which will be set as elements of the added row.
-*/
- void AddRow(in LongSeq theData) raises(IncorrectArgumentLength);
-/*!
- Sets the elements of a definite row.
- \param theRow The number of the row.
- \param theData A sequence of long values which will be set as elements of this row.
-
-*/
- void SetRow(in long theRow, in LongSeq theData) raises(IncorrectArgumentLength, IncorrectIndex);
-/*!
- Gets the row of the table.
-
- \param theRow The number of the row.
- \return A sequence of long values which are set as elements of this row.
-*/
- LongSeq GetRow(in long theRow) raises(IncorrectIndex);
-
- // operations with columns
-/*!
- Adds a column to the end of the table.
-
- \param theData A sequence of long values which will be set as elements of this column.
-*/
- void AddColumn(in LongSeq theData) raises(IncorrectArgumentLength);
-/*!
- Sets the values of all elements of the column.
-
- \param theData A sequence of long values which will be set as elements of this column.
-*/
- void SetColumn(in long theColumn, in LongSeq theData) raises(IncorrectArgumentLength, IncorrectIndex);
-/*!
- Returns the column of the table.
-*/
- LongSeq GetColumn(in long theColumn) raises(IncorrectIndex);
-
- // operations with elements
-/*!
- Puts a value in the table.
- \param theRow The row, where the value will be placed.
- \param theColumn The column, where the value will be placed.
-*/
- void PutValue(in long theValue, in long theRow, in long theColumn) raises(IncorrectIndex);
-/*!
- Returns True if there is a value in the table.
- \param theRow The row containing the value
- \param theColumn The column containing the value
-*/
- boolean HasValue(in long theRow, in long theColumn);
-/*!
- Returns the value from the table.
- \param theRow The row containing the value
- \param theColumn The column containing the value
-*/
- long GetValue(in long theRow, in long theColumn) raises(IncorrectIndex);
-
-/*!
- Sets the max number of colums in the table.
- \note It'd better to set it before filling the table.
-*/
- void SetNbColumns(in long theNbColumns);
-
-/*!
- Returns the indices of the row where the values are defined.
-*/
- LongSeq GetRowSetIndices(in long theRow) raises(IncorrectIndex);
- // operations with files
-/*!
- Reads a table from a file.
-*/
- boolean ReadFromFile(in SALOMEDS::TMPFile theStream);
-/*!
- Saves a table into a file.
-*/
+ /*!
+ \brief Check if the value is set for the cell with specified \a row and \a column indices.
+ \param row row index
+ \param column column index
+ \return \c true if value is set for the specified cell or \c false otherwise
+ (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
+ \sa GetNbColumns()
+ */
+ void SetNbColumns(in long columns);
+ /*!
+ \brief Returns the indices of the columns in the specified \a row for which
+ values are set.
+
+ Raises an exception if \a row is out of range.
+
+ \param row row index
+ \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)
+ \return list of mixed column indices
+ */
+ LongSeq 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)
+ \return list of mixed row indices
+ */
+ LongSeq 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)
+ \return list of mixed column indices
+ */
+ LongSeq 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)
+ \return list of mixed row indices
+ */
+ LongSeq 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
+ \return \c true if table is successfully read or \c false otherwise
+ \sa SaveToFile()
+ */
+ boolean ReadFromFile(in SALOMEDS::TMPFile fileStream);
+ /*!
+ \brief Saves a table into a byte stream.
+ \return byte stream with table representation
+ \sa ReadFromFile()
+ */
SALOMEDS::TMPFile SaveToFile();
};
//==========================================================================
-/*! \brief %AttributeTableOfReal interface
+ /*!
+ \brief Table of %integer values
- This attribute allows to store a table of reals (indexing from 1 like in CASCADE)
- and string titles of this table, of each row, of each column.
-<em>See \ref example21 for an example of usage of these methods in batchmode of %SALOME application.</em>
+ This attribute allows to store a table of %integer values. It is possible
+ to specify titles for rows and columns. In addition, the unis labels can be
+ assigned to the rows. And finally, the table iself can have title.
-*/
- //==========================================================================
+ \note The indices of rows and columns in the table start from 1.
- interface AttributeTableOfReal : GenericAttribute
- {
-//! This exception is raised when an incorrect index is passed as parameter.
- exception IncorrectIndex {};
-//! This exception is raised when an incorrect length of the argument is passed as parameter.
- exception IncorrectArgumentLength {};
+ <em>See \ref example21 for an example of usage of this attribute in batchmode of %SALOME application.</em>
- // titles: for table, for each row, for each column
-/*!
- Sets the title of the table.
-*/
- void SetTitle(in string theTitle);
-/*!
- Returns the title of the table.
-*/
- string GetTitle();
-/*!
- Sets the title of a row with a definite index.
-*/
- void SetRowTitle(in long theIndex, in string theTitle) raises(IncorrectIndex);
-/*!
- Sets the titles for all rows of the table.
-*/
- void SetRowTitles(in StringSeq theTitles) raises(IncorrectArgumentLength);
-/*!
- Returns the titles of all rows of the table.
-*/
- StringSeq GetRowTitles();
-/*!
- Sets the title of a column with a definite index.
-*/
- void SetColumnTitle(in long theIndex, in string theTitle) raises(IncorrectIndex);
-/*!
- Sets the titles for all columns of the table.
-*/
- void SetColumnTitles(in StringSeq theTitles) raises(IncorrectArgumentLength);
-/*!
- Returns the titles of all columns of the table.
-*/
- StringSeq GetColumnTitles();
+ \sa AttributeTable, AttributeTableOfReal, AttributeTableOfString
+ */
+ //==========================================================================
- //Rows units
-/*!
- Sets the unit of a row with a definite index.
-*/
- void SetRowUnit(in long theIndex, in string theUnit) raises(IncorrectIndex);
-/*!
- Sets the units for all rows of the table.
-*/
- void SetRowUnits(in StringSeq theUnits) raises(IncorrectArgumentLength);
-/*!
- Returns the units of all rows of the table.
-*/
- StringSeq GetRowUnits();
+ interface AttributeTableOfInteger : AttributeTable
+ {
+ /*!
+ \brief Appends new row to the table.
+
+ If the length of the \a data parameter is greater than current number of columns
+ in the table, the table is automatically resized.
+
+ \param data sequence of values which will be set as elements of the added row
+ \sa SetRow(), GetRow(), AddColumn()
+ */
+ void AddRow(in LongSeq data) raises(IncorrectArgumentLength);
+ /*!
+ \brief Replaces all the elements of the specified \a row with new values.
+
+ Raises an exception if \a row is out of range or if the length of the
+ \a data parameter is not equal to the number of columns in the table.
+
+ \param row row index
+ \param data sequence of values being set as values of the row
+ \sa GetRow(), AddRow(), SetColumn()
+ */
+ void SetRow(in long row, in LongSeq data) raises(IncorrectArgumentLength, IncorrectIndex);
+ /*!
+ \brief Returns all the values of the specified row in the table.
+
+ Raises an exception if \a row is out of range.
+
+ \note For empty cells 0 value is returned.
+
+ \param row row index
+ \return sequence of values which are set as elements of the row.
+ \sa SetRow(), AddRow()
+ */
+ LongSeq GetRow(in long row) raises(IncorrectIndex);
+ /*!
+ \brief Appends new column to the table.
+
+ If the length of the \a data parameter is greater than current number of rows
+ in the table, the table is automatically resized.
+
+ \param data sequence of values which will be set as elements of the added column
+ \sa SetColumn(), GetColumn(), AddRow()
+ */
+ void AddColumn(in LongSeq data) raises(IncorrectArgumentLength);
+ /*!
+ \brief Replaces all the elements of the specified column with new values.
+
+ Raises an exception if \a column is out of range or if the length of the
+ \a data parameter is not equal to the number of rows in the table.
+
+ \param column column index
+ \param data sequence of values being set as values of the column
+ \sa GetColumn(), AddColumn(), SetRow()
+ */
+ void SetColumn(in long column, in LongSeq data) raises(IncorrectArgumentLength, IncorrectIndex);
+ /*!
+ \brief Returns all the values of the specified column in the table.
+
+ Raises an exception if \a column is out of range.
+
+ \note For empty cells 0 value is returned.
+
+ \param column column index
+ \return sequence of values which are set as elements of the column.
+ \sa SetColumn(), AddColumn()
+ */
+ LongSeq GetColumn(in long column) raises(IncorrectIndex);
+ /*!
+ \brief Puts a value to the table cell specified by \a row and \a column indices.
+
+ If the \a row and/or \a column parameter(s) are greater than current number of rows/columns
+ in the table, the table is automatically resized.
+
+ \param value value being set to the table cell
+ \param row row index
+ \param column column index
+ \sa GetValue(), HasValue()
+ */
+ void PutValue(in long value, in long row, in long column) raises(IncorrectIndex);
+ /*!
+ \brief Returns the value from the cell table.
+
+ Raises an exception if \a row or \a column is out of range or
+ if value is not set for the specified table cell.
+
+ \param row row index
+ \param column column index
+ \return value assigned to the table cell
+ \sa PutValue(), HasValue()
+ */
+ long GetValue(in long row, in long column) raises(IncorrectIndex);
+ };
- // table information
-/*!
- Returns the number of rows of the table.
-*/
- long GetNbRows();
-/*!
- Returns the number of columns of the table.
-*/
- long GetNbColumns();
+ //==========================================================================
+ /*!
+ \brief Table of real values
- // operations with rows
-/*!
- Adds a row to the end of the table.
-*/
- void AddRow(in DoubleSeq theData) raises(IncorrectArgumentLength);
-/*!
- Sets the values of all elements of the row.
-*/
- void SetRow(in long theRow, in DoubleSeq theData) raises(IncorrectArgumentLength, IncorrectIndex);
-/*!
- Returns the row of the table.
-*/
- DoubleSeq GetRow(in long theRow) raises(IncorrectIndex);
+ This attribute allows to store a table of real values. It is possible
+ to specify titles for rows and columns. In addition, the unis labels can be
+ assigned to the rows. And finally, the table iself can have title.
- // operations with columns
-/*!
- Adds a column to the end of the table.
-*/
- void AddColumn(in DoubleSeq theData) raises(IncorrectArgumentLength);
-/*!
- Sets the values of all elements of the column.
-*/
- void SetColumn(in long theColumn, in DoubleSeq theData) raises(IncorrectArgumentLength, IncorrectIndex);
-/*!
- Returns the column of the table.
-*/
- DoubleSeq GetColumn(in long theColumn) raises(IncorrectIndex);
+ \note The indices of rows and columns in the table start from 1.
- // operations with elements
-/*!
- Puts a value in the table.
- \param theRow The row, where the value will be placed.
- \param theColumn The column, where the value will be placed.
-*/
- void PutValue(in double theValue, in long theRow, in long theColumn) raises(IncorrectIndex);
-/*!
- Returns True if there is a value in the table.
- \param theRow The row containing the value
- \param theColumn The column containing the value
-*/
- boolean HasValue(in long theRow, in long theColumn);
-/*!
- Returns the value from the table.
- \param theRow The row containing the value
- \param theColumn The column containing the value
-*/
- double GetValue(in long theRow, in long theColumn) raises(IncorrectIndex);
+ <em>See \ref example22 for an example of usage of this attribute in batchmode of %SALOME application.</em>
-/*!
- Sets the max number of colums in the table.
- \note It'd better to set it before filling the table.
-*/
- void SetNbColumns(in long theNbColumns);
+ \sa AttributeTable, AttributeTableOfInteger, AttributeTableOfString
+ */
+ //==========================================================================
-/*!
- Returns the indices of the row where the values are defined.
-*/
- LongSeq GetRowSetIndices(in long theRow) raises(IncorrectIndex);
- // operations with files
-/*!
- Reads a table from a file.
-*/
- boolean ReadFromFile(in SALOMEDS::TMPFile theStream);
-/*!
- Saves a table into a file.
-*/
- SALOMEDS::TMPFile SaveToFile();
+ interface AttributeTableOfReal : AttributeTable
+ {
+ /*!
+ \brief Appends new row to the table.
+
+ If the length of the \a data parameter is greater than current number of columns
+ in the table, the table is automatically resized.
+
+ \param data sequence of values which will be set as elements of the added row
+ \sa SetRow(), GetRow(), AddColumn()
+ */
+ void AddRow(in DoubleSeq data) raises(IncorrectArgumentLength);
+ /*!
+ \brief Replaces all the elements of the specified \a row with new values.
+
+ Raises an exception if \a row is out of range or if the length of the
+ \a data parameter is not equal to the number of columns in the table.
+
+ \param row row index
+ \param data sequence of values being set as values of the row
+ \sa GetRow(), AddRow(), SetColumn()
+ */
+ void SetRow(in long row, in DoubleSeq data) raises(IncorrectArgumentLength, IncorrectIndex);
+ /*!
+ \brief Returns all the values of the specified row in the table.
+
+ Raises an exception if \a row is out of range.
+
+ \note For empty cells 0.0 value is returned.
+
+ \param row row index
+ \return sequence of values which are set as elements of the row.
+ \sa SetRow(), AddRow()
+ */
+ DoubleSeq GetRow(in long row) raises(IncorrectIndex);
+ /*!
+ \brief Appends new column to the table.
+
+ If the length of the \a data parameter is greater than current number of rows
+ in the table, the table is automatically resized.
+
+ \param data sequence of values which will be set as elements of the added column
+ \sa SetColumn(), GetColumn(), AddRow()
+ */
+ void AddColumn(in DoubleSeq data) raises(IncorrectArgumentLength);
+ /*!
+ \brief Replaces all the elements of the specified column with new values.
+
+ Raises an exception if \a column is out of range or if the length of the
+ \a data parameter is not equal to the number of rows in the table.
+
+ \param column column index
+ \param data sequence of values being set as values of the column
+ \sa GetColumn(), AddColumn(), SetRow()
+ */
+ void SetColumn(in long column, in DoubleSeq data) raises(IncorrectArgumentLength, IncorrectIndex);
+ /*!
+ \brief Returns all the values of the specified column in the table.
+
+ Raises an exception if \a column is out of range.
+
+ \note For empty cells 0.0 value is returned.
+
+ \param column column index
+ \return sequence of values which are set as elements of the column.
+ \sa SetColumn(), AddColumn()
+ */
+ DoubleSeq GetColumn(in long column) raises(IncorrectIndex);
+ /*!
+ \brief Puts a value to the table cell specified by \a row and \a column indices.
+
+ If the \a row and/or \a column parameter(s) are greater than current number of rows/columns
+ in the table, the table is automatically resized.
+
+ \param value value being set to the table cell
+ \param row row index
+ \param column column index
+ \sa GetValue(), HasValue()
+ */
+ void PutValue(in double value, in long row, in long volumn) raises(IncorrectIndex);
+ /*!
+ \brief Returns the value from the cell table.
+
+ Raises an exception if \a row or \a column is out of range or
+ if value is not set for the specified table cell.
+
+ \param row row index
+ \param column column index
+ \return value assigned to the table cell
+ \sa PutValue(), HasValue()
+ */
+ double GetValue(in long row, in long column) raises(IncorrectIndex);
};
-
-
//==========================================================================
-/*! \brief %AttributeTableOfString interface
+ /*!
+ \brief Table of string values
- This attribute allows to store a table of strings (indexing from 1 like in CASCADE)
- and string titles of this table, of each row, of each column.
-<em>See \ref example21 for an example of usage of these methods in batchmode of %SALOME application.</em>
+ This attribute allows to store a table of string values. It is possible
+ to specify titles for rows and columns. In addition, the unis labels can be
+ assigned to the rows. And finally, the table iself can have title.
-*/
+ \note The indices of rows and columns in the table start from 1.
+ \sa AttributeTable, AttributeTableOfInteger, AttributeTableOfReal
+ */
//==========================================================================
-
- interface AttributeTableOfString : GenericAttribute
+ interface AttributeTableOfString : AttributeTable
{
-//! This exception is raised when an incorrect index is passed as parameter.
- exception IncorrectIndex {};
-//! This exception is raised when an incorrect length of the argument is passed as parameter.
- exception IncorrectArgumentLength {};
-
- // titles: for table, for each row, for each column
-/*!
- Sets the title of the table.
-*/
- void SetTitle(in string theTitle);
-/*!
- Returns the title of the table.
-*/
- string GetTitle();
-/*!
- Sets the title of a row with a definite index.
-*/
- void SetRowTitle(in long theIndex, in string theTitle) raises(IncorrectIndex);
-/*!
- Sets the titles for all rows of the table.
-*/
- void SetRowTitles(in StringSeq theTitles) raises(IncorrectArgumentLength);
-/*!
- Returns the titles of all rows of the table.
-*/
- StringSeq GetRowTitles();
-/*!
- Sets the title of a column with a definite index.
-*/
- void SetColumnTitle(in long theIndex, in string theTitle) raises(IncorrectIndex);
-/*!
- Sets the titles for all columns of the table.
-*/
- void SetColumnTitles(in StringSeq theTitles) raises(IncorrectArgumentLength);
-/*!
- Returns the titles of all columns of the table.
-*/
- StringSeq GetColumnTitles();
-
- //Rows units
-/*!
- Sets the unit of a row with a definite index.
-*/
- void SetRowUnit(in long theIndex, in string theUnit) raises(IncorrectIndex);
-/*!
- Sets the units for all rows of the table.
-*/
- void SetRowUnits(in StringSeq theUnits) raises(IncorrectArgumentLength);
-/*!
- Returns the units of all rows of the table.
-*/
- StringSeq GetRowUnits();
-
- // table information
-/*!
- Returns the number of rows of the table.
-*/
- long GetNbRows();
-/*!
- Returns the number of columns of the table.
-*/
- long GetNbColumns();
-
- // operations with rows
-/*!
- Adds a row to the end of the table.
-*/
- void AddRow(in StringSeq theData) raises(IncorrectArgumentLength);
-/*!
- Sets the values of all elements of the row.
-*/
- void SetRow(in long theRow, in StringSeq theData) raises(IncorrectArgumentLength, IncorrectIndex);
-/*!
- Returns the row of the table.
-*/
- StringSeq GetRow(in long theRow) raises(IncorrectIndex);
-
- // operations with columns
-/*!
- Adds a column to the end of the table.
-*/
- void AddColumn(in StringSeq theData) raises(IncorrectArgumentLength);
-/*!
- Sets the values of all elements of the column.
-*/
- void SetColumn(in long theColumn, in StringSeq theData) raises(IncorrectArgumentLength, IncorrectIndex);
-/*!
- Returns the column of the table.
-*/
- StringSeq GetColumn(in long theColumn) raises(IncorrectIndex);
-
- // operations with elements
-/*!
- Puts a value in the table.
- \param theRow The row, where the value will be placed.
- \param theColumn The column, where the value will be placed.
-*/
- void PutValue(in string theValue, in long theRow, in long theColumn) raises(IncorrectIndex);
-/*!
- Returns True if there is a value in the table.
- \param theRow The row containing the value
- \param theColumn The column containing the value
-*/
- boolean HasValue(in long theRow, in long theColumn);
-/*!
- Returns the value from the table.
- \param theRow The row containing the value
- \param theColumn The column containing the value
-*/
- string GetValue(in long theRow, in long theColumn) raises(IncorrectIndex);
-
-/*!
- Sets the max number of colums in the table.
- \note It'd better to set it before filling the table.
-*/
- void SetNbColumns(in long theNbColumns);
-
-/*!
- Returns the indices of the row where the values are defined.
-*/
- LongSeq GetRowSetIndices(in long theRow) raises(IncorrectIndex);
- // operations with files
-/*!
- Reads a table from a file.
-*/
- boolean ReadFromFile(in SALOMEDS::TMPFile theStream);
-/*!
- Saves a table into a file.
-*/
- SALOMEDS::TMPFile SaveToFile();
+ /*!
+ \brief Appends new row to the table.
+
+ If the length of the \a data parameter is greater than current number of columns
+ in the table, the table is automatically resized.
+
+ \param data sequence of values which will be set as elements of the added row
+ \sa SetRow(), GetRow(), AddColumn()
+ */
+ void AddRow(in StringSeq data) raises(IncorrectArgumentLength);
+ /*!
+ \brief Replaces all the elements of the specified \a row with new values.
+
+ Raises an exception if \a row is out of range or if the length of the
+ \a data parameter is not equal to the number of columns in the table.
+
+ \param row row index
+ \param data sequence of values being set as values of the row
+ \sa GetRow(), AddRow(), SetColumn()
+ */
+ void SetRow(in long row, in StringSeq data) raises(IncorrectArgumentLength, IncorrectIndex);
+ /*!
+ \brief Returns all the values of the specified row in the table.
+
+ Raises an exception if \a row is out of range.
+
+ \note For empty cells empty string is returned.
+
+ \param row row index
+ \return sequence of values which are set as elements of the row.
+ \sa SetRow(), AddRow()
+ */
+ StringSeq GetRow(in long row) raises(IncorrectIndex);
+ /*!
+ \brief Appends new column to the table.
+
+ If the length of the \a data parameter is greater than current number of rows
+ in the table, the table is automatically resized.
+
+ \param data sequence of values which will be set as elements of the added column
+ \sa SetColumn(), GetColumn(), AddRow()
+ */
+ void AddColumn(in StringSeq data) raises(IncorrectArgumentLength);
+ /*!
+ \brief Replaces all the elements of the specified column with new values.
+
+ Raises an exception if \a column is out of range or if the length of the
+ \a data parameter is not equal to the number of rows in the table.
+
+ \param column column index
+ \param data sequence of values being set as values of the column
+ \sa GetColumn(), AddColumn(), SetRow()
+ */
+ void SetColumn(in long column, in StringSeq data) raises(IncorrectArgumentLength, IncorrectIndex);
+ /*!
+ \brief Returns all the values of the specified column in the table.
+
+ Raises an exception if \a column is out of range.
+
+ \note For empty cells empty string is returned.
+
+ \param column column index
+ \return sequence of values which are set as elements of the column.
+ \sa SetColumn(), AddColumn()
+ */
+ StringSeq GetColumn(in long column) raises(IncorrectIndex);
+ /*!
+ \brief Puts a value to the table cell specified by \a row and \a column indices.
+
+ If the \a row and/or \a column parameter(s) are greater than current number of rows/columns
+ in the table, the table is automatically resized.
+
+ \param value value being set to the table cell
+ \param row row index
+ \param column column index
+ \sa GetValue(), HasValue()
+ */
+ void PutValue(in string value, in long row, in long column) raises(IncorrectIndex);
+ /*!
+ \brief Returns the value from the cell table.
+
+ Raises an exception if \a row or \a column is out of range or
+ if value is not set for the specified table cell.
+
+ \param row row index
+ \param column column index
+ \return value assigned to the table cell
+ \sa PutValue(), HasValue()
+ */
+ string GetValue(in long row, in long column) raises(IncorrectIndex);
};
-
//==========================================================================
/*! \brief %AttributeStudyProperties interface
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfInteger.cxx
// Author : Sergey RUIN
// Module : SALOME
#include "SALOMEDS_AttributeTableOfInteger.hxx"
#include "SALOMEDS.hxx"
-using namespace std;
-
SALOMEDS_AttributeTableOfInteger::SALOMEDS_AttributeTableOfInteger
(SALOMEDSImpl_AttributeTableOfInteger* theAttr)
:SALOMEDS_GenericAttribute(theAttr)
else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
}
+std::string SALOMEDS_AttributeTableOfInteger::GetRowTitle(int theIndex)
+{
+ std::string aTitle;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowTitle(theIndex);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ aTitle = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowTitle(theIndex);
+ }
+ return aTitle;
+}
+
void SALOMEDS_AttributeTableOfInteger::SetRowTitles(const std::vector<std::string>& theTitles)
{
int aLength = theTitles.size(), i;
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);
}
else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
}
+std::string SALOMEDS_AttributeTableOfInteger::GetColumnTitle(int theIndex)
+{
+ std::string aTitle;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetColumnTitle(theIndex);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ aTitle = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetColumnTitle(theIndex);
+ }
+ return aTitle;
+}
+
void SALOMEDS_AttributeTableOfInteger::SetColumnTitles(const std::vector<std::string>& theTitles)
{
int aLength = theTitles.size(), i;
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);
}
else SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
}
+std::string SALOMEDS_AttributeTableOfInteger::GetRowUnit(int theIndex)
+{
+ std::string aTitle;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetRowUnit(theIndex);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ aTitle = SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->GetRowUnit(theIndex);
+ }
+ return aTitle;
+}
+
void SALOMEDS_AttributeTableOfInteger::SetRowUnits(const std::vector<std::string>& theUnits)
{
int aLength = theUnits.size(), i;
aTable->SetRowData(aTable->GetNbRows() + 1, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
aTable->SetRowData(theRow, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
aTable->SetColumnData(theColumn, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->PutValue(theValue, theRow, theColumn);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
}
}
else {
aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->GetValue(theRow, theColumn);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
}
}
else {
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);
}
+
+std::vector<int> SALOMEDS_AttributeTableOfInteger::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfInteger::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfInteger::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortByRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortByRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfInteger::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_local_impl)->SortByColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfInteger::_narrow(_corba_impl)->SortByColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+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);
+ }
+}
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfInteger.hxx
// Author : Sergey RUIN
// Module : SALOME
virtual void SetTitle(const std::string& theTitle);
virtual std::string GetTitle();
virtual void SetRowTitle(int theIndex, const std::string& theTitle);
+ virtual std::string GetRowTitle(int theIndex);
virtual void SetRowTitles(const std::vector<std::string>& theTitles);
virtual std::vector<std::string> GetRowTitles();
virtual void SetColumnTitle(int theIndex, const std::string& theTitle);
+ virtual std::string GetColumnTitle(int theIndex);
virtual void SetColumnTitles(const std::vector<std::string>& theTitles);
virtual std::vector<std::string> GetColumnTitles();
virtual void SetRowUnit(int theIndex, const std::string& theUnit);
+ virtual std::string GetRowUnit(int theIndex);
virtual void SetRowUnits(const std::vector<std::string>& theUnits);
virtual std::vector<std::string> GetRowUnits();
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 std::vector<int> SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual std::vector<int> SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy);
+ virtual std::vector<int> SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual std::vector<int> 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
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfInteger_i.cxx
// Author : Sergey RUIN
// Module : SALOME
#include <string>
#include <vector>
-using namespace std;
-
-UNEXPECT_CATCH(ATI_IncorrectIndex, SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
-UNEXPECT_CATCH(ATI_IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength);
+UNEXPECT_CATCH(ATI_IncorrectIndex, SALOMEDS::AttributeTable::IncorrectIndex);
+UNEXPECT_CATCH(ATI_IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectArgumentLength);
void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle)
{
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()
}
void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch (ATI_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
+ if (theIndex < 1 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ aTable->SetRowTitle(theIndex, std::string(theTitle));
+}
+
+char* SALOMEDS_AttributeTableOfInteger_i::GetRowTitle(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
- aTable->SetRowTitle(theIndex, string(theTitle));
+ 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();
}
void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch (ATI_IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
SetRowTitle(i + 1, theTitles[i]);
}
}
void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::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)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch (ATI_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
+ 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();
}
void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
aTable->SetColumnTitle(i + 1, (char*)theTitles[i].in());
}
//Units support
void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch (ATI_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::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)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch (ATI_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
+ 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();
}
void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch (ATI_IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
for (int i = 0; i < theUnits.length(); i++) {
aTable->SetRowUnit(i + 1, (char*)theUnits[i].in());
}
}
void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectArgumentLength);
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);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectArgumentLength);
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);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::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];
}
void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theData)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectArgumentLength);
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);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectArgumentLength);
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);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::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];
}
void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
aTable->PutValue(theValue, theRow, theColumn);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
}
}
}
CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATI_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfInteger* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfInteger*>(_impl);
- if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::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 {
aValue = aTable->GetValue(theRow, theColumn);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex();
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
}
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::AttributeTableOfInteger::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();
}
+SALOMEDS::LongSeq* 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();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+SALOMEDS::LongSeq* SALOMEDS_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();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+SALOMEDS::LongSeq* SALOMEDS_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();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+SALOMEDS::LongSeq* 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();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+void SALOMEDS_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();
+ }
+}
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfInteger_i.hxx
// Author : Sergey RUIN
// Module : SALOME
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 void SetTitle(const char* theTitle);
virtual char* GetTitle();
virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual char* GetRowTitle(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void SetRowTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual SALOMEDS::StringSeq* GetRowTitles();
virtual void SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual char* GetColumnTitle(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual SALOMEDS::StringSeq* GetColumnTitles();
virtual void SetRowUnit(CORBA::Long theIndex, const char* theUnit)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual char* GetRowUnit(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void SetRowUnits(const SALOMEDS::StringSeq& theUnits)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual SALOMEDS::StringSeq* GetRowUnits();
virtual CORBA::Long GetNbRows();
virtual CORBA::Long GetNbColumns();
virtual void AddRow(const SALOMEDS::LongSeq& theData)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual void SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex);
virtual SALOMEDS::LongSeq* GetRow(CORBA::Long theRow)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void AddColumn(const SALOMEDS::LongSeq& theData)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual void SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex);
virtual SALOMEDS::LongSeq* GetColumn(CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual CORBA::Boolean HasValue(CORBA::Long theRow, CORBA::Long theColumn);
virtual CORBA::Long GetValue(CORBA::Long theRow, CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex);
+ 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 SALOMEDS::LongSeq* SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual SALOMEDS::LongSeq* SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual SALOMEDS::LongSeq* SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual SALOMEDS::LongSeq* 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();
};
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfReal.cxx
// Author : Sergey RUIN
// Module : SALOME
#include "SALOMEDS_AttributeTableOfReal.hxx"
#include "SALOMEDS.hxx"
-using namespace std;
-
SALOMEDS_AttributeTableOfReal::SALOMEDS_AttributeTableOfReal
(SALOMEDSImpl_AttributeTableOfReal* theAttr)
:SALOMEDS_GenericAttribute(theAttr)
else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
}
+std::string SALOMEDS_AttributeTableOfReal::GetRowTitle(int theIndex)
+{
+ std::string aTitle;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowTitle(theIndex);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ aTitle = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowTitle(theIndex);
+ }
+ return aTitle;
+}
+
void SALOMEDS_AttributeTableOfReal::SetRowTitles(const std::vector<std::string>& theTitles)
{
CheckLocked();
else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
}
+std::string SALOMEDS_AttributeTableOfReal::GetColumnTitle(int theIndex)
+{
+ std::string aTitle;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetColumnTitle(theIndex);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ aTitle = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetColumnTitle(theIndex);
+ }
+ return aTitle;
+}
+
void SALOMEDS_AttributeTableOfReal::SetColumnTitles(const std::vector<std::string>& theTitles)
{
int aLength = theTitles.size(), i;
else SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
}
+std::string SALOMEDS_AttributeTableOfReal::GetRowUnit(int theIndex)
+{
+ std::string aTitle;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetRowUnit(theIndex);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ aTitle = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnit(theIndex);
+ }
+ return aTitle;
+}
+
void SALOMEDS_AttributeTableOfReal::SetRowUnits(const std::vector<std::string>& theUnits)
{
int aLength = theUnits.size(), i;
else {
SALOMEDS::StringSeq_var aSeq = SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->GetRowUnits();
aLength = aSeq->length();
- for (i = 0; i < aLength; i++) aVector.push_back(string(aSeq[i].in()));
+ for (i = 0; i < aLength; i++) aVector.push_back(std::string(aSeq[i].in()));
}
return aVector;
}
aTable->SetRowData(aTable->GetNbRows() + 1, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
aTable->SetRowData(theRow, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
aTable->SetColumnData(theColumn, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->PutValue(theValue, theRow, theColumn);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
}
}
else {
aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->GetValue(theRow, theColumn);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
}
}
else {
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);
}
+
+std::vector<int> SALOMEDS_AttributeTableOfReal::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfReal::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfReal::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortByRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortByRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfReal::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_local_impl)->SortByColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfReal::_narrow(_corba_impl)->SortByColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+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);
+ }
+}
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfReal.hxx
// Author : Sergey RUIN
// Module : SALOME
virtual void SetTitle(const std::string& theTitle);
virtual std::string GetTitle();
virtual void SetRowTitle(int theIndex, const std::string& theTitle);
+ virtual std::string GetRowTitle(int theIndex);
virtual void SetRowTitles(const std::vector<std::string>& theTitles);
virtual std::vector<std::string> GetRowTitles();
virtual void SetColumnTitle(int theIndex, const std::string& theTitle);
+ virtual std::string GetColumnTitle(int theIndex);
virtual void SetColumnTitles(const std::vector<std::string>& theTitles);
virtual std::vector<std::string> GetColumnTitles();
virtual void SetRowUnit(int theIndex, const std::string& theUnit);
+ virtual std::string GetRowUnit(int theIndex);
virtual void SetRowUnits(const std::vector<std::string>& theUnits);
virtual std::vector<std::string> GetRowUnits();
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 std::vector<int> SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual std::vector<int> SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy);
+ virtual std::vector<int> SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual std::vector<int> 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
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfReal_i.cxx
// Author : Sergey RUIN
// Module : SALOME
#include <string>
#include <vector>
-using namespace std;
-
#include "Utils_ExceptHandlers.hxx"
-UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTableOfReal::IncorrectIndex);
-UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength);
+UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTable::IncorrectIndex);
+UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectArgumentLength);
void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle)
{
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()
}
void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch (ATR_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
- aTable->SetRowTitle(theIndex, string(theTitle));
+ if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ aTable->SetRowTitle(theIndex, std::string(theTitle));
+}
+
+char* SALOMEDS_AttributeTableOfReal_i::GetRowTitle(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch (ATR_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowTitle(theIndex).c_str());
+ return c_s._retn();
}
void SALOMEDS_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch (ATR_IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
aTable->SetRowTitle(i + 1, (char*)theTitles[i].in());
}
}
void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch (ATR_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
+ 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)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch (ATR_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ CORBA::String_var c_s = CORBA::string_dup(aTable->GetColumnTitle(theIndex).c_str());
+ return c_s._retn();
}
void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
for (int i = 0; i < theTitles.length(); i++) {
aTable->SetColumnTitle(i + 1, (char*)theTitles[i].in());
}
//Units support
void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch (ATR_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
- aTable->SetRowUnit(theIndex, string(theUnit));
+ if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ aTable->SetRowUnit(theIndex, std::string(theUnit));
+}
+
+char* SALOMEDS_AttributeTableOfReal_i::GetRowUnit(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch (ATR_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowUnit(theIndex).c_str());
+ return c_s._retn();
}
void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch (ATR_IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength();
+ if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
for (int i = 0; i < theUnits.length(); i++) {
aTable->SetRowUnit(i + 1, (char*)theUnits[i].in());
}
}
void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
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);
}
void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
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);
}
SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
+ 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];
}
void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theData)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
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);
}
void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectArgumentLength);
CheckLocked();
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);
}
SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
+ 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];
}
void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectIndex);
}
CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATR_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
+ if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
CORBA::Double aValue;
aValue = aTable->GetValue(theRow, theColumn);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
}
return aValue;
}
+void SALOMEDS_AttributeTableOfReal_i::RemoveValue(CORBA::Long theRow, CORBA::Long theColumn)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATR_IncorrectIndex);
+ SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<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)
{
SALOMEDS::Locker lock;
SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
- if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex();
+ if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
- 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();
}
+
+SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortRow(CORBA::Long theRow,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATR_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortColumn(CORBA::Long theColumn,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATR_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortByRow(CORBA::Long theRow,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATR_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theRow < 1 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::SortByColumn(CORBA::Long theColumn,
+ SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATR_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfReal*>(_impl);
+ if (theColumn < 1 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+void SALOMEDS_AttributeTableOfReal_i::SwapCells(CORBA::Long theRow1, CORBA::Long theColumn1,
+ CORBA::Long theRow2, CORBA::Long theColumn2)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch(ATR_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfReal* aTable = dynamic_cast<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();
+ }
+}
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfReal_i.hxx
// Author : Michael Ponikarov
// Module : SALOME
#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::AttributeTableOfReal::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual char* GetRowTitle(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void SetRowTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual SALOMEDS::StringSeq* GetRowTitles();
virtual void SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual char* GetColumnTitle(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual SALOMEDS::StringSeq* GetColumnTitles();
virtual void SetRowUnit(CORBA::Long theIndex, const char* theUnit)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual char* GetRowUnit(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void SetRowUnits(const SALOMEDS::StringSeq& theUnits)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual SALOMEDS::StringSeq* GetRowUnits();
virtual CORBA::Long GetNbRows();
virtual CORBA::Long GetNbColumns();
virtual void AddRow(const SALOMEDS::DoubleSeq& theData)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual void SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex);
virtual SALOMEDS::DoubleSeq* GetRow(CORBA::Long theRow)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void AddColumn(const SALOMEDS::DoubleSeq& theData)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual void SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex);
virtual SALOMEDS::DoubleSeq* GetColumn(CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex);
+ 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::AttributeTableOfReal::IncorrectIndex);
+ 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 SALOMEDS::LongSeq* SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual SALOMEDS::LongSeq* SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual SALOMEDS::LongSeq* SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual SALOMEDS::LongSeq* 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();
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfString.cxx
// Author : Sergey RUIN
// Module : SALOME
#include <string>
-using namespace std;
-
SALOMEDS_AttributeTableOfString::SALOMEDS_AttributeTableOfString
(SALOMEDSImpl_AttributeTableOfString* theAttr)
:SALOMEDS_GenericAttribute(theAttr)
else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowTitle(theIndex, theTitle.c_str());
}
+std::string SALOMEDS_AttributeTableOfString::GetRowTitle(int theIndex)
+{
+ std::string aTitle;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowTitle(theIndex);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ aTitle = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowTitle(theIndex);
+ }
+ return aTitle;
+}
+
void SALOMEDS_AttributeTableOfString::SetRowTitles(const std::vector<std::string>& theTitles)
{
int aLength = theTitles.size(), i;
else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetColumnTitle(theIndex, theTitle.c_str());
}
+std::string SALOMEDS_AttributeTableOfString::GetColumnTitle(int theIndex)
+{
+ std::string aTitle;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetColumnTitle(theIndex);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ aTitle = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetColumnTitle(theIndex);
+ }
+ return aTitle;
+}
+
void SALOMEDS_AttributeTableOfString::SetColumnTitles(const std::vector<std::string>& theTitles)
{
int aLength = theTitles.size(), i;
else SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SetRowUnit(theIndex, theUnit.c_str());
}
+std::string SALOMEDS_AttributeTableOfString::GetRowUnit(int theIndex)
+{
+ std::string aTitle;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aTitle = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetRowUnit(theIndex);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ aTitle = SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->GetRowUnit(theIndex);
+ }
+ return aTitle;
+}
+
void SALOMEDS_AttributeTableOfString::SetRowUnits(const std::vector<std::string>& theUnits)
{
int aLength = theUnits.size(), i;
aTable->SetRowData(aTable->GetNbRows() + 1, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
aTable->SetRowData(theRow, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
aTable->SetColumnData(aTable->GetNbColumns() + 1, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
aTable->SetColumnData(theColumn, theData);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ throw SALOMEDS::AttributeTable::IncorrectArgumentLength();
}
}
else {
dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->PutValue(theValue, theRow, theColumn);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
}
}
else {
aValue = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->GetValue(theRow, theColumn);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
}
}
else {
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);
}
+
+std::vector<int> SALOMEDS_AttributeTableOfString::SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfString::SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfString::SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortByRow(theRow,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortByRow(theRow,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+std::vector<int> SALOMEDS_AttributeTableOfString::SortByColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy)
+{
+ std::vector<int> aVector;
+ int aLength, i;
+ if (_isLocal) {
+ SALOMEDS::Locker lock;
+ try {
+ aVector = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_local_impl)->SortByColumn(theColumn,
+ (SALOMEDSImpl_AttributeTable::SortOrder)theOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)thePolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ }
+ else {
+ SALOMEDS::LongSeq_var aSet =
+ SALOMEDS::AttributeTableOfString::_narrow(_corba_impl)->SortByColumn(theColumn,
+ (SALOMEDS::AttributeTable::SortOrder)theOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)thePolicy);
+ aLength = aSet->length();
+ for (i = 0; i < aLength; i++) aVector.push_back(aSet[i]);
+ }
+ return aVector;
+}
+
+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);
+ }
+}
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfString.hxx
// Author : Sergey RUIN
// Module : SALOME
virtual void SetTitle(const std::string& theTitle);
virtual std::string GetTitle();
virtual void SetRowTitle(int theIndex, const std::string& theTitle);
+ virtual std::string GetRowTitle(int theIndex);
virtual void SetRowTitles(const std::vector<std::string>& theTitles);
virtual std::vector<std::string> GetRowTitles();
virtual void SetColumnTitle(int theIndex, const std::string& theTitle);
+ virtual std::string GetColumnTitle(int theIndex);
virtual void SetColumnTitles(const std::vector<std::string>& theTitles);
virtual std::vector<std::string> GetColumnTitles();
virtual void SetRowUnit(int theIndex, const std::string& theUnit);
+ virtual std::string GetRowUnit(int theIndex);
virtual void SetRowUnits(const std::vector<std::string>& theUnits);
virtual std::vector<std::string> GetRowUnits();
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 std::vector<int> SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual std::vector<int> SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy);
+ virtual std::vector<int> SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy);
+ virtual std::vector<int> 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
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfString_i.cxx
// Author : Sergey RUIN
// Module : SALOME
#include "Utils_ExceptHandlers.hxx"
-using namespace std;
-
-UNEXPECT_CATCH(ATS_IncorrectIndex, SALOMEDS::AttributeTableOfString::IncorrectIndex);
-UNEXPECT_CATCH(ATS_IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectArgumentLength);
+UNEXPECT_CATCH(ATS_IncorrectIndex, SALOMEDS::AttributeTable::IncorrectIndex);
+UNEXPECT_CATCH(ATS_IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectArgumentLength);
void SALOMEDS_AttributeTableOfString_i::SetTitle(const char* theTitle)
{
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()
}
void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
+ 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)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch (ATS_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
+ if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowTitle(theIndex).c_str());
+ return c_s._retn();
}
void SALOMEDS_AttributeTableOfString_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ 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()));
}
}
}
void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
- aTable->SetColumnTitle(theIndex, string((char*)theTitle));
+ if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ aTable->SetColumnTitle(theIndex, std::string((char*)theTitle));
+}
+
+char* SALOMEDS_AttributeTableOfString_i::GetColumnTitle(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch (ATS_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
+ if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ CORBA::String_var c_s = CORBA::string_dup(aTable->GetColumnTitle(theIndex).c_str());
+ return c_s._retn();
}
void SALOMEDS_AttributeTableOfString_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ 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()));
}
}
//Units support
void SALOMEDS_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
- aTable->SetRowUnit(theIndex, string((char*)theUnit));
+ if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ aTable->SetRowUnit(theIndex, std::string((char*)theUnit));
+}
+
+char* SALOMEDS_AttributeTableOfString_i::GetRowUnit(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
+{
+ SALOMEDS::Locker lock;
+ Unexpect aCatch (ATS_IncorrectIndex);
+ CheckLocked();
+ SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
+ if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
+ CORBA::String_var c_s = CORBA::string_dup(aTable->GetRowUnit(theIndex).c_str());
+ return c_s._retn();
}
void SALOMEDS_AttributeTableOfString_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
CheckLocked();
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength();
+ 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()));
}
}
}
void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theData)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
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);
}
void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMEDS::StringSeq& theData)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
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);
}
SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRow)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
+ 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());
}
void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& theData)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
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);
}
void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::StringSeq& theData)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectArgumentLength);
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);
}
SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
+ 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());
}
void SALOMEDS_AttributeTableOfString_i::PutValue(const char* theValue, CORBA::Long theRow, CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
}
char* SALOMEDS_AttributeTableOfString_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex)
{
SALOMEDS::Locker lock;
Unexpect aCatch(ATS_IncorrectIndex);
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
+ if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTable::IncorrectIndex();
- string aValue;
+ std::string aValue;
try {
aValue = aTable->GetValue(theRow, theColumn);
}
catch(...) {
- throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
}
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)
{
SALOMEDS::Locker lock;
SALOMEDSImpl_AttributeTableOfString* aTable = dynamic_cast<SALOMEDSImpl_AttributeTableOfString*>(_impl);
- if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex();
+ 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();
}
+SALOMEDS::LongSeq* 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();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+SALOMEDS::LongSeq* SALOMEDS_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();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+SALOMEDS::LongSeq* SALOMEDS_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();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortByRow(theRow, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+SALOMEDS::LongSeq* 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();
+
+ std::vector<int> aSeq;
+ SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq;
+ try {
+ aSeq = aTable->SortByColumn(theColumn, (SALOMEDSImpl_AttributeTable::SortOrder)sortOrder,
+ (SALOMEDSImpl_AttributeTable::SortPolicy)sortPolicy);
+ }
+ catch(...) {
+ throw SALOMEDS::AttributeTable::IncorrectIndex();
+ }
+ CorbaSeq->length(aSeq.size());
+ for (int i = 0; i < aSeq.size(); i++) {
+ CorbaSeq[i] = aSeq[i];
+ }
+ return CorbaSeq._retn();
+}
+
+void SALOMEDS_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();
+ }
+}
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDS_AttributeTableOfString_i.hxx
// Author : Sergey RUIN
// Module : SALOME
virtual void SetTitle(const char* theTitle);
virtual char* GetTitle();
virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual char* GetRowTitle(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void SetRowTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual SALOMEDS::StringSeq* GetRowTitles();
virtual void SetColumnTitle(CORBA::Long theIndex, const char* theTitle)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual char* GetColumnTitle(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void SetColumnTitles(const SALOMEDS::StringSeq& theTitles)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual SALOMEDS::StringSeq* GetColumnTitles();
virtual void SetRowUnit(CORBA::Long theIndex, const char* theUnit)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual char* GetRowUnit(CORBA::Long theIndex)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void SetRowUnits(const SALOMEDS::StringSeq& theUnits)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual SALOMEDS::StringSeq* GetRowUnits();
virtual CORBA::Long GetNbRows();
virtual CORBA::Long GetNbColumns();
virtual void AddRow(const SALOMEDS::StringSeq& theData)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual void SetRow(CORBA::Long theRow, const SALOMEDS::StringSeq& theData)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex);
virtual SALOMEDS::StringSeq* GetRow(CORBA::Long theRow)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void AddColumn(const SALOMEDS::StringSeq& theData)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength);
virtual void SetColumn(CORBA::Long theColumn, const SALOMEDS::StringSeq& theData)
- throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectArgumentLength, SALOMEDS::AttributeTable::IncorrectIndex);
virtual SALOMEDS::StringSeq* GetColumn(CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex);
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
virtual void PutValue(const char* theValue, CORBA::Long theRow, CORBA::Long theColumn)
- throw (SALOMEDS::AttributeTableOfString::IncorrectIndex);
+ 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::AttributeTableOfString::IncorrectIndex);
+ 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 SALOMEDS::LongSeq* SortRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual SALOMEDS::LongSeq* SortColumn(CORBA::Long theColumn, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual SALOMEDS::LongSeq* SortByRow(CORBA::Long theRow, SALOMEDS::AttributeTable::SortOrder sortOrder,
+ SALOMEDS::AttributeTable::SortPolicy sortPolicy)
+ throw (SALOMEDS::AttributeTable::IncorrectIndex);
+ virtual SALOMEDS::LongSeq* 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-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 std::vector<int> SortRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) = 0;
+ virtual std::vector<int> SortColumn(int theColumn, SortOrder theOrder, SortPolicy thePolicy) = 0;
+ virtual std::vector<int> SortByRow(int theRow, SortOrder theOrder, SortPolicy thePolicy) = 0;
+ virtual std::vector<int> 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
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDSClient_AttributeTableOfInteger.hxx
// Author : Sergey RUIN
// Module : SALOME
#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 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 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 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
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDSClient_AttributeTableOfReal.hxx
// Author : Michael Ponikarov
// Module : SALOME
#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 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 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 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
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDSClient_AttributeTableOfString.hxx
// Author : Sergey RUIN
// Module : SALOME
#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 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 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 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-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDSImpl_AttributeTableOfInteger.cxx
// 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())
}
void SALOMEDSImpl_AttributeTableOfInteger::SetRowTitle(const int theRow,
- const std::string& theTitle)
+ const std::string& theTitle)
{
CheckLocked();
Backup();
- string aTitle(theTitle), aUnit = GetRowUnit(theRow);
+ std::string aTitle(theTitle), aUnit = GetRowUnit(theRow);
if(aUnit.size()>0) {
aTitle += SEPARATOR;
aTitle += aUnit;
}
void SALOMEDSImpl_AttributeTableOfInteger::SetRowUnit(const int theRow,
- const std::string& theUnit)
+ const std::string& theUnit)
{
CheckLocked();
Backup();
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();
+ CheckLocked();
Backup();
while(myCols.size() < theColumn) myCols.push_back(std::string(""));
myCols[theColumn-1] = theTitle;
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;
}
void SALOMEDSImpl_AttributeTableOfInteger::PutValue(const int theValue,
- const int theRow,
- const int theColumn)
+ const int theRow,
+ const int theColumn)
{
CheckLocked();
+ //Backup();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
int anIndex = (theRow-1)*myNbColumns + theColumn;
}
bool SALOMEDSImpl_AttributeTableOfInteger::HasValue(const int theRow,
- const int theColumn)
+ const int theColumn)
{
if(theRow > myNbRows || theRow < 1) return false;
if(theColumn > myNbColumns || theColumn < 1) return false;
}
int SALOMEDSImpl_AttributeTableOfInteger::GetValue(const int theRow,
- const int 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;
}
}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfInteger::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfInteger::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfInteger::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfInteger::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+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);
+ // swap row titles
+ std::string tmp = myRows[theRow1-1];
+ myRows[theRow1-1] = myRows[theRow2-1];
+ myRows[theRow2-1] = tmp;
+ // 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);
+ // swap column titles
+ std::string tmp = myCols[theColumn1-1];
+ myCols[theColumn1-1] = myCols[theColumn2-1];
+ myCols[theColumn2-1] = tmp;
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+}
+
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server
// File : SALOMEDSImpl_AttributeTableOfInteger.hxx
// Author : Michael Ponikarov
#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);
- 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);
+ 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);
+ std::vector<int> SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ std::vector<int> SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy);
+ std::vector<int> SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ std::vector<int> 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_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
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDSImpl_AttributeTableOfReal.cxx
// Author : Michael Ponikarov
// Module : SALOME
//
#include "SALOMEDSImpl_AttributeTableOfReal.hxx"
-#include <stdio.h>
-#include <sstream>
-using namespace std;
+#include <sstream>
+#include <algorithm>
#define SEPARATOR '\1'
+typedef std::map<int, double>::const_iterator MI;
-typedef map<int, double>::const_iterator MI;
-
-static std::string getUnit(std::string theString)
+static std::string getUnit(const std::string& theString)
{
std::string aString(theString);
int aPos = aString.find(SEPARATOR);
- if(aPos <= 0 || aPos == aString.size() ) return std::string();
- return aString.substr(aPos+1, aString.size());
+ return aPos < 0 || aPos == aString.size()-1 ? std::string() : aString.substr(aPos+1, aString.size());
}
-static std::string getTitle(std::string theString)
+static std::string getTitle(const std::string& theString)
{
std::string aString(theString);
int aPos = aString.find(SEPARATOR);
- if(aPos < 0) return aString;
- if(aPos == 0) return std::string();
- return aString.substr(0, aPos);
+ return aPos < 0 ? aString :aString.substr(0, aPos);
}
const std::string& SALOMEDSImpl_AttributeTableOfReal::GetID()
CheckLocked();
Backup();
- map<int, double> aMap;
+ std::map<int, double> aMap;
aMap = myTable;
myTable.clear();
myNbColumns = theNbColumns;
while (myCols.size() < myNbColumns) { // append empty columns titles
- myCols.push_back(string(""));
+ myCols.push_back(std::string(""));
}
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
void SALOMEDSImpl_AttributeTableOfReal::SetRowData(const int theRow,
- const vector<double>& theData)
+ const std::vector<double>& theData)
{
CheckLocked();
if(theData.size() > myNbColumns) SetNbColumns(theData.size());
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-vector<double> SALOMEDSImpl_AttributeTableOfReal::GetRowData(const int theRow)
+std::vector<double> SALOMEDSImpl_AttributeTableOfReal::GetRowData(const int theRow)
{
- vector<double> aSeq;
+ std::vector<double> aSeq;
int i, aShift = (theRow-1)*myNbColumns;
for(i = 1; i <= myNbColumns; i++) {
if(myTable.find(aShift+i) != myTable.end())
return aSeq;
}
-
void SALOMEDSImpl_AttributeTableOfReal::SetRowTitle(const int theRow,
- const std::string& theTitle)
+ const std::string& theTitle)
{
CheckLocked();
Backup();
}
void SALOMEDSImpl_AttributeTableOfReal::SetRowUnit(const int theRow,
- const std::string& theUnit)
+ const std::string& theUnit)
{
CheckLocked();
Backup();
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-void SALOMEDSImpl_AttributeTableOfReal::SetRowUnits(const vector<string>& theUnits)
+void SALOMEDSImpl_AttributeTableOfReal::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_AttributeTableOfReal::GetRowUnits()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfReal::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_AttributeTableOfReal::SetRowTitles(const vector<string>& theTitles)
+void SALOMEDSImpl_AttributeTableOfReal::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_AttributeTableOfReal::GetRowTitles()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfReal::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_AttributeTableOfReal::GetRowTitle(const int theRow) const
{
return getTitle(myRows[theRow-1]);
}
void SALOMEDSImpl_AttributeTableOfReal::SetColumnData(const int theColumn,
- const vector<double>& theData)
+ const std::vector<double>& theData)
{
CheckLocked();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
if(aLength > myNbRows) {
myNbRows = aLength;
while (myRows.size() < myNbRows) { // append empty row titles
- myRows.push_back(string(""));
+ myRows.push_back(std::string(""));
}
}
SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
}
-
-vector<double> SALOMEDSImpl_AttributeTableOfReal::GetColumnData(const int theColumn)
+std::vector<double> SALOMEDSImpl_AttributeTableOfReal::GetColumnData(const int theColumn)
{
- vector<double> aSeq;
+ std::vector<double> aSeq;
int i, anIndex;
for(i = 1; i <= myNbRows; i++) {
}
void SALOMEDSImpl_AttributeTableOfReal::SetColumnTitle(const int theColumn,
- const std::string& theTitle)
+ const std::string& theTitle)
{
CheckLocked();
Backup();
return myCols[theColumn-1];
}
-void SALOMEDSImpl_AttributeTableOfReal::SetColumnTitles(const vector<string>& theTitles)
+void SALOMEDSImpl_AttributeTableOfReal::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_AttributeTableOfReal::GetColumnTitles()
+std::vector<std::string> SALOMEDSImpl_AttributeTableOfReal::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;
}
void SALOMEDSImpl_AttributeTableOfReal::PutValue(const double& theValue,
- const int theRow,
- const int theColumn)
+ const int theRow,
+ const int theColumn)
{
CheckLocked();
+ //Backup();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
int anIndex = (theRow-1)*myNbColumns + theColumn;
}
bool SALOMEDSImpl_AttributeTableOfReal::HasValue(const int theRow,
- const int theColumn)
+ const int theColumn)
{
if(theRow > myNbRows || theRow < 1) return false;
if(theColumn > myNbColumns || theColumn < 1) return false;
}
double SALOMEDSImpl_AttributeTableOfReal::GetValue(const int theRow,
- const int theColumn)
+ const int theColumn)
{
if(theRow > myNbRows || theRow < 1) throw DFexception("Invalid cell index");
if(theColumn > myNbColumns || theColumn < 1) throw DFexception("Invalid cell index");
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));
}
-
-vector<int> SALOMEDSImpl_AttributeTableOfReal::GetSetRowIndices(const int theRow)
+std::vector<int> SALOMEDSImpl_AttributeTableOfReal::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_AttributeTableOfReal::GetSetColumnIndices(const int theColumn)
+std::vector<int> SALOMEDSImpl_AttributeTableOfReal::GetSetColumnIndices(const int theColumn)
{
- vector<int> aSeq;
+ std::vector<int> aSeq;
int i, anIndex;
for(i = 1; i <= myNbRows; i++) {
return aSeq;
}
-string SALOMEDSImpl_AttributeTableOfReal::Save()
+std::string SALOMEDSImpl_AttributeTableOfReal::Save()
{
- string aString;
+ std::string aString;
char* buffer = new char[1024];
int i, j, l;
return aString;
}
-void SALOMEDSImpl_AttributeTableOfReal::Load(const string& value)
+void SALOMEDSImpl_AttributeTableOfReal::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') {
}
}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfReal::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfReal::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfReal::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfReal::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+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);
+ // swap row titles
+ std::string tmp = myRows[theRow1-1];
+ myRows[theRow1-1] = myRows[theRow2-1];
+ myRows[theRow2-1] = tmp;
+ // 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);
+ // swap column titles
+ std::string tmp = myCols[theColumn1-1];
+ myCols[theColumn1-1] = myCols[theColumn2-1];
+ myCols[theColumn2-1] = tmp;
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+}
+
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server
// File : SALOMEDSImpl_AttributeTableOfReal.hxx
// Author : Michael Ponikarov
#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);
+
+ std::vector<int> SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ std::vector<int> SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy);
+ std::vector<int> SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ std::vector<int> 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
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDSImpl_AttributeTableOfString.cxx
// 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();
}
void SALOMEDSImpl_AttributeTableOfString::SetRowTitle(const int theRow,
- const std::string& theTitle)
+ const std::string& theTitle)
{
CheckLocked();
Backup();
}
void SALOMEDSImpl_AttributeTableOfString::SetRowUnit(const int theRow,
- const std::string& theUnit)
+ const std::string& theUnit)
{
CheckLocked();
Backup();
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++) {
}
void SALOMEDSImpl_AttributeTableOfString::SetColumnTitle(const int theColumn,
- const std::string& theTitle)
+ const std::string& theTitle)
{
CheckLocked();
Backup();
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;
}
void SALOMEDSImpl_AttributeTableOfString::PutValue(const std::string& theValue,
- const int theRow,
- const int theColumn)
+ const int theRow,
+ const int theColumn)
{
CheckLocked();
+ //Backup();
if(theColumn > myNbColumns) SetNbColumns(theColumn);
int anIndex = (theRow-1)*myNbColumns + theColumn;
}
bool SALOMEDSImpl_AttributeTableOfString::HasValue(const int theRow,
- const int theColumn)
+ const int theColumn)
{
if(theRow > myNbRows || theRow < 1) return false;
if(theColumn > myNbColumns || theColumn < 1) return false;
}
std::string SALOMEDSImpl_AttributeTableOfString::GetValue(const int theRow,
- const int theColumn)
+ const int theColumn)
{
if(theRow > myNbRows || theRow < 1) throw DFexception("Invalid cell index");
if(theColumn > myNbColumns || theColumn < 1) throw DFexception("Invalid cell index");
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;
}
}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+std::vector<int> SALOMEDSImpl_AttributeTableOfString::SortByColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy )
+{
+ CheckLocked();
+ std::vector<int> result;
+ 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;
+ }
+ result = indices;
+
+ 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()
+ }
+ return result;
+}
+
+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);
+ // swap row titles
+ std::string tmp = myRows[theRow1-1];
+ myRows[theRow1-1] = myRows[theRow2-1];
+ myRows[theRow2-1] = tmp;
+ // 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);
+ // swap column titles
+ std::string tmp = myCols[theColumn1-1];
+ myCols[theColumn1-1] = myCols[theColumn2-1];
+ myCols[theColumn2-1] = tmp;
+ // no need for SetModifyFlag(), since it is done by SwapCells()
+}
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// SALOME SALOMEDSImpl : data structure of SALOME and sources of Salome data server
// File : SALOMEDSImpl_AttributeTableOfString.hxx
// Author : Sergey Ruin
#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);
+ std::vector<int> SortRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ std::vector<int> SortColumn(const int theColumn, SortOrder sortOrder, SortPolicy sortPolicy);
+ std::vector<int> SortByRow(const int theRow, SortOrder sortOrder, SortPolicy sortPolicy);
+ std::vector<int> 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