![]() |
ImFusion SDK 4.3
|
#include <AnatomyPlugin/include/ImFusion/AnatomyPlugin/Selector.h>
Class for querying objects. More...
Class for querying objects.
This class is modeled after the CSS concept of a selector. Objects either "match" or do not "match" a selector. The match function obtains (in each case optionally) an identifier, anatomical structure (to query its attribute()), content-type, key (i.e. KeyValueStore key), the attributes() of the KeyValueStore entry, and a set of modifiers (referred to as "pseudo-classes" in analogy to CSS. Members that are std::nullopt are ignored, other members are combined with a logical AND.
Public Member Functions | |
| SelectorElem (std::optional< AnatomicalStructure::ContentType > ct={}, std::optional< std::string > identifier={}, std::optional< std::string > key={}, std::optional< std::pair< std::string, std::string > > attributeStructure=std::nullopt, std::optional< std::pair< std::string, std::string > > attributeObject=std::nullopt, std::set< std::string > pseudoClasses={}) | |
| Base constructor allowing specification of all member variables. | |
| bool | match (const std::string &identifier, const Properties &attributesStructure, std::optional< AnatomicalStructure::ContentType > ct, const std::string &key, const Properties &attributesObject, const std::set< std::string > &pseudoClasses) const |
| Returns true, if the given object in the given setting matches the selector. | |
| std::string | str () const |
| Returns a string representation of the selector. This is the inverse of the parse function. | |
Static Public Member Functions | |
| static std::optional< SelectorElem > | parse (const std::string &str) |
| Parse a string into a SelectorElem. | |
| static SelectorElem | contentTypeSelector (AnatomicalStructure::ContentType ct) |
| Utility function to create a Selector to only match by content type. | |
| static SelectorElem | attributesStructureSelector (std::pair< std::string, std::string > attr) |
| Utility function to create a Selector to only match by AnatomicalStructure::attributes() | |
| static SelectorElem | attributesObjectSelector (std::pair< std::string, std::string > attr) |
| Utility function to create a Selector to only match by KeyValueStore::Entry::attributes() | |
| static SelectorElem | pseudoClassesSelector (std::set< std::string > classes) |
| Utility function to create a Selector to match with a set of pseudo-classes. | |
| static SelectorElem | wildcardSelector () |
| Utility function to create a Selector to match with everything. | |
Public Attributes | |
| std::optional< AnatomicalStructure::ContentType > | m_ct |
| Content type to match. | |
| std::optional< std::string > | m_identifier |
| AnatomicalStructure::identifier() to match. | |
| std::optional< std::string > | m_key |
| AnatomicalStructure::KeyValueStore<ContentType>::key to match. | |
| std::optional< std::pair< std::string, std::string > > | m_attributesStructure |
| AnatomicalStructure::attributes() to match. | |
| std::optional< std::pair< std::string, std::string > > | m_attributesObject |
| AnatomicalStructure::KeyValueStore<ContentType>::Entry::attributes() to match. | |
| std::set< std::string > | m_pseudoClasses |
| Set of pseudo-classes to match, e.g. "focus" for the ":focus" pseudo-class. | |
|
explicit |
Base constructor allowing specification of all member variables.
Members that are std::nullopt are ignored during matching, other members must all match (logical AND).
|
static |
Parse a string into a SelectorElem.
| bool match | ( | const std::string & | identifier, |
| const Properties & | attributesStructure, | ||
| std::optional< AnatomicalStructure::ContentType > | ct, | ||
| const std::string & | key, | ||
| const Properties & | attributesObject, | ||
| const std::set< std::string > & | pseudoClasses ) const |
Returns true, if the given object in the given setting matches the selector.
Members that are std::nullopt are ignored during matching, other members must all match (logical AND).