Castle Game Engine: X3DNodes: Class TX3DInterfaceDeclaration

# Class TX3DInterfaceDeclaration
Description | Hierarchy | Fields | Methods | Properties
## Unit X3DNodes ## Declaration `type TX3DInterfaceDeclaration = class(TX3DFileItem)` ## Description Interface declaration, used in VRML/X3D (exposed) prototypes and for nodes with dynamic fields (Script, ComposedShader). See VRML 2.0 and X3D specs. Each interface specification is a field or an event, stored in FieldOrEvent. FieldOrEvent is `Nil` before parsing. Field value is not initialized if you passed FieldValue = `False` to Parse (although IsClauseNames will always be initialized). FieldValue = `True` is used for prototype (not external) declarations and nodes with interface declarations (Script, ComposedShader etc.). In the future maybe some property like FieldValueInitialized will be exposed here, if needed at some point. Interface declaration doesn't have much properties, since all the information is contained within FieldOrEvent instance, like Name, field class type, out or in (in case of event), exposed or not (in case of field), IsClauseNames. ## Hierarchy TPersistent TNonRefCountedInterfacedPersistent TX3DFileItem TX3DInterfaceDeclaration ## Overview ### Methods
| `constructor Create(AParentNode: TX3DNode);`
| `destructor Destroy; override;`
| `function CopyFieldOrEvent(NewParentNode: TX3DNode): TX3DFieldOrEvent;`
| `procedure CopyAndAddFieldOrEvent(Node: TX3DNode);`
| `procedure AddFieldOrEvent(Node: TX3DNode);`
| `procedure Parse(Lexer: TX3DLexer; Reader: TX3DReaderNames; FieldValue, IsClauseAllowed: boolean);`
| `procedure ParseXML(Element: TDOMElement; Reader: TX3DReaderNames; FieldValue: boolean);`
| `procedure IDeclSaveToStream(Writer: TX3DWriter; FieldValue: boolean);`
| `procedure SaveToStream(Writer: TX3DWriter); override;`
| `function AccessType: TX3DAccessType;`
| `function DeepCopy(NewParentNode: TX3DNode; CopyState: TX3DNodeDeepCopyState): TX3DInterfaceDeclaration;`
### Properties
| `property ParentNode: TX3DNode read FParentNode;`
| `property FieldOrEvent: TX3DFieldOrEvent read FFieldOrEvent write SetFieldOrEvent;`
| `property Field: TX3DField read FField;`
| `property Event: TX3DEvent read FEvent;`
## Description ### Methods
| `constructor Create(AParentNode: TX3DNode);`
| `destructor Destroy; override;`
| `function CopyFieldOrEvent(NewParentNode: TX3DNode): TX3DFieldOrEvent;`
Create a copy of current FieldOrEvent. Sets NewParentNode as Result.ParentNode. Note the new copy will not have ParentIntefaceDeclaration set (as the idea is that you own created copy, not this TX3DInterfaceDeclaration instance).
| `procedure CopyAndAddFieldOrEvent(Node: TX3DNode);`
Create a copy of current FieldOrEvent, and add it to Node.Fields or Node.Events.
| `procedure AddFieldOrEvent(Node: TX3DNode);`
Copies only reference to FieldOrEvent, adding it to Node.Fields or Node.Events.
| `procedure Parse(Lexer: TX3DLexer; Reader: TX3DReaderNames; FieldValue, IsClauseAllowed: boolean);`
| `procedure ParseXML(Element: TDOMElement; Reader: TX3DReaderNames; FieldValue: boolean);`
Parse interface declaration encoded in XML. Note that classic VRML parser has here IsClauseAllowed: boolean parameter, this was set to `True` when parsing InterfaceDeclarations of special nodes (Script, ComposedShader etc.), since they could have IS clause (at least, as far as I understood the spec). But for X3D XML encoding, it's not available, since (AFAI understand the X3D XML encoding spec) the <IS> element inside node body may point from nodeField to any interface field of this node, including InterfaceDeclarations. So ParseISStatement handles this.
| `procedure IDeclSaveToStream(Writer: TX3DWriter; FieldValue: boolean);`
Save this interface declaration to stream. This assumes that it starts at the beginning of the line, and at the end always writes NL, so at the end it's also at the beginning of some line. For XML encoding, IS clauses are not saved here. They must be saved by containing node. ###### Parameters FieldValue If `True` then we will always save Field value or (if classic encoding) IS clauses to stream, along with this interface declaration (if this interface declaration has the Field set). Otherwise, field's value will not be saved, only IS clauses if present.
| `procedure SaveToStream(Writer: TX3DWriter); override;`
Save this interface declaration to stream. ###### See also IDeclSaveToStream Save this interface declaration to stream.
| `function AccessType: TX3DAccessType;`
Returns access type, corresponding to current Event and Field values. Result is undefined if both Event and Field are `Nil` (which may happen when it's not initialized (e.g. parsed) yet) or when both are non-nil (which should never happen).
| `function DeepCopy(NewParentNode: TX3DNode; CopyState: TX3DNodeDeepCopyState): TX3DInterfaceDeclaration;`
### Properties
| `property ParentNode: TX3DNode read FParentNode;`
Containing node, if any, for this VRML interface declaration. This must also be set to FieldOrEvent.ParentNode created for this interface declaration.
| `property FieldOrEvent: TX3DFieldOrEvent read FFieldOrEvent write SetFieldOrEvent;`
Field or event of this interface declaration. Is non-nil after parsing. You can assign to this property, to constructs interface declarations (and so also prototypes) in your own code (e.g. this is used X3D XML reader). Just be careful, and remember that this object owns `FieldOrEvent` (that is, will free it at destruction).
| `property Field: TX3DField read FField;`
Return FieldOrEvent casted as appropriate class. `Nil` if such cast is not possible, for example when FieldOrEvent is an event and you try to use Field method.
| `property Event: TX3DEvent read FEvent;`
Generated by PasDoc 0.13.0 on 2013-08-17 21:27:17