TBTK
TBTK::IndexDescriptor Class Reference

Describes the index structure of data stored for several indices. More...

#include <IndexDescriptor.h>

Inheritance diagram for TBTK::IndexDescriptor:
TBTK::Serializable

Public Types

enum  Format { None, Ranges, Custom, Dynamic }
 
- Public Types inherited from TBTK::Serializable
enum  Mode { Debug, Binary, XML, JSON }
 

Public Member Functions

 IndexDescriptor (Format format)
 
 IndexDescriptor (const IndexDescriptor &indexDescriptor)
 
 IndexDescriptor (IndexDescriptor &&indexDescriptor)
 
 IndexDescriptor (const std::string &serialization, Mode mode)
 
 ~IndexDescriptor ()
 
IndexDescriptoroperator= (const IndexDescriptor &rhs)
 
IndexDescriptoroperator= (IndexDescriptor &&rhs)
 
Format getFormat () const
 
unsigned int getDimensions () const
 
void setRanges (const int *ranges, unsigned int dimensions)
 
std::vector< int > getRanges () const
 
void setIndexTree (const IndexTree &indexTree)
 
const IndexTreegetIndexTree () const
 
void add (const Index &index)
 
int getLinearIndex (const Index &index, bool returnNegativeForMissingIndex=false) const
 
unsigned int getSize () const
 
bool contains (const Index &index) const
 
virtual std::string serialize (Mode mode) const
 

Additional Inherited Members

- Static Public Member Functions inherited from TBTK::Serializable
static bool hasID (const std::string &serialization, Mode mode)
 
static std::string getID (const std::string &serialization, Mode mode)
 
static std::string extractComponent (const std::string &serialization, const std::string &containerID, const std::string &componentID, const std::string &componentName, Mode mode)
 
- Static Protected Member Functions inherited from TBTK::Serializable
static bool validate (const std::string &serialization, const std::string &id, Mode mode)
 
static std::string getContent (const std::string &serialization, Mode mode)
 
static std::vector< std::string > split (const std::string &content, Mode mode)
 
static std::string serialize (bool b, Mode mode)
 
static void deserialize (const std::string &serialization, bool *b, Mode mode)
 
static std::string serialize (int i, Mode mode)
 
static void deserialize (const std::string &serialization, int *i, Mode mode)
 
static std::string serialize (unsigned int u, Mode mode)
 
static void deserialize (const std::string &serialization, unsigned int *u, Mode mode)
 
static std::string serialize (double d, Mode mode)
 
static void deserialize (const std::string &serialization, double *d, Mode mode)
 
static std::string serialize (std::complex< double > c, Mode mode)
 
static void deserialize (const std::string &serialization, std::complex< double > *c, Mode mode)
 
static std::string serialize (Statistics s, Mode mode)
 
static void deserialize (const std::string &serialization, Statistics *s, Mode mode)
 
static std::string extract (const std::string &serialization, Mode mode, std::string component)
 

Detailed Description

Describes the index structure of data stored for several indices.

The IndexDescriptor is a helper class for the AbstractProperty to help handle the storage of data using different type of indexing. See AbstractProperty for a description of the various formats.

Member Enumeration Documentation

Enum class determining the storage format.

Constructor & Destructor Documentation

TBTK::IndexDescriptor::IndexDescriptor ( Format  format)

Constructs an IndexDescriptor.

Parameters
formatThe storage format the the IndexDescriptor describes.
TBTK::IndexDescriptor::IndexDescriptor ( const IndexDescriptor indexDescriptor)

Copy constructor.

Parameters
indexDescriptorIndexDescriptor to copy.
TBTK::IndexDescriptor::IndexDescriptor ( IndexDescriptor &&  indexDescriptor)

Move constructor.

Parameters
indexDescriptorIndexDescriptor to move.
TBTK::IndexDescriptor::IndexDescriptor ( const std::string &  serialization,
Mode  mode 
)

Constructor. Construct the IndexDescriptor from a serialization string.

Parameters
serializationSerialization string from which to construct the IndexDescriptor.
modeMode with which the string has been serialized.
TBTK::IndexDescriptor::~IndexDescriptor ( )

Destructor.

Member Function Documentation

void TBTK::IndexDescriptor::add ( const Index index)
inline

Add Index. [Only works for the Dynamic format.]

Parameters
indexIndex to add.
bool TBTK::IndexDescriptor::contains ( const Index index) const
inline

Check whether a given Index is contained in the IndexDescriptor. [Only works for the Custom and Dynamic formats.]

Returns
True if the index descriptor contains the given index.
unsigned int TBTK::IndexDescriptor::getDimensions ( ) const
inline

Set dimensions. Get the number of dimensions for the grid described by the IndexDescriptor. [Only works for the Ranges format.]

Returns
The number of dimensions.
IndexDescriptor::Format TBTK::IndexDescriptor::getFormat ( ) const
inline

Get format.

Returns
The Format that the IndexDescriptor describes.
const IndexTree & TBTK::IndexDescriptor::getIndexTree ( ) const
inline

Get IndexTree. [Only works for the Custom format.]

Returns
An IndexTree containing all the Indices that are described by the IndexDescriptor.
int TBTK::IndexDescriptor::getLinearIndex ( const Index index,
bool  returnNegativeForMissingIndex = false 
) const
inline

Get linear index. [Only works for the Custom and Dynamic formats.]

Parameters
indexThe Index to get the linear Index for.
returnNegativeForMissingIndexIf set to true, requesting an Index that is not included results in -1 being returned. If set to false, an IndexException will be thrown in the same situation.
Returns
The linear index that corresponds to the given Index.
std::vector< int > TBTK::IndexDescriptor::getRanges ( ) const
inline

Get ranges. [Only works for the Ranges format.]

Returns
The upper limits (exclusive) of the grid described by the IndexDescriptor.
unsigned int TBTK::IndexDescriptor::getSize ( ) const

Get the number of data elements described by the IndexDescriptor. For Format::None this is equal to 1, while for the other formats this is equal to the number of Indices that are described by the IndexDescriptor.

Returns
The number of data elements described by the IndexDescriptor.
IndexDescriptor& TBTK::IndexDescriptor::operator= ( const IndexDescriptor rhs)

Assignment operator.

Parameters
rhsIndexDescriptor to assign to the left hand side.
Returns
Reference to the assigned IndexDescriptor.
IndexDescriptor& TBTK::IndexDescriptor::operator= ( IndexDescriptor &&  rhs)

Move assignment operator.

Parameters
rhsIndexDescriptor to assign to the left hand side.
Returns
Reference to the assigned IndexDescriptor.
virtual std::string TBTK::IndexDescriptor::serialize ( Mode  mode) const
virtual

Implements Serializable::serializea().

Implements TBTK::Serializable.

void TBTK::IndexDescriptor::setIndexTree ( const IndexTree indexTree)

Get ranges. Set IndexTree. [Only works for the Custom format.]

Parameters
indexTreeAn IndexTree containing all the Indices that should be described by the IndexDescriptor.
void TBTK::IndexDescriptor::setRanges ( const int *  ranges,
unsigned int  dimensions 
)
inline

Set ranges. [Only works for the Ranges format.]

Parameters
rangesThe upper limits (exlcusive) of the grid described by the IndexDescriptor.
dimensionsThe number of dimensions of the grid. [Should be the same as the number of elements in ranges.)

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