28 #include "../SortedArray.hpp" 29 #include "../Macros.hpp" 30 #include "../limits.hpp" 31 #include "../output.hpp" 70 virtual void setAccessLevel(
int const accessLevel,
int const memorySpace ) = 0;
76 virtual std::string
repr()
const = 0;
82 virtual std::type_index
valueType()
const = 0;
91 virtual long long insert(
void const *
const values,
long long const nVals ) = 0;
100 virtual long long remove(
void const *
const values,
long long const nVals ) = 0;
106 virtual PyObject *
toNumPy() = 0;
130 template<
typename T,
132 template<
typename >
class BUFFER_TYPE >
143 m_sortedArray( sortedArray )
150 virtual void setAccessLevel(
int const accessLevel,
int const memorySpace )
final override 153 if( accessLevel >= static_cast< int >( LvArray::python::PyModify::RESIZEABLE ) )
161 virtual std::string
repr() const final
override 162 {
return system::demangleType< SortedArray< T, INDEX_TYPE, BUFFER_TYPE > >(); }
165 virtual std::type_index
valueType() const final
override 166 {
return std::type_index(
typeid( T ) ); }
169 virtual long long insert(
void const *
const values,
long long const nVals )
final override 171 T
const *
const castedValues =
reinterpret_cast< T
const *
>( values );
172 return integerConversion< long long >( m_sortedArray.insert( castedValues, castedValues + nVals ) );
176 virtual long long remove(
void const *
const values,
long long const nVals )
final override 178 T
const *
const castedValues =
reinterpret_cast< T
const *
>( values );
179 return integerConversion< long long >( m_sortedArray.remove( castedValues, castedValues + nVals ) );
185 INDEX_TYPE
const dims = m_sortedArray.size();
186 INDEX_TYPE
const strides = 1;
200 PyObject *
create( std::unique_ptr< internal::PySortedArrayWrapperBase > && sortedArray );
214 template<
typename T,
typename INDEX_TYPE,
template<
typename >
class BUFFER_TYPE >
215 std::enable_if_t< internal::canExportToNumpy< T >, PyObject * >
218 auto tmp = std::make_unique< internal::PySortedArrayWrapper< T, INDEX_TYPE, BUFFER_TYPE > >( sortedArray );
#define LVARRAY_UNUSED_VARIABLE(X)
Mark X as an unused variable, used to silence compiler warnings.
Definition: Macros.hpp:79
std::enable_if_t< internal::canExportToNumpy< T >, PyObject *> create(T &value)
Create a NumPy 1D array of length 1 containing the scalar value.
Definition: numpyHelpers.hpp:147
PyModify
An enumeration of the various access policies for Python objects.
Definition: pythonHelpers.hpp:136
virtual void setAccessLevel(int const accessLevel, int const memorySpace) final override
Set the access level for the SortedArray.
Definition: PySortedArray.hpp:150
PySortedArrayWrapper(SortedArray< T, INDEX_TYPE, BUFFER_TYPE > &sortedArray)
Construct a new Python wrapper around sortedArray.
Definition: PySortedArray.hpp:141
virtual void setAccessLevel(int const accessLevel, int const memorySpace)=0
Set the access level for the SortedArray.
virtual PyObject * toNumPy()=0
Return an immutable NumPy array representing the set.
virtual std::type_index valueType() const final override
Return the type of the values stored in the sub-arrays.
Definition: PySortedArray.hpp:165
This class provides an interface similar to an std::set.
Definition: SortedArray.hpp:35
PyTypeObject * getPySortedArrayType()
Return the Python type for the SortedArray.
virtual PyObject * toNumPy() final override
Return an immutable NumPy array representing the set.
Definition: PySortedArray.hpp:183
virtual ~PySortedArrayWrapperBase()=default
Default destructor.
std::enable_if_t< internal::canExportToNumpy< T >, PyObject *> create(SortedArray< T, INDEX_TYPE, BUFFER_TYPE > &sortedArray)
Create a Python object corresponding to sortedArray.
Definition: PySortedArray.hpp:216
SortedArray< T, INDEX_TYPE, BUFFER_TYPE > & m_sortedArray
The wrapped SortedArray.
Definition: PySortedArray.hpp:192
Forward declarations of Python Objects.
virtual std::type_index valueType() const =0
Return the type of the values stored in the sub-arrays.
Provides a concrete implementation of PySortedArrayWrapperBase.
Definition: PySortedArray.hpp:133
virtual long long insert(void const *const values, long long const nVals)=0
Insert values into the set.
The top level namespace.
Definition: Array.hpp:24
Contains methods to help with conversion to python objects.
Provides a virtual Python wrapper around a SortedArray.
Definition: PySortedArray.hpp:49
PySortedArrayWrapperBase()
Construct an empty PySortedArrayWrapperBase.
Definition: PySortedArray.hpp:113
virtual int getAccessLevel() const
Return the access level for the SortedArray.
Definition: PySortedArray.hpp:62
int m_accessLevel
The access level for the SortedArray.
Definition: PySortedArray.hpp:118
virtual std::string repr() const final override
Return a string representing the underlying SortedArray type.
Definition: PySortedArray.hpp:161
virtual long long insert(void const *const values, long long const nVals) final override
Insert values into the set.
Definition: PySortedArray.hpp:169
std::enable_if_t< internal::canExportToNumpy< T >, PyObject *> createNumPyArray(T *const data, bool const modify, int const ndim, INDEX_TYPE const *const dimsPtr, INDEX_TYPE const *const stridesPtr)
Return a NumPy ndarray view of data.
Definition: numpyHelpers.hpp:107
virtual std::string repr() const =0
Return a string representing the underlying SortedArray type.