Enzo
Loading...
Searching...
No Matches
StyleAccess.h File Reference
#include "Engine/Parameter/Parameter.h"
#include "Engine/Parameter/Styles.h"
#include "Engine/Parameter/Template.h"
#include <any>
#include <memory>
#include <optional>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>

Go to the source code of this file.

Functions

std::vector< std::string > enzo::prm::style::splitNames (const std::string &text)
 Returns the names in a option written as a space separated list.
 
std::vector< attr::AttributeOwnerenzo::prm::style::parseOwners (const std::string &text)
 Returns the attribute owners a option names, e.g. "point vertex".
 
std::vector< attr::AttributeTypeenzo::prm::style::parseAttributeTypes (const std::string &text)
 Returns the attribute types a option names, e.g. "float vector".
 
std::optional< std::string > enzo::prm::style::getReferencedParameterName (const std::string &text)
 Returns the name of the parameter a option reads its value from.
 
void enzo::prm::style::attachStyle (prm::Template &parameter, const std::string &styleName)
 Attaches the style a node.yaml name asks for.
 
template<typename T >
bool enzo::prm::style::holds (const std::any &style)
 Returns whether a style is of a particular kind.
 
std::string enzo::prm::style::toString (const std::any &style)
 Returns the name a style is written under in node.yaml, e.g. "boolIcon".
 
std::vector< std::shared_ptr< prm::Parameter > > enzo::prm::style::options (const std::any &style)
 Returns the options a style exposes to node.yaml.
 
template<typename Parse >
void enzo::prm::style::validateOption (const std::string &optionValue, const std::vector< const prm::Template * > &parameters, Parse parseValue)
 Checks the value a style option holds.
 
void enzo::prm::style::validateOptions (const std::any &style, const std::vector< const prm::Template * > &parameters)
 Checks the values a style's options hold.
 
std::shared_ptr< prm::Parameterenzo::prm::style::getOption (const std::any &style, const std::string &name)
 Returns the option a style exposes under a name, e.g. "scale".
 

Detailed Description

Reads and checks a parameter style and the values its options hold. The styles themselves are in Styles.h.

Function Documentation

◆ attachStyle()

void enzo::prm::style::attachStyle ( prm::Template & parameter,
const std::string & styleName )
inline

Attaches the style a node.yaml name asks for.

Note
An unknown name throws.

◆ getOption()

std::shared_ptr< prm::Parameter > enzo::prm::style::getOption ( const std::any & style,
const std::string & name )
inline

Returns the option a style exposes under a name, e.g. "scale".

Returns
The option, or null when the style has none by that name.

◆ getReferencedParameterName()

std::optional< std::string > enzo::prm::style::getReferencedParameterName ( const std::string & text)
inline

Returns the name of the parameter a option reads its value from.

getReferencedParameterName("prm(attachTo)") gives "attachTo", while a literal such as "point vertex" gives nothing.

◆ options()

std::vector< std::shared_ptr< prm::Parameter > > enzo::prm::style::options ( const std::any & style)
inline

Returns the options a style exposes to node.yaml.

Returns
The options, empty when the style takes none.
Note
The options stay shared with the style, so writing one lands on the style itself.

◆ parseAttributeTypes()

std::vector< attr::AttributeType > enzo::prm::style::parseAttributeTypes ( const std::string & text)
inline

Returns the attribute types a option names, e.g. "float vector".

Note
The name "all" stands for every type. An unknown name throws.

◆ parseOwners()

std::vector< attr::AttributeOwner > enzo::prm::style::parseOwners ( const std::string & text)
inline

Returns the attribute owners a option names, e.g. "point vertex".

Note
The name "all" stands for every owner. An unknown name throws.

◆ splitNames()

std::vector< std::string > enzo::prm::style::splitNames ( const std::string & text)
inline

Returns the names in a option written as a space separated list.

splitNames("point vertex") gives {"point", "vertex"}.

◆ toString()

std::string enzo::prm::style::toString ( const std::any & style)
inline

Returns the name a style is written under in node.yaml, e.g. "boolIcon".

Returns
The name, or empty when there is no style.

◆ validateOption()

template<typename Parse >
void enzo::prm::style::validateOption ( const std::string & optionValue,
const std::vector< const prm::Template * > & parameters,
Parse parseValue )

Checks the value a style option holds.

An option written as prm(name) is checked against every choice the dropdown it names offers.

Note
A value the option cannot read, or a reference to a parameter the node does not have, throws.

◆ validateOptions()

void enzo::prm::style::validateOptions ( const std::any & style,
const std::vector< const prm::Template * > & parameters )
inline

Checks the values a style's options hold.

Parameters
parametersEvery parameter on the node holding the style.