Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Class TX3DSimpleMultField
Unit
X3DFields
Declaration
type TX3DSimpleMultField = class(TX3DMultField)
Description
Field holding multiple values. Remember that such field may always have any number of items, including zero.
Note that we keep MF fields contents in TFPSList or TCastleStringList 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 TX3DSimpleMultField as a descendant of TX3DSingleFieldsList: 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 TVector3SingleList instance, that internally keeps all items in one continuos piece of memory.
Descendants implementors notes: to make new descendant:
In CreateUndefined you have to initialize FItemClass and create RawItems. In destructor of this class, RawItems are freed, so don't worry about this.
Override RawItemsAdd.
If your ItemClass doesn't work 100% correctly when it's initialized by CreateUndefined, you may have to override CreateItemBeforeParse. Fortunately, VRML specification was careful to choose as multi-valued field types' only fields that can behave nicely when initialized by CreateUndefined (and in fact VRML 2.0 removed the "bad fields" entirely).
Not strictly required, but usually it's comfortable to have a constructor that allows you to init default field value from some "array of TXxx".
Hierarchy
Overview
Fields
Methods
Properties
Description
Fields
 |
RawItems: TObject; |
Items of this field. Either TFPSList or TCastleStringList.
Descendants implementors notes: You have to initialize this field in descendants' constructor, it will be always freed in our destructor.
|
Methods
 |
function CreateItemBeforeParse: TX3DSingleField; 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.
|
 |
procedure RawItemsAdd(Item: TX3DSingleField); 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).
|
 |
procedure OnWarning_InvalidIndex(const Index, ACount: Integer); |
|
 |
procedure SaveToStreamValue(Writer: TX3DWriter); override; |
SaveToStreamValue overriden for MF fields. This class handles SaveToStreamValue fully, no need to override it again in descendants.
|
 |
function RawItemToString(ItemNum: integer; const Encoding: TX3DEncoding): 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.
|
 |
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).
|
 |
function GetCount: Integer; override; |
Get or set the number of items. In TX3DSimpleMultField descendants, these simply get/set RawItems.Count (you could do it directly as well, since operating on RawItems directly is Ok).
|
 |
procedure SetCount(const Value: Integer); override; |
|
 |
procedure Clear; |
|
 |
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 ItemClass.Parse method.
|
 |
destructor Destroy; override; |
|
 |
function Equals(SecondValue: TX3DField; const EqualityEpsilon: Double): 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
Generated by PasDoc 0.13.0 on 2014-04-30 22:06:46
|