TBTK
Need a break? Support the development by playing Polarity Puzzles
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 ()
 
 IndexDescriptor (const std::vector< int > &ranges)
 
 IndexDescriptor (const IndexTree &indexTree)
 
 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
 
std::vector< int > getRanges () const
 
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
 
- Public Member Functions inherited from TBTK::Serializable
template<>
std::string serialize (const bool &data, Mode mode)
 
template<>
std::string serialize (const double &data, Mode mode)
 
template<>
std::string serialize (const std::complex< double > &data, Mode mode)
 
template<>
std::string serialize (const int &data, Mode mode)
 
template<>
std::string serialize (const unsigned int &data, Mode mode)
 
template<>
std::string serialize (const SpinMatrix &data, Mode mode)
 
template<>
std::string serialize (const Statistics &data, Mode mode)
 
template<>
std::string serialize (const std::vector< std::complex< double >> &data, Mode mode)
 
template<>
int deserialize (const std::string &serialization, Mode mode)
 
template<>
unsigned int deserialize (const std::string &serialization, Mode mode)
 
template<>
double deserialize (const std::string &serialization, Mode mode)
 
template<>
std::complex< double > deserialize (const std::string &serialization, Mode mode)
 
template<>
SpinMatrix deserialize (const std::string &serialization, Mode mode)
 
template<>
Statistics deserialize (const std::string &serialization, Mode mode)
 
template<>
std::vector< std::complex< double > > deserialize (const std::string &serialization, Mode mode)
 

Friends

bool operator== (const IndexDescriptor &lhs, const IndexDescriptor &rhs)
 
bool operator!= (const IndexDescriptor &lhs, const IndexDescriptor &rhs)
 

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)
 
template<typename DataType >
static std::enable_if<!std::is_pointer< DataType >::value, std::string >::type serialize (const DataType &data, Mode mode)
 
template<typename DataType >
static std::enable_if< std::is_pointer< DataType >::value, std::string >::type serialize (const DataType &data, Mode mode)
 
template<typename DataType >
static DataType deserialize (const std::string &serialization, 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

◆ Format

Enum class determining the storage format.

Constructor & Destructor Documentation

◆ IndexDescriptor() [1/6]

TBTK::IndexDescriptor::IndexDescriptor ( )

Constructs an IndexDescriptor on the Format::None.

◆ IndexDescriptor() [2/6]

TBTK::IndexDescriptor::IndexDescriptor ( const std::vector< int > &  ranges)

Constructs an IndexDescriptor on the Format::Ranges.

Parameters
rangesThe upper limits (exlcusive) of the grid described by the IndexDescriptor.

◆ IndexDescriptor() [3/6]

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

Constructs an IndexDescriptor on the Format::Custom.

Parameters
indexTreeAn IndexTree containing all the Indices that should be described by the IndexDescriptor.

◆ IndexDescriptor() [4/6]

TBTK::IndexDescriptor::IndexDescriptor ( const IndexDescriptor indexDescriptor)

Copy constructor.

Parameters
indexDescriptorIndexDescriptor to copy.

◆ IndexDescriptor() [5/6]

TBTK::IndexDescriptor::IndexDescriptor ( IndexDescriptor &&  indexDescriptor)

Move constructor.

Parameters
indexDescriptorIndexDescriptor to move.

◆ IndexDescriptor() [6/6]

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.

◆ ~IndexDescriptor()

TBTK::IndexDescriptor::~IndexDescriptor ( )

Destructor.

Member Function Documentation

◆ add()

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

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

Parameters
indexIndex to add.

◆ contains()

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.

◆ getFormat()

IndexDescriptor::Format TBTK::IndexDescriptor::getFormat ( ) const
inline

Get format.

Returns
The Format that the IndexDescriptor describes.

◆ getIndexTree()

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.

◆ getLinearIndex()

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.

◆ getRanges()

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.

◆ getSize()

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.

◆ operator=() [1/2]

IndexDescriptor& TBTK::IndexDescriptor::operator= ( const IndexDescriptor rhs)

Assignment operator.

Parameters
rhsIndexDescriptor to assign to the left hand side.
Returns
Reference to the assigned IndexDescriptor.

◆ operator=() [2/2]

IndexDescriptor& TBTK::IndexDescriptor::operator= ( IndexDescriptor &&  rhs)

Move assignment operator.

Parameters
rhsIndexDescriptor to assign to the left hand side.
Returns
Reference to the assigned IndexDescriptor.

◆ serialize()

virtual std::string TBTK::IndexDescriptor::serialize ( Mode  mode) const
virtual

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const IndexDescriptor lhs,
const IndexDescriptor rhs 
)
friend

Inequality operator.

Parameters
rhsLeft hand side of the inequality sign.
rhsRight hand side of the inequality sign.
Returns
False if the IndexDescriptors describe identical index structures, otherwise true.

◆ operator==

bool operator== ( const IndexDescriptor lhs,
const IndexDescriptor rhs 
)
friend

Comparison operator.

Parameters
rhsLeft hand side of the equality sign.
rhsRight hand side of the equality sign.
Returns
True if the IndexDescriptors describe identical index structures, otherwise false.

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