The DOM or Data Object Model (not to be confused with the GOM) is a collection of dynamic definition objects. The DOM is where node classes are created and defined, fields in those classes are further specified, certain field values are enumerated, and prototypes are created. GOM data is then placed in those fields.
- Changes to DOM structure can be modified by the CLI or the DOM Editor
- GOM data, on the other hand, can be modified from the CLI, or also from the HSL scripting language.
- DOM structures cannot be modified from HSL.
- Different versions of the DOM exist on the client and server, each of which is stored in a separate database schema, for client or server, as appropriate.
Structure of a node
- A GOM node is always created based on a class, a prototype, or another node.
- Each node is defined by one or more classes, each of which has been based on a particular Archetype.
- A node can have multiple classes.
- A node's fields are directly dependent on which classes it has
- Each field can contain different types of data, depending on the field datatype.
- Fields are associated with classes. A node cannot have a field, unless that field is part of a class which is on the node. Once a class is attached to a node, that node then has access to all the fields of that class.
- If multiple classes on a node duplicate the same field, the node only has access to one field of that type -- it doesn't have duplicate fields.
Prototypes are a combination of DOM structure and GOM data. For more information, see the section on Prototypes.
DOM Reflection via HeroScript Language
Definitions stored in the DOM are exposed to HSL via a series of external functions, using those functions it is possible to query the DOM for information on classes, including their inheritance hierarchy and listing their member fields.
Get Parent Classes of a Class
The external function GetParentClasses() retrieves the immediate parents of a child class.
ParentsOfClass as List of String = GetParentClasses( className )
List Member Fields of a Class
A class is comprised of its own member fields and any fields it inherits from its parent classes. The external function GetClassFields() retrieves the member fields of a class, but not any fields it inherits.
fields as list of string = GetClassFields( className )
Retrieving all of the fields that class has or inherits requires you get the parent classes, get their fields, and recurse until you reach the penultimate parent class(es) removing any duplicates along the way.
public function getAllFieldsInClass( className as String ) as List of String classes as List of String // call a function to get the parent classes and all of their parent classes recursively getAllParentsForClass( className, classes ) fields as List of String = getClassFields( className ) foreach c in classes classFields as List of String = GetClassFields( c ) alreadyInList as Boolean // eliminate duplicate adds foreach cf in classFields foreach f in fields if f = cf alreadyInList = true break . . if not alreadyInList add back cf to fields . . . return fields . public function getAllParentsForClass(Class as String, ClassList references List of String) ParentsOfClass as List of String = GetParentClasses(Class) // For all of the parents, check for whether or not they are already in the class list // if not, add them to the list and then recurse to walk their parent classes foreach p in ParentsOfClass AlreadyInClassList as Boolean foreach c in ClassList if (c == p) AlreadyInClassList = true break . . if not AlreadyInClassList add back p to classList // recurse getAllParentsForClass(p, ClassList) . . .