H3D API  2.4.1
Script.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __SCRIPT_H__
30 #define __SCRIPT_H__
31 
32 #include <H3D/X3DScriptNode.h>
34 #include <H3D/SFBool.h>
35 #include <H3D/SpiderMonkeySAI.h>
36 
37 namespace H3D {
38 
42  class Script : public X3DScriptNode,
43  public H3DDynamicFieldsObject {
44  public:
45  // Constructor
46  Script( Inst< SFNode > _metadata = 0,
47  Inst< MFString > _url = 0,
48  Inst< SFBool > _directOutput = 0,
49  Inst< SFBool > _mustEvaluate = 0 );
50 
52  ~Script();
53 
54  virtual void initialize();
55  virtual void traverseSG( TraverseInfo &ti );
56 
59  virtual bool addField( const string &_name,
60  const Field::AccessType &access,
61  Field *field );
62 
64  H3DUniquePtr< SFBool > directOutput;
65 
67  H3DUniquePtr< SFBool > mustEvaluate;
68 
71 
72  protected:
73 
74  static Scene::CallbackCode initEngineCallback( void *data );
75 #ifdef HAVE_SPIDERMONKEY
76  SpiderMonkeySAI sai;
77 #endif
78  };
79 }
80 
81 #endif
Header file for H3DDynamicFieldsObject.
Contains the SFBool field class.
Header file for SAI ECMAScript implementation using the SpiderMonkey javascript engine.
Base class for all scripting node interfaces.
The Field class.
Definition: Field.h:46
AccessType
The different access types that a field can have.
Definition: Field.h:53
This abstract interface class is the base class for all classes that specify arbitrary fields.
Definition: H3DDynamicFieldsObject.h:128
CallbackCode
Return code for callback functions.
Definition: Scene.h:228
No scripting is supported with the Script node yet.
Definition: Script.h:43
virtual bool addField(const string &_name, const Field::AccessType &access, Field *field)
Override the addField method from H3DDynamicFieldsObject to add the field to the script engine.
Definition: Script.cpp:108
~Script()
Destructor.
Definition: Script.cpp:61
H3DUniquePtr< SFBool > directOutput
Field is not supported by H3DAPI yet.
Definition: Script.h:64
virtual void traverseSG(TraverseInfo &ti)
traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph.
Definition: Script.cpp:94
static H3DNodeDatabase database
The X3DNodeDatabase for this node.
Definition: Script.h:70
H3DUniquePtr< SFBool > mustEvaluate
Field is not supported by H3DAPI yet.
Definition: Script.h:67
The SpiderMonkeySAI class is an implementation of the X3D Ecmascript SAI specification using SpiderMo...
Definition: SpiderMonkeySAI.h:52
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
The base class for script nodes.
Definition: X3DScriptNode.h:41
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194