#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 SchemaDef * | getSchemaDef (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) |
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.
using ItemRegistry::Instantiator = Item* (*)() |
Type definition for a function that creates an instance of an Item subclass.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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:
This function is not thread-safe and may be called only during program startup from a single thread.
|
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.
|
static |
This function verifies that all enumeration elements for the enumeration type started by a call to beginEnum() have been added.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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).
|
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.
|
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.
|
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.