Class TVRMLSimpleMultField

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TVRMLSimpleMultField = class(TVRMLMultField)

Description

Multiple values VRML field. Remember that such field may always have any number of items, including zero.

Note that we keep MF fields contents in TDyn*Array instances (RawItems in this class, also accessible as Items (with more concrete class) in descendants). This means that they are in compact form, easy for reading, or even for feeding the list into OpenGL. That's the main reason why I did not simply implement TVRMLSimpleMultField as a descendant of TVRMLSingleFieldsList: A long list of vertexes, MFVec3f, would be kept as a list of pointers to a lot of TSFVec3f instances. This would be quite memory-consuming, and very uncomfortable for access. On the contrary, current implementation keeps all these vertexes inside one TDynVector3SingleArray instance, that internally keeps all items in one continuos piece of memory.

Descendants implementors notes: to make new descendant:

Hierarchy

Overview

Fields

Protected fItemClass: TVRMLSingleFieldClass;
Public RawItems: TDynArrayBase;

Methods

Protected function CreateItemBeforeParse: TVRMLSingleField; virtual;
Protected procedure RawItemsAdd(Item: TVRMLSingleField); virtual abstract;
Protected procedure SaveToStreamValue(SaveProperties: TVRMLSaveToStreamProperties); override;
Protected function RawItemToString(ItemNum: integer): string; virtual; abstract;
Protected function SaveToStreamDoNewLineAfterRawItem(ItemNum: integer): boolean; virtual;
Public function Count: integer; override;
Public procedure Parse(Lexer: TVRMLLexer; IsClauseAllowed: boolean); override;
Public destructor Destroy; override;
Public function Equals(SecondValue: TVRMLField; const EqualityEpsilon: Single): boolean; override;

Properties

Public property ItemClass: TVRMLSingleFieldClass read fItemClass;

Description

Fields

Protected fItemClass: TVRMLSingleFieldClass;
 
Public RawItems: TDynArrayBase;

Items of this field.

Descendants implementors notes: You have to initialize this field in descendants' constructor, it will be always freed in our destructor.

Methods

Protected function CreateItemBeforeParse: TVRMLSingleField; virtual;

This creates new instance of class ItemClass. It doesn't have to have initialized value (in other words, it can be created by CreateUndefined), since we'll call his Parse method immediately. Default implementation in this class uses simply ItemClass.CreateUndefined.

Protected procedure RawItemsAdd(Item: TVRMLSingleField); virtual abstract;

Add Item at the end of RawItems. It's guaranteed that Item passes here will be of class ItemClass. You should copy Item contents as appropriate (remember that Item instance itself may be freed soon, so copy contents, not only some reference).

Protected procedure SaveToStreamValue(SaveProperties: TVRMLSaveToStreamProperties); override;

SaveToStreamValue overriden for MF fields. This class handles SaveToStreamValue fully, no need to override it again in descendants.

Protected function RawItemToString(ItemNum: integer): string; virtual; abstract;

RawItemToString(i) must change RawItems[i] into a string that can be used to store this is text stream. In descendants, you have to override this.

Protected function SaveToStreamDoNewLineAfterRawItem(ItemNum: integer): boolean; virtual;

This says when we should do newline when writing this field into a stream. It's has purely aesthetical meaning, nothing more. In this class SaveToStreamDoNewLineAfterRawItem always returns True (although SaveToStreamValue may sometimes ignore it, if it knows better).

Public function Count: integer; override;

Number of items in this field. Simply returns RawItems.Count.

Public procedure Parse(Lexer: TVRMLLexer; IsClauseAllowed: boolean); override;

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

Public destructor Destroy; override;
 
Public function Equals(SecondValue: TVRMLField; const EqualityEpsilon: Single): boolean; override;

Checks equality between this and SecondValue field. In addition to inherited(Equals), this also checks that Count and ItemClass are equal. All descendants must check for equality every item on SecondValue.Items[I] and Items[I].

Properties

Public property ItemClass: TVRMLSingleFieldClass read fItemClass;

A corresponding SF field class. All items that will be passed to RawItemsAdd will be of this class.


Generated by PasDoc 0.10.0 on 2008-02-25 00:00:40