PropertyBlock.h header

#include <ew/core/PropertyBlock.h>

Namespace ew::core

PropertyBlock class

class ew::core::PropertyBlock

A named, reusable group of properties, usable anywhere a single property can go.

The thing a naming convention was standing in for. A set of related facts – physical stats, a cost breakdown, a pair of coordinates – had to be modelled as loose keys called statsStr, statsDex and so on, held together by nothing but the spelling. Nothing could add a seventh stat to every character at once, nothing could say "this list holds coordinates", and an export handed a consumer a flat bag of keys to reassemble by convention.

A block is defined ONCE and used as a field type. Adding a field to the block gives it to every property that uses the block, wherever it sits – which is the whole reason it is a definition rather than a template that dissolves on use, as ew::core::entity::EntityTemplate does.

Blocks may nest: a field inside a block may itself be a Block. The nesting is finite because a block cannot contain itself, directly or through a chain (see ew::core::taxonomy::blockCycle).

Members

ew::core::taxonomy::PropertyBlock::PropertyBlock(ew::core::foundation::BlockId id, QString name)

Creates a block with stable id and display name.

ew::core::foundation::BlockId ew::core::taxonomy::PropertyBlock::id() const

The stable identity a field points at. Immutable, so renaming the block keeps every use.

const QString & ew::core::taxonomy::PropertyBlock::name() const

The human-readable name shown wherever the block is offered or edited.

void ew::core::taxonomy::PropertyBlock::setName(QString name)

Sets the block's display name.

const QString & ew::core::taxonomy::PropertyBlock::description() const

Optional help text explaining what the block is for.

void ew::core::taxonomy::PropertyBlock::setDescription(QString description)

Sets the block's help text.

const std::vector< FieldDefinition > & ew::core::taxonomy::PropertyBlock::fields() const

The block's own properties, in the order an author arranged them.

Order is data: a Stats block reading strength, dexterity, constitution is one a reader can scan, and one that reorders itself between two entities is not.

void ew::core::taxonomy::PropertyBlock::setFields(std::vector< FieldDefinition > fields)

Replaces the block's properties.

const FieldDefinition * ew::core::taxonomy::PropertyBlock::field(const QString &key) const

The field with key, or null when the block has none.

Constants

char16_t ew::core::taxonomy::kPathSeparator = u'.'

The separator between the steps of a value path – "stats.strength".

A path is how anything outside the codex reaches inside a block: a validation rule, a rollup, a search, an export column. Named here rather than spelled inline in each of them, because the day one of them spells it differently is the day a rule silently matches nothing.