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

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

#include <globalarray.h>

List of all members.

Public Member Functions

 GlobalArray (const T newData[], size_t newSize)
 Constructs a new wrapper object for the given C++ array.
 GlobalArray (const GlobalArray< T, ReturnValuePolicy > &cloneMe)
 Constructs a new wrapper object that wraps the same C++ array as the given wrapper object.
size_t size () const
 Return the number of elements in this array.
const T & getItem (size_t index) const
 Returns the array element at the given index.
const T & operator[] (size_t index) const
 Returns the array element at the given index.
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

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

Friends

class GlobalArray2D< T, ReturnValuePolicy >


Detailed Description

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

A template class that references a constant one-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 index that is passed.

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

For each different set of template parameters, the corresponding GlobalArray 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 &lt;< is defined for type T.


Constructor & Destructor Documentation

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
regina::python::GlobalArray< T, ReturnValuePolicy >::GlobalArray ( const T  newData[],
size_t  newSize 
) [inline]

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

Precondition:
This class has already been wrapped in Python by calling wrapClass().
Parameters:
newData the constant C++ array that is to be wrapped.
newSize the number of elements in this C++ array.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
regina::python::GlobalArray< T, ReturnValuePolicy >::GlobalArray ( const GlobalArray< 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.


Member Function Documentation

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

Return the number of elements in this array.

Returns:
the number of elements.

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

Returns the array element at the given index.

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

Parameters:
index the given array index.
Returns:
the element at the given index.

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

Returns the array element at the given index.

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

Parameters:
index the given array index.
Returns:
the element at the given index.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
std::ostream& regina::python::GlobalArray< 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.

template<typename T, class ReturnValuePolicy = ::boost::python::return_by_value>
static void regina::python::GlobalArray< 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.


The documentation for this class was generated from the following file:
Copyright © 1999-2006, 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).