ATLAS Offline Software
Loading...
Searching...
No Matches
CxxUtils::Array< 0 > Class Reference

Read-only multidimensional array, specialized for N=0. More...

#include <Array.h>

Inheritance diagram for CxxUtils::Array< 0 >:
Collaboration diagram for CxxUtils::Array< 0 >:

Public Types

enum  { NDIM = 0 }
 The number of dimensions of the array. More...
enum  
 The number of dimensions of the array. More...
typedef ArrayIteratorChooser< N >::const_iterator const_iterator
 The iterator for this container.

Public Member Functions

 Array ()
 Default constructor.
 Array (const Arrayrep &rep)
 Constructor.
bool valid () const
 Test for validity.
std::vector< unsigned int > shape () const
 Return the array shape.
unsigned int size (unsigned int dim=0) const
 Return the size of the array along one dimension.
 operator Arrayelt () const
 Convert to a number.
int asint () const
 Convert to an integer.
void write_array (std::ostream &stream) const
 Creates a text representation of the array content.
 Array ()
 Default constructor.
 Array (const Arrayrep &rep)
 Constructor.
bool valid () const
 Test for validity.
std::vector< unsigned int > shape () const
 Return the array shape.
unsigned int size (unsigned int dim=0) const
 Return the size of the array along one dimension.
Array< N-1 > operator[] (unsigned int i) const
 Array indexing.
const Arrayeltptr () const
 Return a direct pointer to array elements.
const_iterator begin () const
 Return an iterator pointing at the beginning of the container.
const_iterator end () const
 Return an iterator pointing past the end of the container.
void write_array (std::ostream &stream) const
 Creates a text representation of the array content.

Protected Member Functions

 Array (const Arrayrep &rep, unsigned int offs)
 Private constructor for array indexing.
 Array (const Arrayrep &rep, unsigned int offs)
 Private constructor for array indexing.

Protected Attributes

const Arrayeltm_elt
 Pointer to this array's single element.
friend WritableArray< N+1 >
const Arrayrepm_rep
 Pointer to the representation.
unsigned int m_offs
 Offset in the Arrayrep's data of the first element of this array.

Friends

class Array< 1 >
class WritableArray< 1 >
class Array< N+1 >
class ArrayIterator< N+1 >

Detailed Description

Read-only multidimensional array, specialized for N=0.

This is a specialization of Array for the case N=0, i.e., a scalar. It does not support indexing, but it does support implicit conversions to Arrayelt, as well as an explicit conversion to an integer.

Definition at line 269 of file Control/CxxUtils/CxxUtils/Array.h.

Member Typedef Documentation

◆ const_iterator

The iterator for this container.

Definition at line 141 of file Control/CxxUtils/CxxUtils/Array.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

The number of dimensions of the array.

Definition at line 138 of file Control/CxxUtils/CxxUtils/Array.h.

◆ anonymous enum

anonymous enum

The number of dimensions of the array.

Enumerator
NDIM 

Definition at line 273 of file Control/CxxUtils/CxxUtils/Array.h.

273{ NDIM = 0 };

Constructor & Destructor Documentation

◆ Array() [1/6]

Default constructor.

This produces an invalid Array that is not associated with an Arrayrep. valid() will return false for such an array. The only other thing that it is legal to do with an invalid array is to assign to it (which may make it valid).

◆ Array() [2/6]

CxxUtils::Array< 0 >::Array ( const Arrayrep & rep)

Constructor.

Parameters
repArrayrep from which to initialize the array.

Initialize an array from an Arrayrep. The new array will represent the entire Arrayrep. The dimension N must match the length of the Arrayrep's shape.

◆ Array() [3/6]

CxxUtils::Array< 0 >::Array ( const Arrayrep & rep,
unsigned int offs )
protected

Private constructor for array indexing.

Parameters
repArrayrep from which to initialize the array.
offsOffset of the first element of the new array within rep.

This is a private constructor used to make the Array instances returned from an indexing operation.

◆ Array() [4/6]

Default constructor.

This produces an invalid Array that is not associated with an Arrayrep. valid() will return false for such an array. The only other things that it is legal to do with an invalid array are to assign to it (which may make it valid) or request its size with size() (which will always return 0).

◆ Array() [5/6]

CxxUtils::Array< N >::Array ( const Arrayrep & rep)

Constructor.

Parameters
repArrayrep from which to initialize the array.

Initialize an array from an Arrayrep. The new array will represent the entire Arrayrep. The dimension N must match the length of the Arrayrep's shape.

◆ Array() [6/6]

CxxUtils::Array< N >::Array ( const Arrayrep & rep,
unsigned int offs )
protected

Private constructor for array indexing.

Parameters
repArrayrep from which to initialize the array.
offsOffset of the first element of the new array within rep.

This is a private constructor used to make the Array instances returned from an indexing operation.

Member Function Documentation

◆ asint()

int CxxUtils::Array< 0 >::asint ( ) const

Convert to an integer.

Returns
The Array<0> contents as an integer.

◆ begin()

const_iterator CxxUtils::Array< N >::begin ( ) const

Return an iterator pointing at the beginning of the container.

Returns
An iterator pointing at the beginning of the container.

◆ end()

const_iterator CxxUtils::Array< N >::end ( ) const

Return an iterator pointing past the end of the container.

Returns
An iterator pointing past the end of the container.

◆ operator Arrayelt()

CxxUtils::Array< 0 >::operator Arrayelt ( ) const

Convert to a number.

Returns
The Array<0> contents as a number.

◆ operator[]()

Array< N-1 > CxxUtils::Array< N >::operator[] ( unsigned int i) const

Array indexing.

Parameters
iThe desired index. Must be less than the array size along this dimension.
Returns
The i'th N-1 dimensional subarray in the array.

Note that this operation is not available if N is 0.

◆ ptr()

const Arrayelt * CxxUtils::Array< N >::ptr ( ) const

Return a direct pointer to array elements.

Returns
A pointer to the first array elements.

Subsequent elements follow in standard C indexing order.

◆ shape() [1/2]

std::vector< unsigned int > CxxUtils::Array< N >::shape ( ) const

Return the array shape.

Returns
The array shape.

The array shape is vector with one element for each array dimension, giving the size of the array along that dimension.

◆ shape() [2/2]

std::vector< unsigned int > CxxUtils::Array< 0 >::shape ( ) const

Return the array shape.

Returns
The array shape.

The array shape is vector with one element for each array dimension, giving the size of the array along that dimension. For Array<0>, this will always be an empty array.

◆ size() [1/2]

unsigned int CxxUtils::Array< N >::size ( unsigned int dim = 0) const

Return the size of the array along one dimension.

Parameters
dimThe dimension of the size to retrieve. Must be less than the number of dimensions.
Returns
The array size along dimension dim.

◆ size() [2/2]

unsigned int CxxUtils::Array< 0 >::size ( unsigned int dim = 0) const

Return the size of the array along one dimension.

Parameters
dimThe dimension of the size to retrieve. Must be less than the number of dimensions.
Returns
The array size along dimension dim.

For Array<0>, dim must be 0, and the function will always return 0.

◆ valid() [1/2]

bool CxxUtils::Array< N >::valid ( ) const

Test for validity.

Returns
True if the Array is associated with an Arrayrep, false if not.

◆ valid() [2/2]

bool CxxUtils::Array< 0 >::valid ( ) const

Test for validity.

Returns
True if the Array is associated with an Arrayrep, false if not.

◆ write_array() [1/2]

void CxxUtils::Array< N >::write_array ( std::ostream & stream) const

Creates a text representation of the array content.

Parameters
std::ostreamwhere the text should be written

Writes the content of the array to a ostream. The sub-arrays are enclosed by square-brackets and separated by commas.

◆ write_array() [2/2]

void CxxUtils::Array< 0 >::write_array ( std::ostream & stream) const

Creates a text representation of the array content.

Parameters
std::ostreamwhere the text should be written

Writes the content of the array to a ostream. The sub-arrays are enclosed by square brackets and separated by commas.

◆ Array< 1 >

friend class Array< 1 >
friend

Definition at line 357 of file Control/CxxUtils/CxxUtils/Array.h.

◆ Array< N+1 >

friend class Array< N+1 >
friend

Definition at line 243 of file Control/CxxUtils/CxxUtils/Array.h.

◆ ArrayIterator< N+1 >

friend class ArrayIterator< N+1 >
friend

Definition at line 247 of file Control/CxxUtils/CxxUtils/Array.h.

◆ WritableArray< 1 >

friend class WritableArray< 1 >
friend

Definition at line 357 of file Control/CxxUtils/CxxUtils/Array.h.

Member Data Documentation

◆ m_elt

const Arrayelt* CxxUtils::Array< 0 >::m_elt
protected

Pointer to this array's single element.

Null if this instance was created using the default constructor.

Definition at line 365 of file Control/CxxUtils/CxxUtils/Array.h.

◆ m_offs

unsigned int CxxUtils::Array< N >::m_offs
protected

Offset in the Arrayrep's data of the first element of this array.

Definition at line 255 of file Control/CxxUtils/CxxUtils/Array.h.

◆ m_rep

const Arrayrep* CxxUtils::Array< N >::m_rep
protected

Pointer to the representation.

Null if this instance was created using the default constructor.

Definition at line 252 of file Control/CxxUtils/CxxUtils/Array.h.

◆ WritableArray< N+1 >

friend CxxUtils::Array< N >::WritableArray< N+1 >
protected

Definition at line 247 of file Control/CxxUtils/CxxUtils/Array.h.


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