mmcfilters
Public API documentation
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
mmcfilters::AttributeNames Class Reference

Layout object that maps scalar attributes to flat-buffer offsets. More...

#include <AttributeNames.hpp>

Public Member Functions

 AttributeNames (std::unordered_map< Attribute, int > &&map)
 Constructs a layout from an already validated offset map.
 
int getIndex (Attribute attr) const
 Returns the per-node offset associated with attr.
 
bool contains (Attribute attr) const noexcept
 Returns whether this layout contains attr.
 
int offset (Attribute attr) const
 Returns the per-node offset associated with attr.
 
int linearIndex (int nodeIndex, Attribute attr) const
 Returns the linear index in the flat buffer for (node, attr).
 

Static Public Member Functions

static AttributeNames fromList (const std::vector< Attribute > &attributes)
 Builds a dense layout from an explicit attribute list.
 
static AttributeNames fromGroup (AttributeGroup group)
 Builds a layout from a public attribute group.
 
static std::string toString (Attribute attr)
 Returns the stable symbolic name associated with attr.
 
static std::string describe (Attribute attr)
 Returns a user-facing description of an attribute.
 
static std::optional< Attribute > parse (const std::string &str)
 Parses a stable symbolic attribute name.
 

Public Attributes

std::unordered_map< Attribute, intindexMap
 Maps each requested attribute to its per-node offset.
 
const int NUM_ATTRIBUTES
 Number of scalar attributes stored for each node.
 

Detailed Description

Layout object that maps scalar attributes to flat-buffer offsets.

AttributeNames describes the in-memory arrangement of a node-attribute buffer. The layout is node-major:

NUM_ATTRIBUTES is therefore the per-node stride needed to jump from the attributes of one node to the next. The actual number of floats in a buffer is numNodes * NUM_ATTRIBUTES.

The class is deliberately lightweight because it is shared across most of the incremental attribute pipeline, dependency maps, and Python bindings.

Definition at line 162 of file AttributeNames.hpp.

Constructor & Destructor Documentation

◆ AttributeNames()

mmcfilters::AttributeNames::AttributeNames ( std::unordered_map< Attribute, int > &&  map)
inline

Constructs a layout from an already validated offset map.

The constructor takes ownership of map and derives the per-node stride from its final size.

Parameters
mapMapping used to initialize the layout.

Definition at line 178 of file AttributeNames.hpp.

Member Function Documentation

◆ contains()

bool mmcfilters::AttributeNames::contains ( Attribute  attr) const
inlinenoexcept

Returns whether this layout contains attr.

Parameters
attrAttribute requested by the operation.
Returns
Whether this layout contains attr.

Definition at line 226 of file AttributeNames.hpp.

◆ describe()

static std::string mmcfilters::AttributeNames::describe ( Attribute  attr)
inlinestatic

Returns a user-facing description of an attribute.

The descriptions are intentionally richer than toString(...) and are meant for documentation, notebooks, and Python introspection helpers.

Parameters
attrAttribute requested by the operation.
Returns
A user-facing description of an attribute.

Definition at line 263 of file AttributeNames.hpp.

◆ fromGroup()

static AttributeNames mmcfilters::AttributeNames::fromGroup ( AttributeGroup  group)
inlinestatic

Builds a layout from a public attribute group.

Parameters
groupPublic attribute group.
Returns
The resulting layout from a public attribute group.

Definition at line 206 of file AttributeNames.hpp.

◆ fromList()

static AttributeNames mmcfilters::AttributeNames::fromList ( const std::vector< Attribute > &  attributes)
inlinestatic

Builds a dense layout from an explicit attribute list.

Duplicate attributes are rejected because a repeated key would make the flat-buffer stride disagree with the lookup table.

Parameters
attributesAttributes requested by the operation.
Returns
The resulting dense layout from an explicit attribute list.

Definition at line 189 of file AttributeNames.hpp.

◆ getIndex()

int mmcfilters::AttributeNames::getIndex ( Attribute  attr) const
inline

Returns the per-node offset associated with attr.

Parameters
attrAttribute requested by the operation.
Returns
The per-node offset associated with attr.

Definition at line 218 of file AttributeNames.hpp.

◆ linearIndex()

int mmcfilters::AttributeNames::linearIndex ( int  nodeIndex,
Attribute  attr 
) const
inline

Returns the linear index in the flat buffer for (node, attr).

Parameters
nodeIndexIndex.
attrAttribute requested by the operation.
Returns
The linear index in the flat buffer for (node, attr).

Definition at line 243 of file AttributeNames.hpp.

◆ offset()

int mmcfilters::AttributeNames::offset ( Attribute  attr) const
inline

Returns the per-node offset associated with attr.

Parameters
attrAttribute requested by the operation.
Returns
The per-node offset associated with attr.

Definition at line 234 of file AttributeNames.hpp.

◆ parse()

static std::optional< Attribute > mmcfilters::AttributeNames::parse ( const std::string &  str)
inlinestatic

Parses a stable symbolic attribute name.

Parameters
strSymbolic attribute name to parse.
Returns
The matching attribute when str names a known descriptor, or std::nullopt otherwise.

Definition at line 273 of file AttributeNames.hpp.

◆ toString()

static std::string mmcfilters::AttributeNames::toString ( Attribute  attr)
inlinestatic

Returns the stable symbolic name associated with attr.

Parameters
attrAttribute requested by the operation.
Returns
The stable symbolic name associated with attr.

Definition at line 251 of file AttributeNames.hpp.

Member Data Documentation

◆ indexMap

std::unordered_map<Attribute, int> mmcfilters::AttributeNames::indexMap

Maps each requested attribute to its per-node offset.

Definition at line 165 of file AttributeNames.hpp.

◆ NUM_ATTRIBUTES

const int mmcfilters::AttributeNames::NUM_ATTRIBUTES

Number of scalar attributes stored for each node.

Definition at line 168 of file AttributeNames.hpp.


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