Class TMFNode

Unit

Declaration

type TMFNode = class(TX3DMultField)

Description

VRML/X3D field holding a list of nodes.

Just like SFNode, it's defined in this unit, as it uses TX3DNode. Note that items of MFNode cannot be nil (i.e. VRML/X3D doesn't allow to use NULL inside MFNode), contrary to SFNode.

Note that TMFNode implementation doesn't use TX3DSimpleMultField. One reason is that we don't want to parse MFNode items by SFNode parser, because MFNode doesn't allow NULL items. (In the past, another argument was that we want to use TX3DNodeList and it wasn't compatible with TX3DSimpleMultField. But now TX3DNodeList descends from TFPSList, so it isn't a problem.)

Just like for TSFNode: Note that we store AllowedChildren list, which is a list of classes allowed as Items. But this is used only to produce warnings for a user. You should never assert that every item actually is one the requested classes.

Hierarchy

Overview

Methods

Public constructor CreateUndefined(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String); override;
Public constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AAllowedChildrenClasses: array of TX3DNodeClass); overload;
Public constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AAllowedChildrenClasses: TX3DNodeClassesList); overload;
Public constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AnAllowedChildrenFunctionality: TNodeFunctionalityClass); overload;
Public destructor Destroy; override;
Public function GetEnumerator: TEnumerator;
Public procedure Replace(const Index: Integer; Node: TX3DNode);
Public procedure Add(Node: TX3DNode); overload;
Public procedure Add(Position: Integer; Node: TX3DNode); overload;
Public procedure Delete(Index: Integer);
Public function Remove(const Node: TX3DNode): Integer;
Public function Extract(Index: Integer): TX3DNode;
Public procedure Clear;
Public procedure AssignItems(const SourceItems: TX3DNodeList); overload;
Public procedure AssignItems(const SourceItems: array of TX3DNode); overload;
Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;
Public procedure ParseXMLAttribute(const AttributeValue: String; Reader: TX3DReader); override;
Public procedure ParseXMLElement(Element: TDOMElement; Reader: TX3DReader); override;
Public function EqualsDefaultValue: boolean; override;
Public function Equals(SecondValue: TX3DField): boolean; override;
Public procedure Assign(Source: TPersistent); override;
Public procedure AssignValue(Source: TX3DField); override;
Public procedure AssignDefaultValueFromValue; override;
Public procedure UnassignDefaultValue; override;
Public class function X3DType: String; override;
Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: String; const AInEvent: boolean): TX3DEvent; override;
Public procedure WarningIfChildNotAllowed(Child: TX3DNode);
Public function ChildAllowed(Child: TX3DNode): boolean;
Public procedure AssignDefaultItems(const SourceDefaultItems: TX3DNodeList);
Public procedure ClearDefault;
Public function Enumerate(Func: TEnumerateChildrenFunction): Pointer;
Public procedure Send(const AValue: array of TX3DNode); overload;
Public function FindName(const AName: String): TX3DNode;
Public function IndexOfName(const AName: String): Integer;
Public function IndexOf(const ANode: TX3DNode): Integer;

Properties

Public property Items[const Index: Integer]: TX3DNode read GetItems write Replace;
Public property ItemsArray[Index: Integer]: TX3DNode read GetItems; deprecated 'use Items (default array property)';
Public property ParentNode: TX3DNode read FParentNode;
Public property DefaultItems: TX3DNodeList read FDefaultItems;
Public property DefaultValueExists: boolean read FDefaultValueExists write FDefaultValueExists default false;

Description

Methods

Public constructor CreateUndefined(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String); override;

Construct a field allowing any children class. Suitable only for special cases. For example, in instantiated prototypes, we must initially just allow all children, otherwise valid prototypes with SFNode/MFNode would cause warnings when parsing.

Public constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AAllowedChildrenClasses: array of TX3DNodeClass); overload;

This item has no description.

Public constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AAllowedChildrenClasses: TX3DNodeClassesList); overload;

Constructor that takes a list of allowed children classes. Note that we copy the contents of AAllowedChildrenClasses, not the reference.

Public constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AnAllowedChildrenFunctionality: TNodeFunctionalityClass); overload;

Constructor that allows as children any implementor of given functionality.

Public destructor Destroy; override;

This item has no description.

Public function GetEnumerator: TEnumerator;

This item has no description.

Public procedure Replace(const Index: Integer; Node: TX3DNode);

This item has no description.

Public procedure Add(Node: TX3DNode); overload;

This item has no description.

Public procedure Add(Position: Integer; Node: TX3DNode); overload;

This item has no description.

Public procedure Delete(Index: Integer);

This item has no description.

Public function Remove(const Node: TX3DNode): Integer;

Search list for given node, and, if found, remove it. Returns the index of removed item, or -1 if not found.

Public function Extract(Index: Integer): TX3DNode;

Remove child with given Index, and return it, never freeing it. This is analogous to TX3DNode.ExtractChild, see there for more explanation.

Public procedure Clear;

This item has no description.

Public procedure AssignItems(const SourceItems: TX3DNodeList); overload;

This item has no description.

Public procedure AssignItems(const SourceItems: array of TX3DNode); overload;

This item has no description.

Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;

This item has no description.

Public procedure ParseXMLAttribute(const AttributeValue: String; Reader: TX3DReader); override;

This item has no description. Showing description inherited from TX3DField.ParseXMLAttribute.

Parse field value from X3D XML encoded attribute.

Implementation in this class creates a Lexer to parse the string, and calls ParseXMLAttributeLexer.

Public procedure ParseXMLElement(Element: TDOMElement; Reader: TX3DReader); override;

This item has no description. Showing description inherited from TX3DField.ParseXMLElement.

Parse field's value from XML Element children. This is used to read SFNode / MFNode field value inside <field> (for interface declaration default field value) and <fieldValue> inside <ProtoInstance>.

Public function EqualsDefaultValue: boolean; override;

This item has no description. Showing description inherited from TX3DField.EqualsDefaultValue.

Whether the value is equal to default. Returns always False in TX3DField, descendants should override it. It is used when writing the field value to X3D file (values that are default do not have to be written, ever).

Public function Equals(SecondValue: TX3DField): boolean; override;

This item has no description. Showing description inherited from TX3DField.Equals.

True if the SecondValue object has exactly the same type and properties. For this class, this returns just (SecondValue.Name = Name).

All descendants (that add some property that should be compared) should override this like

Result := (inherited Equals(SecondValue)) and
  (SecondValue is TMyType) and
  (TMyType(SecondValue).MyProperty = MyProperty);

The floating-point fields may be compared with a small epsilon tolerance by this method.

Note that this *doesn't* compare the default values of two fields instances. This compares only the current values of two fields instances, and eventually some other properties that affect parsing (like names for TSFEnum and TSFBitMask) or allowed future values (like TSFFloat.MustBeNonnegative).

Public procedure Assign(Source: TPersistent); override;

This item has no description.

Public procedure AssignValue(Source: TX3DField); override;

This item has no description. Showing description inherited from TX3DField.AssignValue.

Copies the current field value. Contrary to TPersistent.Assign, this doesn't copy the rest of properties.

After setting, our ValueFromIsClause is always changed to False. You can manually change it to True, if this copy indeed was done following "IS" clause.

Descendants implementors notes:

In this class, implementation takes care of setting our ValueFromIsClause to False. In descendants, you should do like

if Source is <appropriate class> then
begin
  inherited;
  Value := Source.value;
end else
  AssignValueRaiseInvalidClass(Source);

Public procedure AssignDefaultValueFromValue; override;

This item has no description. Showing description inherited from TX3DField.AssignDefaultValueFromValue.

Set field's default value from the current value.

Note that for now this doesn't guarantee that every possible field's value can be stored as default value. In case of trouble, it will silently record "no default is known" information, so e.g. EqualsDefaultValue will always return False. Our default value mechanisms are sometimes limited, not every value can be a default value. For example, for multiple-valued nodes, we usually cannot save arrays longer than one as default value. This is not a problem, since X3D specification doesn't specify too long default values. But it may be a problem for prototypes, since then user can assign any value as default value. May be corrected in the future.

Public procedure UnassignDefaultValue; override;

This item has no description. Showing description inherited from TX3DField.UnassignDefaultValue.

Remove default value, recording that "no default is known". In effect EqualsDefaultValue will always return False.

Public class function X3DType: String; override;

This item has no description. Showing description inherited from TX3DField.X3DType.

Field type in X3D, like 'SFString' or 'MFInt32'. As for VRML/X3D interface declaration statements. In base TX3DField class, this returns XFAny (name indicating any type, used by instantreality and us).

Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: String; const AInEvent: boolean): TX3DEvent; override;

This item has no description. Showing description inherited from TX3DField.CreateEvent.

Create TX3DEvent descendant suitable as exposed event for this field.

Public procedure WarningIfChildNotAllowed(Child: TX3DNode);

Checks is Child allowed on the list of nodes of this MFNode, and makes WritelnWarning if not.

Check is allowed is done looking at AllowedChildrenAll and AllowedChildren properties.

Child must not be Nil.

WritelnWarning message will suggest that this Child is added to this node. In other words, you should only pass as Child a node that you want to add (e.g. by Add) to this field, otherwise WritelnWarning message will be a little unsensible.

Public function ChildAllowed(Child: TX3DNode): boolean;

This item has no description.

Public procedure AssignDefaultItems(const SourceDefaultItems: TX3DNodeList);

Operate on DefaultItems, just like analogous AssignItems and Clear.

Public procedure ClearDefault;

This item has no description.

Public function Enumerate(Func: TEnumerateChildrenFunction): Pointer;

Calls Func for all current children. Stops if Func returns something non-nil. The main use for this is to simplify implementation of TX3DNode.DirectEnumerateActive overrides in TX3DNode descendants.

Public procedure Send(const AValue: array of TX3DNode); overload;

Set the field's value in a correct way (by sending X3D event, or at least notifying the parent scene).

Public function FindName(const AName: String): TX3DNode;

Find node by name, Nil if not found.

For empty node name, always returns Nil. This follows the definition of TX3DNode.X3DName: empty means that node has no name, so it should not be found by searches by name, ever.

See also
Returns the node index. This is sometimes more flexible (you can always quickly get actual node knowing the index, by Items[Index], but not the other way around). It is also sometimes less comfortable (often you're not interested in node index).
Find index of a node with given name, -1 if not found.
Public function IndexOfName(const AName: String): Integer;

Find index of a node with given name, -1 if not found.

Public function IndexOf(const ANode: TX3DNode): Integer;

Find index of a node , -1 if not found.

Properties

Public property Items[const Index: Integer]: TX3DNode read GetItems write Replace;

Items of this field.

Public property ItemsArray[Index: Integer]: TX3DNode read GetItems; deprecated 'use Items (default array property)';

Warning: this symbol is deprecated: use Items (default array property)

This item has no description.

Public property ParentNode: TX3DNode read FParentNode;

This item has no description.

Public property DefaultItems: TX3DNodeList read FDefaultItems;

Lists default items of this field.

Do not modify this list explicitly. Use only methods in this class like AssignDefaultItems (they take care of calling appropriate AddParentField / RemoveParentField, otherwise you could break reference-counting of nodes by ParentFields).

Public property DefaultValueExists: boolean read FDefaultValueExists write FDefaultValueExists default false;

This item has no description.


Generated by PasDoc 0.16.0-snapshot.