The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
PropertyHandler Class Referenceabstract

#include <PropertyHandler.hpp>

Inheritance diagram for PropertyHandler:
Inheritance graph
[legend]

Public Member Functions

 PropertyHandler (const PropertyHandler &)=delete
 
 PropertyHandler (Item *target, const PropertyDef *property, const SchemaDef *schema, NameManager *nameMgr)
 
virtual ~PropertyHandler ()=default
 
virtual void acceptVisitor (PropertyHandlerVisitor *visitor)=0
 
virtual vector< Item * > children () const
 
bool hasChanged () const
 
bool hasDefaultValue () const
 
virtual void insertNames ()=0
 
virtual bool isCompound () const
 
bool isConfigured ()
 
bool isConfiguredByUser ()
 
bool isDisplayed () const
 
bool isRelevant () const
 
bool isRequired () const
 
bool isSilent () const
 
virtual bool isValidValue (string value) const =0
 
string name () const
 
NameManagernameManager () const
 
PropertyHandleroperator= (const PropertyHandler &)=delete
 
void rebuildNames ()
 
Itemroot () const
 
const SchemaDefschema () const
 
void setConfiguredByUser (bool valid=true)
 
void setConfiguredToDefault ()
 
void setNotConfigured ()
 
string title () const
 
string type () const
 

Protected Member Functions

const PropertyDefproperty () const
 
void setChanged ()
 
Itemtarget () const
 

Private Attributes

bool _changed
 
NameManager_nameMgr
 
const PropertyDef_property
 
const SchemaDef_schema
 
Item_target
 

Detailed Description

PropertyHandler is the abstract base class for handling a property of a SMILE data item. There is a specific subclass for each supported property type. A PropertyHandler instance combines knowledge about the schema definition describing the SMILE dataset being handled, the target data item within that dataset, the target property within that item, and the type of that property. The latter aspect is baked into the code of the PropertyHandler subclass in use, while the first three aspects are provided during construction.

Constructor & Destructor Documentation

◆ PropertyHandler() [1/2]

PropertyHandler::PropertyHandler ( Item target,
const PropertyDef property,
const SchemaDef schema,
NameManager nameMgr 
)

Constructs a property handler for the specified target item and property, with a given schema definition. The last argument, a pointer to the name manager used for the current dataset, allows the property handler to access the global and local name sets for evaluating Boolean expressions.

The caller must guarantee that the specified instances are not deleted during the lifetime of the property handler (the property handler does not assume ownership, nor is there a reference counting scheme).

◆ ~PropertyHandler()

virtual PropertyHandler::~PropertyHandler ( )
virtualdefault

Destructs the property handler. This virtual destructor is declared here because PropertyHandler is the top-level class in the hierarchy of property handlers.

◆ PropertyHandler() [2/2]

PropertyHandler::PropertyHandler ( const PropertyHandler )
delete

The copy constructor is deleted because instances of derived classes should never be copied or moved.

Member Function Documentation

◆ acceptVisitor()

virtual void PropertyHandler::acceptVisitor ( PropertyHandlerVisitor visitor)
pure virtual

Accepts the specified property handler visitor. This function is part of the "visitor" design pattern implementation used to handle properties of various types. It must be implemented in every subclass.

Implemented in BoolPropertyHandler, DoubleListPropertyHandler, DoublePropertyHandler, EnumPropertyHandler, IntPropertyHandler, ItemListPropertyHandler, ItemPropertyHandler, and StringPropertyHandler.

◆ children()

virtual vector< Item * > PropertyHandler::children ( ) const
virtual

Returns a list of SMILE data items including the immediate children of the target item in the dataset in which the target item resides. The default implementation in this abstract class returns an empty list.

Reimplemented in ItemListPropertyHandler, and ItemPropertyHandler.

◆ hasChanged()

bool PropertyHandler::hasChanged ( ) const

Returns true if the value of the target property has been modified by this handler; otherwise returns false.

◆ hasDefaultValue()

bool PropertyHandler::hasDefaultValue ( ) const

Returns true if the handled property has a valid default value in the current dataset configuration, or false if not. A property that does not have the "default" attribute does not have a default value. A property that has the "default" attribute has a default value if the provided conditional value expression evaluates to a valid value for the property type, after replacing names currently present in the global or local name sets by true, and other names by false.

◆ insertNames()

virtual void PropertyHandler::insertNames ( )
pure virtual

Causes the name manager associated with this handler to insert names into the global and/or local name sets corresponding to the current value of the target property. Because the list of inserted names depends on the property type, this function must be implemented in every subclass.

Implemented in BoolPropertyHandler, DoubleListPropertyHandler, DoublePropertyHandler, EnumPropertyHandler, IntPropertyHandler, ItemListPropertyHandler, ItemPropertyHandler, and StringPropertyHandler.

◆ isCompound()

virtual bool PropertyHandler::isCompound ( ) const
virtual

Returns true if the handled property type is compound in the sense that the property may hold (in other words, aggregate) other items that are part of the item hierarchy. The default implementation in this abstract class returns false, which is appropriate for plain, non-compound property types. This function must be overridden by property handler subclasses that implement compound property types.

Reimplemented in AbstractItemPropertyHandler.

◆ isConfigured()

bool PropertyHandler::isConfigured ( )

This function returns true if the configured state for the target property indicates configuration with a valid value, i.e. if it is "Configured to default" or "Configured by the user with a valid value". Otherwise the function returns false.

◆ isConfiguredByUser()

bool PropertyHandler::isConfiguredByUser ( )

This function returns true if the configured state for the target property is "Configured by user", regardless whether the value is valid or invalid, and false otherwise.

◆ isDisplayed()

bool PropertyHandler::isDisplayed ( ) const

Returns true if the handled property should be displayed in the current dataset configuration. A property that does not have the "displayedIf" attribute is always displayed. A property that has the "displayedIf" attribute is displayed if the provided Boolean expression evaluates to true, after replacing names currently present in the global or local name sets by true, and other names by false.

◆ isRelevant()

bool PropertyHandler::isRelevant ( ) const

Returns true if the handled property is relevant in the current dataset configuration. A property that does not have the "relevantIf" attribute is always relevant. A property that has the "relevantIf" attribute is relevant if the provided Boolean expression evaluates to true, after replacing names currently present in the global or local name sets by true, and other names by false.

◆ isRequired()

bool PropertyHandler::isRequired ( ) const

Returns true if the handled property is required to have a nonempty value in the current dataset configuration. A property that does not have the "requiredIf" attribute is always required. A property that has the "requiredIf" attribute is required if the provided Boolean expression evaluates to true, after replacing names currently present in the global or local name sets by true, and other names by false. The "requiredIf" attribute (and thus the return value of this function) is intended for complex property types including strings, compound types, and lists. Scalar numeric and enumeration property types ignore its value.

◆ isSilent()

bool PropertyHandler::isSilent ( ) const

Returns true if the handled property can be considered to be "silent" for interactive purposes. An irrelevant property is always silent. A property that should not be displayed is silent unless it is required and has no default value.

◆ isValidValue()

virtual bool PropertyHandler::isValidValue ( string  value) const
pure virtual

Returns true if the given string can be successfully converted to a value of the property's type. For an empty string, the function always returns false. This function must be overridden by property handler subclasses.

Implemented in AbstractItemPropertyHandler, BoolPropertyHandler, DoubleListPropertyHandler, DoublePropertyHandler, EnumPropertyHandler, IntPropertyHandler, and StringPropertyHandler.

◆ name()

string PropertyHandler::name ( ) const

Returns the name of the handled property.

◆ nameManager()

NameManager * PropertyHandler::nameManager ( ) const
inline

Returns the name manager for the SMILE dataset in which the target item resides.

◆ operator=()

PropertyHandler & PropertyHandler::operator= ( const PropertyHandler )
delete

The assignment operator is deleted because instances of derived classes should never be copied or moved.

◆ property()

const PropertyDef * PropertyHandler::property ( ) const
inlineprotected

Returns the property definition for the SMILE property being handled.

◆ rebuildNames()

void PropertyHandler::rebuildNames ( )

This function rebuilds the global and local name sets in the name manager associated with this handler so that they reflect the contents of the dataset in which the target item resides, up to (and not including) the target item. To this end, the function performs a depth-first traversal of the dataset; properties at the same level are scanned in schema definition order, and children of an item list are scanned in order of dataset occurrence.

◆ root()

Item * PropertyHandler::root ( ) const

Returns the SMILE data item that sits at the root of the dataset in which the target item resides, i.e. the recursive ancestor item that has no parent.

◆ schema()

const SchemaDef * PropertyHandler::schema ( ) const
inline

Returns the schema definition describing the SMILE dataset in which the target item resides.

◆ setChanged()

void PropertyHandler::setChanged ( )
protected

Sets the flag indicating that the value of the target property has been modified by this handler, and invokes the insertNames() function. Subclasses must call this function when the target property is updated.

◆ setConfiguredByUser()

void PropertyHandler::setConfiguredByUser ( bool  valid = true)

This function sets the configured state for the target property to "Configured by the user with a valid value" or "Configured by the user with an invalid value", depending on the value of the valid argument. If the argument is omitted, it default to true.

◆ setConfiguredToDefault()

void PropertyHandler::setConfiguredToDefault ( )

This function sets the configured state for the target property to "Configured to default".

◆ setNotConfigured()

void PropertyHandler::setNotConfigured ( )

This function sets the configured state for the target property to "Not configured". This corresponds to the automatic initial state at the start of the editing session.

◆ target()

Item * PropertyHandler::target ( ) const
inlineprotected

Returns the SMILE data item for which a property is being handled.

◆ title()

string PropertyHandler::title ( ) const

Returns the title (used for display to a user) for the handled property.

◆ type()

string PropertyHandler::type ( ) const

Returns the type of the target item.


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