GizmoBase

plugin.cpp

Example which shows how to create a plugin module. The source code can also be found in the examples directory of the GizmoBase distribution.

00001 // *****************************************************************************
00002 // File         : plugin.cpp
00003 // Module       : 
00004 // Description  : A sample plugin module
00005 // Author       : Anders Modén          
00006 // Product      : Gizmo3D 2.1.1
00007 //              
00008 // Copyright © 2003- Saab Training Systems AB, Sweden   
00009 //                      
00010 // NOTE:    The GIZMO package defines a general purpose API for large model
00011 //          visualisation and advanced graphic behaviours. The package is similar
00012 //          to Cosmo3D, Inventor, Performer etc. but adds automated behaviour
00013 //          patterns to the graphics. 
00014 //
00015 //
00016 // Revision History...                                                  
00017 //                                                                      
00018 // Who  Date    Description                                             
00019 //                                                                      
00020 // AMO  991002  Created file  
00021 //
00022 // ******************************************************************************
00023 #include "gzModule.h"
00024 #include "stdio.h"
00025 #define VERSIONSTR "MODULE: plugin ver 1.0"
00026 
00027 #include "plugtype.h"
00028 
00029 class MinModul : public gzDynamicMethodChain<MinModul,gzModule>
00030 {
00031 public:
00032     GZ_DECLARE_TYPE_INTERFACE;
00033 
00034     MinModul()
00035     {
00036         registerMethod(IID_DEBUG,IIDS_DEBUG,&MinModul::debug);
00037         registerDirectMethod(IID_DEBUG,s_debug);
00038 
00039         registerMethod(IID_VERSION,IIDS_VERSION,&MinModul::version);
00040 
00041         registerMethod(IID_PLUGTYPE,IIDS_PLUGTYPE,&MinModul::getMyPlugData);
00042     }
00043 
00044     gzVoid onEvent( gzModuleEvent event)
00045     {
00046         switch(event)
00047         {
00048             case GZ_MODULE_ADD:
00049                 GZMESSAGE(GZ_MESSAGE_DEBUG,"Loading Plugin Module");
00050                 m_data.m_member=LL(6806012537);
00051                 break;
00052 
00053             case GZ_MODULE_REMOVE:
00054                 GZMESSAGE(GZ_MESSAGE_DEBUG,"Unloading Plugin Module");
00055                 break;
00056         }
00057     };
00058     
00059     static gzDynamicType GZ_CALLBACK s_debug(gzDynamicInvokeInterface *iface,GZ_DYNAMIC_ATTRIBUTE_LIST_IMP)
00060     {
00061         return ((MinModul *)iface)->debug(GZ_DYNAMIC_ATTRIBUTE_LIST_IMP_FORWARD);
00062     }
00063     
00064     gzDynamicType   debug(GZ_DYNAMIC_ATTRIBUTE_LIST)
00065     {
00066         gzString debugstr;
00067         gzTime  today;
00068         
00069         debugstr=gzString("Todays date is ")+gzString(today.day())+gzString("/")+gzString(today.month());
00070         
00071         sendEvent(IID_DEBUG,gzString("Test"));
00072                 
00073         GZMESSAGE(GZ_MESSAGE_DEBUG,(const char *)debugstr);
00074         
00075         return gzDynamicTypeVoid();
00076     }
00077     
00078     gzDynamicType   version(GZ_DYNAMIC_ATTRIBUTE_LIST)
00079     {
00080         GZMESSAGE(GZ_MESSAGE_DEBUG,(const char *)VERSIONSTR);
00081         
00082         return gzDynamicTypeVoid();
00083     }
00084 
00085     gzDynamicType getMyPlugData(GZ_DYNAMIC_ATTRIBUTE_LIST)
00086     {
00087         return gzDynamicType(&m_data);
00088     }
00089         
00090     //----------- Member data --------------------
00091 
00092     MyPlugClass m_data;
00093 
00094 };
00095 
00096 GZ_DECLARE_TYPE_CHILD(gzModule,MinModul,"MyModule");
00097 
00098 GZ_DECLARE_MODULE(MinModul);
00099 

Documentation for GizmoBase generated at Wed Feb 20 11:57:53 2008 by   Saab Training Systems AB, ¸ (c) 2003-and beyond