Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

ScriptJDK.h

00001 //
00002 // OpenVRML
00003 //
00004 // Copyright (C) 1998  Chris Morley
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License, or (at your option) any later version.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 #ifndef _SCRIPTJDK_
00021 #define _SCRIPTJDK_
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include "config.h"
00025 #endif
00026 
00027 #if OPENVRML_ENABLE_SCRIPT_NODE_JAVA
00028 #include "script.h"
00029 
00030 #include <jni.h>
00031 
00032 #include "field.h"
00033 
00034 namespace OpenVRML {
00035 
00036     class ScriptNode;
00037 
00038     class ScriptJDK : public Script {
00039         // Shared by all JDK Script objects
00040         static JavaVM * d_jvm;
00041         static JNIEnv * d_env;
00042 
00043         jclass d_class;
00044         jobject d_object;
00045         jmethodID d_processEventsID, d_processEventID, d_eventsProcessedID;
00046 
00047     public:
00048         ScriptJDK(ScriptNode & scriptNode,
00049                   const char * className, const char * classDir);
00050         virtual ~ScriptJDK();
00051 
00052         virtual void initialize(double timestamp);
00053         virtual void processEvent(const std::string & id,
00054                                   const FieldValue & value, double timestamp);
00055         virtual void eventsProcessed(double timestamp);
00056         virtual void shutdown(double timestamp);
00057 
00058     private:
00059         void activate(double timeStamp, const std::string & fname,
00060                       size_t argc, const FieldValue * const argv[]);
00061     };
00062 }
00063 
00064 #endif // OPENVRML_ENABLE_SCRIPT_NODE_JAVA
00065 #endif // _SCRIPTJDK_