CVB++ 15.0
ArrayAccess Class Referencefinal

Access trait for contiguous linear CVB image planes. More...

#include <cvb/vpat.hpp>

Inherits ValueAccessBase< ArrayAccess >.

Classes

class  Column
 A single column. More...
 
class  Row
 A single row. More...
 

Public Member Functions

 ArrayAccess () noexcept
 
LinearAccessData NewMoved (const Rect< int > newAoi) const noexcept
 Creates a new, moved linear access object. More...
 
ArrayAccess NewMoved (int idx) const noexcept
 Creates a new, moved array access object. More...
 
CVB_FORCE_INLINE std::uint8_tBasePtr () const noexcept
 Gets the address of the first pixel of the plane. More...
 
CVB_FORCE_INLINE std::intptr_t XInc () const noexcept
 Gets the offset to the next pixel on this line in this plane. More...
 
CVB_FORCE_INLINE std::intptr_t YInc () const noexcept
 Gets the offset to the next pixel on the next line in this plane. More...
 
CVB_FORCE_INLINE int Width () const noexcept
 Gets the width of the buffer, this access operates on. More...
 
bool Valid () const noexcept
 Gets whether this linear access object is valid. More...
 
 operator bool () const noexcept
 Gets whether this linear access object is valid. More...
 
CVB_FORCE_INLINE const void * operator() (int x, int y) const noexcept
 Coordinate pixel access operator. More...
 
CVB_FORCE_INLINE void * operator() (int x, int y) noexcept
 Coordinate pixel access operator. More...
 
CVB_FORCE_INLINE const void * operator[] (int idx) const noexcept
 Index pixel access operator. More...
 
CVB_FORCE_INLINE void * operator[] (int idx) noexcept
 Index pixel access operator. More...
 
Row RowAt (int y) const noexcept
 Gets the ArrayAccess::Row at y. More...
 
Column ColumnAt (int x) const noexcept
 Gets the ArrayAccess::Column at x. More...
 
- Public Member Functions inherited from ValueAccessBase< ArrayAccess >
const Type & Value (int x, int y) const noexcept
 Gets a pixel value at a given position. More...
 
Type & Value (int x, int y) noexcept
 Gets a settable pixel value at a given position. More...
 
const Type & Value (Point2D< int > position) const noexcept
 Gets a pixel value at a given position. More...
 
Type & Value (Point2D< int > position) noexcept
 Gets a settable pixel value at a given position. More...
 

Static Public Member Functions

template<class PLANE_T >
static ArrayAccess FromPlane (const PLANE_T &plane) noexcept
 Tries to get a valid ArrayAccess trait from the given plane. More...
 
static ArrayAccess FromLinearAccess (const LinearAccessData &access, Size2D< int > size) noexcept
 Tries to get a valid ArrayAccess trait from the given access. More...
 
static ArrayAccess FromVpat (const Vpat &access, Size2D< int > size, DataType dataType) noexcept
 Tries to get a valid ArrayAccess trait from the given VPAT access. More...
 

Related Functions

(Note that these are not member functions.)

bool operator!= (const ArrayAccess &lhs, const ArrayAccess &rhs) noexcept
 Inequality operator. More...
 
bool operator== (const ArrayAccess &lhs, const ArrayAccess &rhs) noexcept
 Equality operator. More...
 
bool IsInterleaved (size_t bytesPerPixel, const ArrayAccess &access0, const ArrayAccess &access1) noexcept
 
template<class... ACCESSES>
bool IsInterleaved (size_t bytesPerPixel, const ArrayAccess &access0, const ArrayAccess &access1, const ACCESSES &... accs) noexcept
 

Detailed Description

Access trait for contiguous linear CVB image planes.

Constructor & Destructor Documentation

◆ ArrayAccess()

ArrayAccess ( )
inlinedefaultnoexcept

Default ctor of invalid access data.

Postcondition
Valid() == false

Member Function Documentation

◆ BasePtr()

CVB_FORCE_INLINE std::uint8_t * BasePtr ( ) const
inlinenoexcept

Gets the address of the first pixel of the plane.

Returns
Address of the first pixel of the plane.

◆ ColumnAt()

Column ColumnAt ( int  x) const
inlinenoexcept

Gets the ArrayAccess::Column at x.

Precondition
x must be between 0 and less than the allowed width.
Parameters
[in]xPixel column.
Returns
Column object at line x.

◆ FromLinearAccess()

ArrayAccess FromLinearAccess ( const LinearAccessData access,
Size2D< int >  size 
)
inlinestaticnoexcept

Tries to get a valid ArrayAccess trait from the given access.

Parameters
[in]accessLinear access to analyze.
[in]sizeImage dimensions of the given access.
Returns
Valid ArrayAccess if the linear access is also array-like; invalid one otherwise.

◆ FromPlane()

ArrayAccess FromPlane ( const PLANE_T &  plane)
inlinestaticnoexcept

Tries to get a valid ArrayAccess trait from the given plane.

Can be extended to support custom plane types T by implementing Cvb::PlaneTraits<T>.

Template Parameters
PLANE_TThe type of the plane to get the access from.
Parameters
[in]planePlane to access.
Returns
Valid ArrayAccess if the layout is linear and array-like; invalid one otherwise.

◆ FromVpat()

ArrayAccess FromVpat ( const Vpat access,
Size2D< int >  size,
DataType  dataType 
)
inlinestaticnoexcept

Tries to get a valid ArrayAccess trait from the given VPAT access.

Parameters
[in]accessBase address in conjunction with VPAT.
[in]sizeImage dimensions of the given VPAT access.
[in]dataTypeData type of the image of the given vpat.
Returns
Valid ArrayAccess if VPAT access is linear and array-like; invalid one otherwise.

◆ NewMoved() [1/2]

LinearAccessData NewMoved ( const Rect< int >  newAoi) const
inlinenoexcept

Creates a new, moved linear access object.

Precondition
Valid() == true
Parameters
[in]newAoiOffset and new size in pixels to move this access to.
Returns
New ArrayAccess object that is moved by (x, y).

◆ NewMoved() [2/2]

ArrayAccess NewMoved ( int  idx) const
inlinenoexcept

Creates a new, moved array access object.

Precondition
Valid() == true
Parameters
[in]idxOffset in pixels to move this array access to.
Returns
New ArrayAccess object that is moved by idx.

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexcept

Gets whether this linear access object is valid.

Returns
true if Scan0() is not nullptr, XInc(), Width() and Height() are greater than 0.

◆ operator()() [1/2]

CVB_FORCE_INLINE const void * operator() ( int  x,
int  y 
) const
inlinenoexcept

Coordinate pixel access operator.

Precondition
Valid() == true
Parameters
[in]xX coordinate coefficient in pixels.
[in]yY coordinate coefficient in pixels.
Returns
Const pointer to pixel value.

◆ operator()() [2/2]

CVB_FORCE_INLINE void * operator() ( int  x,
int  y 
)
inlinenoexcept

Coordinate pixel access operator.

Precondition
Valid() == true
Parameters
[in]xX coordinate coefficient in pixels.
[in]yY coordinate coefficient in pixels.
Returns
Mutable pointer to pixel value.

◆ operator[]() [1/2]

CVB_FORCE_INLINE const void * operator[] ( int  idx) const
inlinenoexcept

Index pixel access operator.

Precondition
Valid() == true
Parameters
[in]idxIndex of the pixel.
Returns
Const pointer to pixel value.

◆ operator[]() [2/2]

CVB_FORCE_INLINE void * operator[] ( int  idx)
inlinenoexcept

Index pixel access operator.

Precondition
Valid() == true
Parameters
[in]idxIndex of the pixel.
Returns
Mutable pointer to pixel value.

◆ RowAt()

Row RowAt ( int  y) const
inlinenoexcept

Gets the ArrayAccess::Row at y.

Precondition
y must be between 0 and less than the allowed height.
Parameters
[in]yPixel row.
Returns
Row object at line y.

◆ Valid()

bool Valid ( ) const
inlinenoexcept

Gets whether this linear access object is valid.

Returns
true if Scan0() is not nullptr, XInc(), Width() and Height() are greater than 0.

◆ Width()

CVB_FORCE_INLINE int Width ( ) const
inlinenoexcept

Gets the width of the buffer, this access operates on.

Returns
The number of pixels in a line in the buffer this access operates on.

◆ XInc()

CVB_FORCE_INLINE std::intptr_t XInc ( ) const
inlinenoexcept

Gets the offset to the next pixel on this line in this plane.

Returns
Offset to the next pixel in bytes.

◆ YInc()

CVB_FORCE_INLINE std::intptr_t YInc ( ) const
inlinenoexcept

Gets the offset to the next pixel on the next line in this plane.

Returns
Offset to the next line in bytes.

Friends And Related Function Documentation

◆ IsInterleaved() [1/2]

bool IsInterleaved ( size_t  bytesPerPixel,
const ArrayAccess access0,
const ArrayAccess access1 
)
related

Returns whether the ArrayAccesses are directly interleaved.

Parameters
[in]bytesPerPixelThe number of bytes required per pixel.
[in]access0First ArrayAccess to test.
[in]access1Second ArrayAccess to test.
Returns
true if interleaved, false if not

◆ IsInterleaved() [2/2]

bool IsInterleaved ( size_t  bytesPerPixel,
const ArrayAccess access0,
const ArrayAccess access1,
const ACCESSES &...  accs 
)
related
Parameters
[in]accsArbitrary number of other ArrayAccesses. Returns whether the ArrayAccesses are directly interleaved.
[in]bytesPerPixelThe number of bytes required per pixel.
[in]access0First ArrayAccess to test.
[in]access1Second ArrayAccess to test.
Returns
true if interleaved, false if not

◆ operator!=()

bool operator!= ( const ArrayAccess lhs,
const ArrayAccess rhs 
)
related

Inequality operator.

Parameters
[in]lhsLeft hand side operand.
[in]rhsRight hand side operand.
Returns
true if lhs and rhs are unequal; false if equal.

◆ operator==()

bool operator== ( const ArrayAccess lhs,
const ArrayAccess rhs 
)
related

Equality operator.

Parameters
[in]lhsLeft hand side operand.
[in]rhsRight hand side operand.
Returns
true if lhs and rhs are equal; false if equal.