Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

regina::python::GlobalArray2D< T, ReturnValuePolicy > Class Template Reference

A template class that references a constant two-dimensional C++ array. More...

#include <globalarray.h>

List of all members.

Public Types

typedef GlobalArray< T, ReturnValuePolicy > Row
 A wrapper class for each row of this array.

Public Member Functions

template<size_t newCols>
 GlobalArray2D (const T newData[][newCols], size_t newRows)
 Constructs a new wrapper object for the given 2-dimensional C++ array.
 GlobalArray2D (const T newData[], size_t newRows, size_t newCols)
 Constructs a new 2-dimensional wrapper object for the given 1-dimensional C++ array.
 GlobalArray2D (const GlobalArray2D< T, ReturnValuePolicy > &cloneMe)
 Constructs a new wrapper object that wraps the same C++ array as the given wrapper object.
 ~GlobalArray2D ()
 Class destructor.
size_t rows () const
 Return the number of rows in this array.
size_t cols () const
 Return the number of columns in this array.
const RowgetItem (size_t index) const
 Returns the requested row of the array.
const Rowoperator[] (size_t index) const
 Returns the requested row of the array.
std::ostream & writeText (std::ostream &out) const
 Writes a string representation of this array, including all of its elements, to the given output stream.

Static Public Member Functions

void wrapClass (const char *className)
 Constructs a Boost.Python wrapper for this class.

Friends

class GlobalArray3D<T, ReturnValuePolicy>


Detailed Description

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
class regina::python::GlobalArray2D< T, ReturnValuePolicy >

A template class that references a constant two-dimensional C++ array.

An object of this class can be passed through to Python to allow the user access to the underlying C++ array. For the Python user, the usual list operator [] can be used to access the elements of the array. Range checking is performed on any indices that are passed.

The ReturnValuePolicy template argument specifies the return value policy for element lookup.

For each different set of template parameters, the corresponding GlobalArray2D class must be wrapped in Python before the first object of this class is constructed. This wrapping is performed by calling wrapClass().

Note that elements of this array can only be inspected, not modified.

Precondition:
The output operator << is defined for type T.


Member Typedef Documentation

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
typedef GlobalArray<T, ReturnValuePolicy> regina::python::GlobalArray2D< T, ReturnValuePolicy >::Row
 

A wrapper class for each row of this array.


Constructor & Destructor Documentation

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
template<size_t newCols>
regina::python::GlobalArray2D< T, ReturnValuePolicy >::GlobalArray2D const T  newData[][newCols],
size_t  newRows
[inline]
 

Constructs a new wrapper object for the given 2-dimensional C++ array.

Precondition:
This class has already been wrapped in Python by calling wrapClass().

The number of rows is strictly positive.

Parameters:
newData the constant 2-dimensional C++ array that is to be wrapped.
newRows the number of rows in this C++ array, i.e., the first array dimension.
newCols the number of columns in this C++ array, i.e., the second array dimension. This must be a compile-time constant.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
regina::python::GlobalArray2D< T, ReturnValuePolicy >::GlobalArray2D const T  newData[],
size_t  newRows,
size_t  newCols
[inline]
 

Constructs a new 2-dimensional wrapper object for the given 1-dimensional C++ array.

If the Python array is to have r rows and columns, the Python element array[i][j] will correspond to the C++ element array[(i * c) + j].

Precondition:
This class has already been wrapped in Python by calling wrapClass().

The numbers of rows and columns are both strictly positive.

Parameters:
newData the constant 1-dimensional C++ array that is to be wrapped.
newRows the number of rows in the corresponding 2-dimensional array, i.e., the first array dimension.
newCols the number of columns in the corresponding 2-dimensional array, i.e., the second array dimension.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
regina::python::GlobalArray2D< T, ReturnValuePolicy >::GlobalArray2D const GlobalArray2D< T, ReturnValuePolicy > &  cloneMe  )  [inline]
 

Constructs a new wrapper object that wraps the same C++ array as the given wrapper object.

Note that the same underlying C++ array is referenced, i.e., the C++ array itself is not cloned.

Parameters:
cloneMe the wrapper object to clone.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
regina::python::GlobalArray2D< T, ReturnValuePolicy >::~GlobalArray2D  )  [inline]
 

Class destructor.

All of the internal row wrappers are destroyed.


Member Function Documentation

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
size_t regina::python::GlobalArray2D< T, ReturnValuePolicy >::cols  )  const [inline]
 

Return the number of columns in this array.

Returns:
the number of columns.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
const Row& regina::python::GlobalArray2D< T, ReturnValuePolicy >::getItem size_t  index  )  const [inline]
 

Returns the requested row of the array.

If the row index is out of range, a Python error will be thrown.

Parameters:
index the index of the requested row.
Returns:
the row at the given index.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
const Row& regina::python::GlobalArray2D< T, ReturnValuePolicy >::operator[] size_t  index  )  const [inline]
 

Returns the requested row of the array.

If the row index is out of range, a Python error will be thrown.

Parameters:
index the index of the requested row.
Returns:
the row at the given index.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
size_t regina::python::GlobalArray2D< T, ReturnValuePolicy >::rows  )  const [inline]
 

Return the number of rows in this array.

Returns:
the number of rows.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
void regina::python::GlobalArray2D< T, ReturnValuePolicy >::wrapClass const char *  className  )  [inline, static]
 

Constructs a Boost.Python wrapper for this class.

This routine must be called for each set of template parameters before the first object of this class is constructed.

Parameters:
className the name that will be assigned to this class in Python.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
std::ostream& regina::python::GlobalArray2D< T, ReturnValuePolicy >::writeText std::ostream &  out  )  const [inline]
 

Writes a string representation of this array, including all of its elements, to the given output stream.

Parameters:
out the output stream to which to write.
Returns:
a reference to out.


The documentation for this class was generated from the following file:
Copyright © 1999-2004, Ben Burton
This software is released under the GNU General Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).