AvogadroLibs 2.1.0-20261111
Loading...
Searching...
No Matches
PropertyMap Class Reference

A typed column store for per-entity custom properties. More...

#include <avogadro/core/propertymap.h>

Public Member Functions

void setDouble (const std::string &name, Index index, double value)
void setInt (const std::string &name, Index index, int value)
void setString (const std::string &name, Index index, const std::string &value)
void setMatrix (const std::string &name, Index index, const MatrixX &value)
std::optional< double > getDouble (const std::string &name, Index index) const
std::optional< int > getInt (const std::string &name, Index index) const
std::optional< std::string > getString (const std::string &name, Index index) const
std::optional< MatrixX > getMatrix (const std::string &name, Index index) const
void createDoubles (const std::string &name, Index count)
void createInts (const std::string &name, Index count)
void createStrings (const std::string &name, Index count)
void setDoubles (const std::string &name, const Array< double > &values)
const Array< double > & doubles (const std::string &name) const
void setInts (const std::string &name, const Array< int > &values)
const Array< int > & ints (const std::string &name) const
void setStrings (const std::string &name, const Array< std::string > &values)
const Array< std::string > & strings (const std::string &name) const
const std::unordered_map< Index, MatrixX > & matrices (const std::string &name) const
bool hasDoubles (const std::string &name) const
bool hasInts (const std::string &name) const
bool hasStrings (const std::string &name) const
bool hasMatrix (const std::string &name, Index index) const
bool hasMatrices (const std::string &name) const
std::set< std::string > doubleNames () const
std::set< std::string > intNames () const
std::set< std::string > stringNames () const
std::set< std::string > matrixNames () const
void addEntry (Index entityCount)
void removeEntry (Index index, Index entityCount)
void swapEntries (Index a, Index b, Index entityCount)
void clear ()
bool empty () const

Detailed Description

PropertyMap stores named columns of per-entity data (e.g., per-atom, per-bond, or per-residue). It supports four column types:

  • double — dense, stored in Array<double> (NaN sentinel internally)
  • int — dense, stored in Array<int> (INT_MIN sentinel internally)
  • std::string — dense, stored in Array<std::string> ("" sentinel)
  • MatrixX — sparse, stored in std::unordered_map<Index, MatrixX>

Dense columns are always sized to the entity count. Sparse matrix columns only store entries for entities that have data.

Public getters return std::optional<T>, returning std::nullopt for missing values or type mismatches. Sentinels are an internal storage detail.

Member Function Documentation

◆ setDouble()

void setDouble ( const std::string & name,
Index index,
double value )

Set a double property value for entity at index.

◆ setInt()

void setInt ( const std::string & name,
Index index,
int value )

Set an int property value for entity at index.

◆ setString()

void setString ( const std::string & name,
Index index,
const std::string & value )

Set a string property value for entity at index.

◆ setMatrix()

void setMatrix ( const std::string & name,
Index index,
const MatrixX & value )

Set a matrix property value for entity at index (sparse).

◆ getDouble()

std::optional< double > getDouble ( const std::string & name,
Index index ) const
Returns
the double value for name at index, or nullopt.

◆ getInt()

std::optional< int > getInt ( const std::string & name,
Index index ) const
Returns
the int value for name at index, or nullopt.

◆ getString()

std::optional< std::string > getString ( const std::string & name,
Index index ) const
Returns
the string value for name at index, or nullopt.

◆ getMatrix()

std::optional< MatrixX > getMatrix ( const std::string & name,
Index index ) const
Returns
the matrix value for name at index, or nullopt.

◆ createDoubles()

void createDoubles ( const std::string & name,
Index count )

Create an empty dense double column named name with count entries, all unset (getDouble() returns nullopt until a value is assigned). An existing column of the same name is left unchanged.

◆ setDoubles()

void setDoubles ( const std::string & name,
const Array< double > & values )

Set an entire column of double values.

◆ doubles()

const Array< double > & doubles ( const std::string & name) const
Returns
the full double column for name, or empty array if absent.

◆ setInts()

void setInts ( const std::string & name,
const Array< int > & values )

Set an entire column of int values.

◆ ints()

const Array< int > & ints ( const std::string & name) const
Returns
the full int column for name, or empty array if absent.

◆ setStrings()

void setStrings ( const std::string & name,
const Array< std::string > & values )

Set an entire column of string values.

◆ strings()

const Array< std::string > & strings ( const std::string & name) const
Returns
the full string column for name, or empty array if absent.

◆ matrices()

const std::unordered_map< Index, MatrixX > & matrices ( const std::string & name) const
Returns
the sparse matrix column for name, or an empty map if absent.

◆ hasDoubles()

bool hasDoubles ( const std::string & name) const
Returns
true if a double column named name exists.

◆ hasInts()

bool hasInts ( const std::string & name) const
Returns
true if an int column named name exists.

◆ hasStrings()

bool hasStrings ( const std::string & name) const
Returns
true if a string column named name exists.

◆ hasMatrix()

bool hasMatrix ( const std::string & name,
Index index ) const
Returns
true if a matrix entry exists for name at index.

◆ hasMatrices()

bool hasMatrices ( const std::string & name) const
Returns
true if any matrix column named name exists.

◆ doubleNames()

std::set< std::string > doubleNames ( ) const
Returns
names of all double columns.

◆ intNames()

std::set< std::string > intNames ( ) const
Returns
names of all int columns.

◆ stringNames()

std::set< std::string > stringNames ( ) const
Returns
names of all string columns.

◆ matrixNames()

std::set< std::string > matrixNames ( ) const
Returns
names of all matrix columns.

◆ addEntry()

void addEntry ( Index entityCount)

Append a default entry to all existing dense columns. New columns are not created; only columns that already exist are extended. entityCount is the count after addition, so the new entity's index is entityCount - 1. Any entry already at or past that index is dropped first, so the new entity never inherits a stale value.

◆ removeEntry()

void removeEntry ( Index index,
Index entityCount )

Remove the entry at index using swap-and-pop. entityCount is the count before removal (used to check if columns are at full size).

◆ swapEntries()

void swapEntries ( Index a,
Index b,
Index entityCount )

Swap entries at indices a and b. entityCount is the current entity count (used to check column sizes).

◆ clear()

void clear ( )

Clear all columns and data.

◆ empty()

bool empty ( ) const
Returns
true if no columns exist.

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