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

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

`#include <python/globalarray.h>`

## Public Member Functions

| GlobalArray (const T newData[], size_t newSize)
| Constructs a new wrapper object for the given C++ array. More...
| GlobalArray (const GlobalArray< T, ReturnValuePolicy > &cloneMe)
| Constructs a new wrapper object that wraps the same C++ array as the given wrapper object. More...
size_t | size () const
| Return the number of elements in this array. More...
const T & | getItem (size_t index) const
| Returns the array element at the given index. More...
const T & | operator[] (size_t index) const
| Returns the array element at the given index. More...
std::ostream & | writeText (std::ostream &out) const
| Writes a string representation of this array, including all of its elements, to the given output stream. More...

## Static Public Member Functions

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

## 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 << 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>

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>

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>

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.

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.

The documentation for this class was generated from the following file:

- python/globalarray.h

Copyright © 1999-2014, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).