Regina 7.0 Calculation Engine
Public Member Functions | Static Public Member Functions | Friends | List of all members
regina::python::GlobalArray< T, rvp > 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 data[], size_t size)
 Constructs a new wrapper object for the given C++ array. More...
 
 GlobalArray (const GlobalArray< T, rvp > &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...
 
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 (pybind11::module_ &m, const char *className)
 Constructs a Python wrapper for this class. More...
 

Friends

class GlobalArray2D< T, rvp >
 

Detailed Description

template<typename T, pybind11::return_value_policy rvp = pybind11::return_value_policy::copy>
class regina::python::GlobalArray< T, rvp >

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 rvp 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 wrapped. 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

◆ GlobalArray() [1/2]

template<typename T , pybind11::return_value_policy rvp = pybind11::return_value_policy::copy>
regina::python::GlobalArray< T, rvp >::GlobalArray ( const T  data[],
size_t  size 
)
inline

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

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

◆ GlobalArray() [2/2]

template<typename T , pybind11::return_value_policy rvp = pybind11::return_value_policy::copy>
regina::python::GlobalArray< T, rvp >::GlobalArray ( const GlobalArray< T, rvp > &  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
cloneMethe wrapper object to clone.

Member Function Documentation

◆ getItem()

template<typename T , pybind11::return_value_policy rvp = pybind11::return_value_policy::copy>
const T & regina::python::GlobalArray< T, rvp >::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
indexthe given array index.
Returns
the element at the given index.

◆ size()

template<typename T , pybind11::return_value_policy rvp = pybind11::return_value_policy::copy>
size_t regina::python::GlobalArray< T, rvp >::size ( ) const
inline

Return the number of elements in this array.

Returns
the number of elements.

◆ wrapClass()

template<typename T , pybind11::return_value_policy rvp = pybind11::return_value_policy::copy>
static void regina::python::GlobalArray< T, rvp >::wrapClass ( pybind11::module_ &  m,
const char *  className 
)
inlinestatic

Constructs a Python wrapper for this class.

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

Parameters
mthe Python module in which these wrappers should be installed.
classNamethe name that will be assigned to this class in Python.

◆ writeText()

template<typename T , pybind11::return_value_policy rvp = pybind11::return_value_policy::copy>
std::ostream & regina::python::GlobalArray< T, rvp >::writeText ( std::ostream &  out) const
inline

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

Parameters
outthe output stream to which to write.
Returns
a reference to out.

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

Copyright © 1999-2021, 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@maths.uq.edu.au).