NPL
Neurological Programs and Libraries
npl::NDView< T > Class Template Reference

This is a basic accessor class, which allows for accessing array data in the type specified by the template. More...

#include <accessors.h>

Inherited by npl::BSplineView< T >, npl::Pixel3DView< T >, and npl::Vector3DView< T >.

Public Member Functions

 NDView (std::shared_ptr< NDArray > in)
 
 NDView ()
 
void setArray (ptr< NDArray > in)
 
operator[] (int64_t index)
 Gets value linear position in array, then casts to T. More...
 
get (const std::vector< int64_t > &index)
 Gets value at array index and then casts to T. More...
 
get (size_t len, int64_t *index)
 Gets value at array index and then casts to T. More...
 
operator[] (const std::vector< int64_t > &index)
 Gets value at array index and then casts to T. More...
 
void set (size_t len, const int64_t *index, T v)
 Casts to the appropriate type then sets array at given index. More...
 
void set (const std::vector< int64_t > &index, T v)
 Casts to the appropriate type then sets array at given index. More...
 
void set (int64_t index, T v)
 Casts to the appropriate type then sets array at given index. More...
 
int64_t tlen ()
 

Static Protected Member Functions

template<typename U >
static T castgetStatic (void *ptr)
 This is a wrapper function that will be called to safely cast from the underlying type. More...
 
template<typename U >
static void castsetStatic (void *ptr, const T &val)
 This is a wrapper function that will be called to safely cast to the underlying type. More...
 

Protected Attributes

std::shared_ptr< NDArrayparent
 Where to get the dat a from. Also the shared_ptr prevents dealloc. More...
 
T(* castget )(void *ptr)
 Function pointer to the correct function for casting from the underlying type. More...
 
void(* castset )(void *ptr, const T &v)
 Function pointer to the correct function for casting to the underlying type. This should be set during construction. More...
 

Detailed Description

template<typename T>
class npl::NDView< T >

This is a basic accessor class, which allows for accessing array data in the type specified by the template.

Template Parameters
TValue to return on access

Definition at line 63 of file accessors.h.

Constructor & Destructor Documentation

template<typename T >
npl::NDView< T >::NDView ( std::shared_ptr< NDArray in)
inline

Definition at line 66 of file accessors.h.

template<typename T >
npl::NDView< T >::NDView ( )
inline

Definition at line 71 of file accessors.h.

Member Function Documentation

template<typename T >
template<typename U >
static T npl::NDView< T >::castgetStatic ( void *  ptr)
inlinestaticprotected

This is a wrapper function that will be called to safely cast from the underlying type.

Template Parameters
UUnderlying type of pixel, figured out in the constructor
Parameters
ptrPointer to memory where the pixel is.
Returns
Correctly cast value

Definition at line 272 of file accessors.h.

template<typename T >
template<typename U >
static void npl::NDView< T >::castsetStatic ( void *  ptr,
const T &  val 
)
inlinestaticprotected

This is a wrapper function that will be called to safely cast to the underlying type.

Template Parameters
UUnderlying type of pixel, figured out in the constructor
Parameters
ptrPointer to memory where the pixel is.
valnew value to write

Definition at line 287 of file accessors.h.

template<typename T >
T npl::NDView< T >::get ( const std::vector< int64_t > &  index)
inline

Gets value at array index and then casts to T.

Parameters
indexn-d index to access
Returns
value

Definition at line 170 of file accessors.h.

template<typename T >
T npl::NDView< T >::get ( size_t  len,
int64_t *  index 
)
inline

Gets value at array index and then casts to T.

Parameters
lenlength of index array
indexn-d index to access
Returns
value

Definition at line 186 of file accessors.h.

template<typename T >
T npl::NDView< T >::operator[] ( int64_t  index)
inline

Gets value linear position in array, then casts to T.

Returns
value

Definition at line 155 of file accessors.h.

template<typename T >
T npl::NDView< T >::operator[] ( const std::vector< int64_t > &  index)
inline

Gets value at array index and then casts to T.

Parameters
indexn-d index to access
Returns
value

Definition at line 201 of file accessors.h.

template<typename T >
void npl::NDView< T >::set ( size_t  len,
const int64_t *  index,
v 
)
inline

Casts to the appropriate type then sets array at given index.

Parameters
lenlength of index array
indexn-d index to access
vvalue to set at index
Returns
current value

Definition at line 218 of file accessors.h.

template<typename T >
void npl::NDView< T >::set ( const std::vector< int64_t > &  index,
v 
)
inline

Casts to the appropriate type then sets array at given index.

Parameters
vvalue to set at index
indexn-d index to access
Returns
current value

Definition at line 234 of file accessors.h.

template<typename T >
void npl::NDView< T >::set ( int64_t  index,
v 
)
inline

Casts to the appropriate type then sets array at given index.

Parameters
vvalue to set at index
indexn-d index to access
Returns
current value

Definition at line 250 of file accessors.h.

template<typename T >
void npl::NDView< T >::setArray ( ptr< NDArray in)
inline

Definition at line 73 of file accessors.h.

template<typename T >
int64_t npl::NDView< T >::tlen ( )
inline

Definition at line 258 of file accessors.h.

Member Data Documentation

template<typename T >
T(* npl::NDView< T >::castget) (void *ptr)
protected

Function pointer to the correct function for casting from the underlying type.

Parameters
ptrlocation in memory where the pixel is stored

Definition at line 303 of file accessors.h.

template<typename T >
void(* npl::NDView< T >::castset) (void *ptr, const T &v)
protected

Function pointer to the correct function for casting to the underlying type. This should be set during construction.

Parameters
ptrpointer to memory
vvalue to cast and write

Definition at line 313 of file accessors.h.

template<typename T >
std::shared_ptr<NDArray> npl::NDView< T >::parent
protected

Where to get the dat a from. Also the shared_ptr prevents dealloc.

Definition at line 290 of file accessors.h.


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