cgma
CGMEngineDynamicLoader.hpp
Go to the documentation of this file.
00001 
00002 
00003 #ifndef CGM_ENGINE_DYNAMIC_LOADER_HPP
00004 #define CGM_ENGINE_DYNAMIC_LOADER_HPP
00005 
00006 #include "CubitDynamicLoader.hpp"
00007 #include "CubitString.hpp"
00008 #include "CGMGeomConfigure.h"
00009 
00010 class GeometryQueryEngine;
00011 class GeometryModifyEngine;
00012   
00014 class CUBIT_GEOM_EXPORT CGMEngineDynamicLoader
00015 {
00016   public:
00018     CGMEngineDynamicLoader(const CubitString& engine_name);
00020     virtual ~CGMEngineDynamicLoader();
00021     
00023     CubitString get_engine_name();
00024     
00027     void set_library_base_name(const CubitString& libname);
00028     CubitString get_library_base_name();
00029 
00031     CubitBoolean engine_exists();
00032     
00034     CubitStatus load_engine();
00036     CubitStatus unload_engine();
00037     
00041     GeometryQueryEngine* get_gqe();
00042     
00046     GeometryModifyEngine* get_gme();
00047 
00048   protected:
00049 
00050     // the name of the engine
00051     const CubitString mEngineName;
00052 
00053     // the filename of the engine library
00054     CubitString mEngineLibrary;
00055 
00056     // the handle of the engine library
00057     CubitDynamicLoader::LibraryHandle mLibraryHandle;
00058     
00059     // whether attempted to load the library
00060     CubitBoolean mLoadAttempted; 
00061     
00062     // compare versions of CGM that the engine was built with
00063     // and the version that is expected to be found
00064     CubitBoolean check_engine_version();
00065 
00066     GeometryQueryEngine* mQueryEngine;
00067     GeometryModifyEngine* mModifyEngine;
00068 };
00069 
00070 
00071 // macro to define symbols in CGM engine to allow 
00072 // this dynamic loader to resolve
00073 
00074 #if defined(_WIN32)
00075 #define CGM_EXPORT_ENGINE_SYM __declspec(dllexport)
00076 #else
00077 #define CGM_EXPORT_ENGINE_SYM
00078 #endif
00079 
00080 #define CGM_ENGINE_EXPORT_CREATE_GQE(EngineName) \
00081   extern "C" CGM_EXPORT_ENGINE_SYM const char* dynamic_##EngineName##_get_cgm_version() \
00082   { \
00083     return "1.0";  /* TODO -- use real versioning system, or not at all? */  \
00084   } \
00085   extern "C" CGM_EXPORT_ENGINE_SYM GeometryQueryEngine* dynamic_##EngineName##_create_gqe()
00086 
00087 #define CGM_ENGINE_EXPORT_CREATE_GME(EngineName) \
00088   extern "C" CGM_EXPORT_ENGINE_SYM GeometryModifyEngine* dynamic_##EngineName##_create_gme() \
00089 
00090 
00091 #endif // CGM_ENGINE_DYNAMIC_LOADER_HPP
00092 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines