The SKIRT project
advanced radiative transfer for astrophysics
Public Types | Static Public Member Functions | Static Private Member Functions | List of all members
ItemRegistry Class Referencefinal

#include <ItemRegistry.hpp>

Public Types

using Instantiator = Item *(*)()
 

Static Public Member Functions

template<class ItemClass >
static void add ()
 
static void addEnum (int enumIndex, const char *enumName, const char *enumTitle)
 
template<class UnitDefClass >
static void addUnitDef ()
 
static void beginEnum (int enumCount)
 
static void beginProperty (const char *type, const char *name, const char *title, const PropertyAccessor *accessor)
 
static void beginSchema (string name, string title, string version, string extension, string root, string type, string format, string url)
 
static void beginType (const char *type, const char *baseType, const char *title, Instantiator instantiator=nullptr)
 
static void endEnum ()
 
static void finalize ()
 
static const SchemaDefgetSchemaDef (string name)
 
static void setBase (const char *type)
 
static void setDefaultValue (const char *value)
 
static void setDisplayedIf (const char *expression)
 
static void setInsert (const char *expression)
 
static void setMaxValue (const char *value)
 
static void setMinValue (const char *value)
 
static void setQuantity (const char *value)
 
static void setRelevantIf (const char *expression)
 
static void setRequiredIf (const char *expression)
 
static void setSubPropertyIndexHere ()
 
static void setTypeAllowedIf (const char *expression)
 
static void setTypeDisplayedIf (const char *expression)
 
static void setTypeInsert (const char *expression)
 

Static Private Member Functions

static void addUnitDefImpl (const UnitDef &unitDef)
 

Detailed Description

The ItemRegistry class offers a set of static functions that manage the global registry of Item subclasses in the program. The functions are grouped in three interfaces with distinct goals:

The first two interfaces set up the global data structures representing the item registry. They are not thread-safe and may be called only during program startup and termination from a single thread. The third interface does not modify the global data structures, and is thus fully thread-safe.

Member Typedef Documentation

◆ Instantiator

Type definition for a function that creates an instance of an Item subclass.

Member Function Documentation

◆ add()

template<class ItemClass >
static void ItemRegistry::add ( )
inlinestatic

This function adds the Item subclass specified as template argument to the current target schema definition in the registry. The function causes the metadata about discoverable properties for the specified class to be loaded into the schema definition. This function is not thread-safe and may be called only during program startup from a single thread.

◆ addEnum()

static void ItemRegistry::addEnum ( int  enumIndex,
const char *  enumName,
const char *  enumTitle 
)
static

This function adds information for one enumeration element to the current target property. Enumeration elements must be added in the order of their definition in the enumeration type. If the invocations does not adhere to this pattern, a fatal error is thrown. The arguments specify the enumeration index (i.e. the integer value underlying the enumeration element), a string version of the enumeration element's identifier, and a user-oriented description of the enumeration element.

◆ addUnitDef()

template<class UnitDefClass >
static void ItemRegistry::addUnitDef ( )
inlinestatic

This function adds the unit and unit system information loaded by the UnitDef subclass specified as template argument to the current target schema definition in the registry. This function is not thread-safe and may be called only during program startup from a single thread.

◆ addUnitDefImpl()

static void ItemRegistry::addUnitDefImpl ( const UnitDef unitDef)
staticprivate

This private function adds the unit and unit system information held by the specified UnitDef subclass instance to the current target schema definition in the registry. This function is not thread-safe and may be called only during program startup from a single thread.

◆ beginEnum()

static void ItemRegistry::beginEnum ( int  enumCount)
static

This function begins the addition of enumeration information to the current target property. The argument specifies the number of elements in the enumeration type. If this number is zero or negative, a fatal error is thrown. An invocation of this function must be followed by one or more calls of the addEnum() function and a single call of the endEnum() function.

◆ beginProperty()

static void ItemRegistry::beginProperty ( const char *  type,
const char *  name,
const char *  title,
const PropertyAccessor accessor 
)
static

This function creates a new property definition and initializes its basic properties as specified by the function arguments. The new property definition becomes the target for subsequent calls to the registry.

◆ beginSchema()

static void ItemRegistry::beginSchema ( string  name,
string  title,
string  version,
string  extension,
string  root,
string  type,
string  format,
string  url 
)
static

This function creates a new, empty SMILE schema definition and initializes its basic properties as specified by the function arguments. The new schema definition becomes the target for any subsequent calls to the add() function. The function arguments specify, in order of occurrence:

  • name: a short name for this schema
  • title: a description of the type of datasets described by this schema
  • version: the version of this schema definition
  • extension: the filename extension for datasets described by this schema
  • root: the name of the root element in datasets described by this schema
  • type: the type of the top-level item in datasets described by this schema
  • format: the version of the described data format (specified on the root element)
  • url: a URL pointing to information on the Web for this schema (or the empty string if not available)

This function is not thread-safe and may be called only during program startup from a single thread.

◆ beginType()

static void ItemRegistry::beginType ( const char *  type,
const char *  baseType,
const char *  title,
Instantiator  instantiator = nullptr 
)
static

This function creates a new type definition and initializes its basic properties as specified by the function arguments. The new type definition becomes the target for subsequent calls to the registry.

◆ endEnum()

static void ItemRegistry::endEnum ( )
static

This function verifies that all enumeration elements for the enumeration type started by a call to beginEnum() have been added.

◆ finalize()

static void ItemRegistry::finalize ( )
static

This function releases the global memory structure representing the registry. This function is not thread-safe; it should be invoked at least once at program termination, after closing down any parallel threads and after the last use of the facilities offered by this class.

◆ getSchemaDef()

static const SchemaDef * ItemRegistry::getSchemaDef ( string  name)
static

This function returns a pointer to the schema definition with the specified name. Ownership remains with the registry. If there is no schema definition with the specified name, the function throws an error.

◆ setBase()

static void ItemRegistry::setBase ( const char *  type)
static

This function sets the name of the base type for the instances of the current target property. This must match one of the type names defined in this schema. This information is relevant only for compound properties (i.e. properties containing other items of some type), and for those properties it should not be left empty.

◆ setDefaultValue()

static void ItemRegistry::setDefaultValue ( const char *  value)
static

This function sets the default value for the property in case the property is missing, in the form of a conditional value expression, which is evaluated against the names inserted elsewhere in this schema definition. Each value in the conditional expression must have a format compatible with the particular property type. If the string is empty, there is no default value.

◆ setDisplayedIf()

static void ItemRegistry::setDisplayedIf ( const char *  expression)
static

This function sets the value of the 'displayedIf' attribute of the current target property, i.e. a Boolean expression using names inserted elsewhere in this schema definition.

◆ setInsert()

static void ItemRegistry::setInsert ( const char *  expression)
static

This function sets the value of the 'insert' attribute of the current target property, i.e. a conditional value expression providing names inserted when a value is entered for the property.

◆ setMaxValue()

static void ItemRegistry::setMaxValue ( const char *  value)
static

This function sets the maximum value for the property, in a format compatible with the particular property type. If the string is empty, the maximum value is determined by the implementation of the property type.

◆ setMinValue()

static void ItemRegistry::setMinValue ( const char *  value)
static

This function sets the minimum value for the property, in a format compatible with the particular property type. If the string is empty, the minimum value is determined by the implementation of the property type.

◆ setQuantity()

static void ItemRegistry::setQuantity ( const char *  value)
static

This function sets the name of the physical quantity represented by this property. This must match one of the quantity names loaded into this schema via the addUnitDef() function and determines the allowed and default units for the property values. If the string is empty, the property values are dimensionless.

◆ setRelevantIf()

static void ItemRegistry::setRelevantIf ( const char *  expression)
static

This function sets the value of the 'relevantIf' attribute of the current target property, i.e. a Boolean expression using names inserted elsewhere in this schema definition.

◆ setRequiredIf()

static void ItemRegistry::setRequiredIf ( const char *  expression)
static

This function sets the value of the 'requiredIf' attribute of the current target property, i.e. a Boolean expression using names inserted elsewhere in this schema definition.

◆ setSubPropertyIndexHere()

static void ItemRegistry::setSubPropertyIndexHere ( )
static

This function sets the index in the property list where properties of subtypes should be listed to the number of properties currently held by the target type definition. This has the effect of listing properties of subtypes just before the next property added to the type definition (or at the end if no further properties are added).

◆ setTypeAllowedIf()

static void ItemRegistry::setTypeAllowedIf ( const char *  expression)
static

This function sets the value of the 'allowedIf' attribute of the current target type, i.e. a Boolean expression using names inserted elsewhere in this schema definition.

◆ setTypeDisplayedIf()

static void ItemRegistry::setTypeDisplayedIf ( const char *  expression)
static

This function sets the value of the 'displayedIf' attribute of the current target type, i.e. a Boolean expression using names inserted elsewhere in this schema definition.

◆ setTypeInsert()

static void ItemRegistry::setTypeInsert ( const char *  expression)
static

This function sets the value of the 'insert' attribute of the current target type, i.e. a conditional value expression providing names inserted when the type is used.


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