Class TX3DSimpleMultField

Unit

Declaration

type generic TX3DSimpleMultField<TItem;TSingleField;TItemList> = class(TX3DMultField)

Description

X3D field with a list of values. This is an ancestor of most multiple-value X3D fields.

Hierarchy

Overview

Methods

Public constructor Create(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: string; const InitialContent: array of TItem);
Public constructor CreateUndefined(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: string); override;
Public destructor Destroy; override;
Public procedure Assign(Source: TPersistent); override;
Public procedure AssignValue(Source: TX3DField); override;
Public procedure AssignDefaultValueFromValue; override;
Public procedure UnassignDefaultValue; override;
Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;
Public function Equals(SecondValue: TX3DField): boolean; override;
Public function EqualsDefaultValue: boolean; override;
Public procedure ParseXMLAttributeLexer(Lexer: TX3DLexer; Reader: TX3DReader); override;
Public procedure Send(const AValue: array of TItem); overload;
Public procedure Send(const AValue: TItemList); overload;

Properties

Public property Items: TItemList read GetItems write SetItems;
Public property ItemsSafe[Index: Integer]: TItem read GetItemsSafe write SetItemsSafe;

Description

Methods

Public constructor Create(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: string; const InitialContent: array of TItem);

This item has no description.

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

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

Virtual constructor, that you can use to construct field instance when field class is known only at runtime.

The idea is that in some cases, you need to create fields using variable like FieldClass: TX3DFieldClass. See e.g. TX3DInterfaceDeclaration, VRML 2.0 feature that simply requires this ability, also implementation of TX3DSimpleMultField.Parse and TX3DSimpleMultField.CreateItemBeforeParse.

Later you can initialize such instance from string using it's Parse method.

Note that some exceptional fields simply cannot work when initialized by this constructor: these are SFEnum and SFBitMask fields. They simply need to know their TSFEnum.EnumNames, or TSFBitMask.FlagNames + TSFBitMask.NoneString + TSFBitMask.AllString before they can be parsed. I guess that's one of the reasons why these field types were entirely removed from VRML 2.0.

Public destructor Destroy; override;

This item has no description.

Public procedure Assign(Source: TPersistent); override;

Copy another field value, default value and other properties.

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 procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;

Parse MF field. This class handles parsing fully, usually no need to override this more in descendants. It uses TSingleField.Parse method.

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

Checks equality between this and SecondValue field. In addition to inherited(Equals), this checks the actual contents of the items. Note that floating-point values are compared with some tolerance for errors by this method.

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 procedure ParseXMLAttributeLexer(Lexer: TX3DLexer; Reader: TX3DReader); override;

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

Parse field value from X3D XML encoded attribute using a Lexer. Attributes in X3D are generally encoded such that normal ParseValue(Lexer, nil) call is appropriate, so this is done in this class.

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

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

Public procedure Send(const AValue: TItemList); overload;

This item has no description.

Properties

Public property Items: TItemList read GetItems write SetItems;

This item has no description.

Public property ItemsSafe[Index: Integer]: TItem read GetItemsSafe write SetItemsSafe;

Access items, making nice warning in case of an invalid index. In case of an invalid index, getting will return default value (filled with zeroes), setting will do nothing, and both will emit user-friendly WritelnWarning.


Generated by PasDoc 0.16.0-snapshot.