|
Katana Plug-in APIs 0.1
|
00001 #ifndef FnGeolibOp_H 00002 #define FnGeolibOp_H 00003 00004 #include <vector> 00005 #include <string> 00006 00007 #include <FnAttribute/FnAttribute.h> 00008 00009 #include <FnGeolib/FnGeolibAPI.h> 00010 #include <FnGeolib/op/FnGeolibCookInterface.h> 00011 #include <FnGeolib/op/FnGeolibSetupInterface.h> 00012 #include <FnGeolib/op/FnOpDescriptionBuilder.h> 00013 #include <FnGeolib/op/ns.h> 00014 #include <FnGeolib/suite/FnGeolibCookInterfaceSuite.h> 00015 #include <FnGeolib/suite/FnGeolibOpSuite.h> 00016 #include <FnGeolib/suite/FnGeolibSetupInterfaceSuite.h> 00017 00018 #include <FnPluginSystem/FnPlugin.h> 00019 #include <FnPluginSystem/FnPluginSystem.h> 00020 00021 00022 FNGEOLIBOP_NAMESPACE_ENTER 00023 { 00043 // GeolibOp and classes derived from it are never instantiated. 00044 // The base class contains some common static functions used by 00045 // the plugin system (setHost/getHost/flush/createSuite). 00046 // 00047 // Each derived class should create a static cook function 00048 // which will be registered in a FnGeolibOpSuite_v1 instance. 00049 // 00050 // Cook func: static void cook(GeolibCookInterface &cookInterface); 00051 class FNGEOLIB_API GeolibOp 00052 { 00053 public: 00055 static FnPlugStatus setHost(FnPluginHost *host); 00056 static FnPluginHost *getHost(); 00057 00058 static void flush(); 00059 00060 static FnGeolibOpSuite_v1 createSuite( 00061 void (*setup)(FnGeolibSetupInterfaceHandle cookInterfaceHandle, 00062 FnGeolibSetupInterfaceSuite_v1 *cookInterfaceSuite), 00063 void (*cook)(FnGeolibCookInterfaceHandle cookInterfaceHandle, 00064 FnGeolibCookInterfaceSuite_v1 *cookInterfaceSuite, 00065 uint8_t * didAbort), 00066 FnAttributeHandle (*describe)()); 00067 00068 static void callSetup( 00069 void (*setupFunc)(GeolibSetupInterface & setupInterface), 00070 FnGeolibSetupInterfaceHandle setupInterfaceHandle, 00071 FnGeolibSetupInterfaceSuite_v1 *setupInterfaceSuite); 00072 00073 static void callCook( 00074 void (*cookFunc)(GeolibCookInterface & cookInterface), 00075 FnGeolibCookInterfaceHandle cookInterfaceHandle, 00076 FnGeolibCookInterfaceSuite_v1 *cookInterfaceSuite, 00077 uint8_t * didAbort); 00078 00079 static FnAttributeHandle callDescribe( 00080 FnAttribute::GroupAttribute (*describeFunc)()); 00081 00082 static FnAttribute::GroupAttribute describe(); 00083 00084 static unsigned int _apiVersion; 00085 static const char* _apiName; 00086 00087 private: 00088 static FnPluginHost *_host; 00089 00090 // op instances are never made (just a derivable placeholder for 00091 // static funcs). 00092 GeolibOp(); 00093 ~GeolibOp(); 00095 }; 00096 00101 } 00102 FNGEOLIBOP_NAMESPACE_EXIT 00103 00105 00106 // Plugin Registering Macro. 00107 00108 #define DEFINE_GEOLIBOP(OP_CLASS) \ 00109 \ 00110 void OP_CLASS##_setup( \ 00111 FnGeolibSetupInterfaceHandle setupInterfaceHandle, \ 00112 FnGeolibSetupInterfaceSuite_v1 *setupInterfaceSuite) \ 00113 { \ 00114 FNGEOLIBOP_NAMESPACE::GeolibOp::callSetup(OP_CLASS::setup, \ 00115 setupInterfaceHandle, setupInterfaceSuite \ 00116 ); \ 00117 } \ 00118 \ 00119 void OP_CLASS##_cook( \ 00120 FnGeolibCookInterfaceHandle cookInterfaceHandle, \ 00121 FnGeolibCookInterfaceSuite_v1 *cookInterfaceSuite, \ 00122 uint8_t * didAbort) \ 00123 { \ 00124 FNGEOLIBOP_NAMESPACE::GeolibOp::callCook(OP_CLASS::cook, \ 00125 cookInterfaceHandle, cookInterfaceSuite, \ 00126 didAbort); \ 00127 } \ 00128 \ 00129 FnAttributeHandle OP_CLASS##_describe() \ 00130 { \ 00131 return FNGEOLIBOP_NAMESPACE::GeolibOp::callDescribe( \ 00132 OP_CLASS::describe); \ 00133 } \ 00134 \ 00135 FnGeolibOpSuite_v1 OP_CLASS##_suite = \ 00136 FNGEOLIBOP_NAMESPACE::GeolibOp::createSuite( \ 00137 OP_CLASS##_setup, \ 00138 OP_CLASS##_cook, \ 00139 OP_CLASS##_describe); \ 00140 \ 00141 const void* OP_CLASS##_getSuite() \ 00142 { \ 00143 return &OP_CLASS##_suite; \ 00144 } 00145 00146 #define DEFINE_GEOLIBOP_PLUGIN(OP_CLASS) \ 00147 \ 00148 FnPlugin OP_CLASS##_plugin; \ 00149 \ 00150 DEFINE_GEOLIBOP(OP_CLASS) 00151 00152 00153 // NO-SETUP VARIANT 00154 #define DEFINE_GEOLIBOP_NOSETUP(OP_CLASS) \ 00155 \ 00156 void OP_CLASS##_setup( \ 00157 FnGeolibSetupInterfaceHandle, \ 00158 FnGeolibSetupInterfaceSuite_v1 *) \ 00159 { \ 00160 } \ 00161 \ 00162 void OP_CLASS##_cook( \ 00163 FnGeolibCookInterfaceHandle cookInterfaceHandle, \ 00164 FnGeolibCookInterfaceSuite_v1 *cookInterfaceSuite, \ 00165 uint8_t * didAbort) \ 00166 { \ 00167 FNGEOLIBOP_NAMESPACE::GeolibOp::callCook(OP_CLASS::cook, \ 00168 cookInterfaceHandle, cookInterfaceSuite, \ 00169 didAbort); \ 00170 } \ 00171 \ 00172 FnAttributeHandle OP_CLASS##_describe() \ 00173 { \ 00174 return FNGEOLIBOP_NAMESPACE::GeolibOp::callDescribe( \ 00175 OP_CLASS::describe); \ 00176 } \ 00177 \ 00178 FnGeolibOpSuite_v1 OP_CLASS##_suite = \ 00179 FNGEOLIBOP_NAMESPACE::GeolibOp::createSuite( \ 00180 OP_CLASS##_setup, \ 00181 OP_CLASS##_cook, \ 00182 OP_CLASS##_describe); \ 00183 \ 00184 const void* OP_CLASS##_getSuite() \ 00185 { \ 00186 return &OP_CLASS##_suite; \ 00187 } 00188 00189 #define DEFINE_GEOLIBOP_PLUGIN_NOSETUP(OP_CLASS) \ 00190 \ 00191 FnPlugin OP_CLASS##_plugin; \ 00192 \ 00193 DEFINE_GEOLIBOP_NOSETUP(OP_CLASS) 00194 00195 00197 00198 #endif // FnGeolibOp_H
1.7.3