-
Notifications
You must be signed in to change notification settings - Fork 0
API: Definitions, Sources and Factories
#Overview Scriptable objects only exist at runtime. They are not C++ data types and may not be directly declared and initialized in your client code. Instead we create an object source and pass that to the object factory which returns us the object.
All object sources are derived from ScriptObjectDefinition and ScriptObjectSource, these two base classes allow the object factory to query the number of fields, their names and types and ultimately create the new object.
##Object Definitions
ScriptObjectDefinition exposes the fundamental methods to determine the number of fields, their names and their types in the source object. The class does not expose object instance values, it is used solely to infer the object signature based on its name and type components.
In addition the class can calculate a hash based on the field names and types which can be used by libscriptobject to look up metadata associated with the object (e.g. common keys).
The class is defined as follows:
class ScriptObjectDefinition {
public:
virtual unsigned count() const = 0;
virtual ScriptObjectType type(int index) const = 0;
virtual const char* name(int index) const = 0;
virtual unsigned length(int index) const = 0;
void CalculateHash(ScriptObjectHash digest) const;
};-
countreturns the number of fields in the object. -
typereturns the type of the field at the supplied index. -
namereturns the null terminated name of the field andlengththe number of characters occupied by thename.