]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Config.h.in
Moved to version 1.0
[cpPlugins.git] / lib / cpPlugins / Config.h.in
index 6cec4adba2ace6e7f9b2cf827765c14888e1baac..71e0b03d3b6e7acc9cbf401e8458301eebdd14ba 100644 (file)
-#ifndef __CPPLUGINS__CONFIG__H__
-#define __CPPLUGINS__CONFIG__H__
+// =========================================================================
+// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
+#ifndef __cpPlugins__Config__h__
+#define __cpPlugins__Config__h__
 
-#include <cpPlugins/cpPlugins_Export.h>
-#include <cpPlugins_Config.h>
+#include <iostream>
+#include <memory>
 #include <string>
+#include <sstream>
+#include <stdexcept>
+#include <cpPlugins_Export.h>
 
-/*
- * =========================================================================
- * Version numbers and strings
- * =========================================================================
- */
-#define cpPlugins_MAJ_VER @prj_MAJ_VER@
-#define cpPlugins_MIN_VER @prj_MIN_VER@
-#define cpPlugins_REL_VER @prj_REL_VER@
-#define cpPlugins_VER     "@prj_VER@"
-#define cpPlugins_sVER    "@prj_sVER@"
-
-/*
- * =========================================================================
- * Some useful constants and values
- * =========================================================================
- */
-
-#define cpPlugins_CONFIG_FILE "plugins.cfg"
+// =========================================================================
+// Identify OS
+// =========================================================================
 
-#define cpPlugins_QT4_USED @QT4_FOUND@
-#if cpPlugins_QT4_USED == 1
-#  define cpPlugins_QT4
-#else // cpPlugins_QT4_USED == 1
-#  undef cpPlugins_QT4
-#endif // cpPlugins_QT4_USED == 1
+#define cpPlugins_OS_@CMAKE_SYSTEM_NAME@
+#define cpPlugins_LIB_EXT    "@CMAKE_SHARED_LIBRARY_SUFFIX@"
+#define cpPlugins_LIB_PREFIX "@CMAKE_SHARED_LIBRARY_PREFIX@"
+#define cpPlugins_ENV        "cpPlugins_PATH"
+#define cpPlugins_EXT        ".plg"
 
-/*
- * =========================================================================
- * Identify OS
- * =========================================================================
- */
-#if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ )
-#  define cpPlugins_SYS_WINDOWS
-#  define cpPlugins_PLUGIN_PREFIX ""
-#  define cpPlugins_PLUGIN_EXT "dll"
+#ifdef cpPlugins_OS_Windows
+#  define cpPlugins_ENV_SEP ";"
 #  ifndef WIN32_LEAN_AND_MEAN
 #    define WIN32_LEAN_AND_MEAN
-#  endif
+#  endif // WIN32_LEAN_AND_MEAN
 #  define NOMINMAX
 #  include <windows.h>
 #  include <tchar.h>
-#elif defined( linux ) || defined( __linux )
-#  define cpPlugins_SYS_LINUX
-#  define cpPlugins_PLUGIN_PREFIX "lib"
-#  define cpPlugins_PLUGIN_EXT "so"
-#elif defined( __APPLE__ ) || defined( MACOSX ) || defined( macintosh ) || defined( Macintosh )
-#  define cpPlugins_SYS_MACOS
-#  define cpPlugins_PLUGIN_PREFIX "lib"
-#  define cpPlugins_PLUGIN_EXT "dylib"
-#elif defined( __FreeBSD__ ) || defined( __FreeBSD_kernel__ )
-#  define cpPlugins_SYS_FREEBSD
-#  define cpPlugins_PLUGIN_PREFIX "lib"
-#  define cpPlugins_PLUGIN_EXT "so"
-#else
-#  error "This operating system is not supported by cpPlugins"
-#endif
+#else // cpPlugins_OS_Windows
+#  define cpPlugins_ENV_SEP ":"
+#endif // cpPlugins_OS_Windows
 
-/*
- * =========================================================================
- * Some macros
- * =========================================================================
- */
-#define cpPlugins_Id_Macro( N, C )                                      \
-  public:                                                               \
-  virtual const char* GetClassName( )     override { return( #N ); }    \
-  virtual const char* GetClassCategory( ) override { return( #C ); }
+// =========================================================================
+// Some generic macros
+// =========================================================================
 
-/*
- * =========================================================================
- * Some functions
- * =========================================================================
- */
-#include <iostream>
-namespace cpPlugins
-{
-  struct PathHelper
-  {
-    // ---------------------------------------------------------------------
-    inline bool operator()( char c ) const
-      {
-#ifdef cpPlugins_SYS_WINDOWS
-        return( c == '\\' || c == '/' );
-#else // cpPlugins_SYS_WINDOWS
-        return( c == '/' );
-#endif // cpPlugins_SYS_WINDOWS
-      }
+#define _cpPluginsErrorMacro_2( CPPLUGINS_OBJECT, CPPLUGINS_MESSAGE )   \
+  {                                                                     \
+    std::stringstream _cpPlugins_error_message_;                        \
+    _cpPlugins_error_message_                                           \
+      << "Error in \"" << __FILE__                                      \
+      << "\", line \"" << __LINE__ << "\": ";                           \
+    if( CPPLUGINS_OBJECT != NULL )                                      \
+    {                                                                   \
+      const cpPlugins::ProcessObject* _cpPlugins_Object =               \
+        reinterpret_cast< const cpPlugins::ProcessObject* >(            \
+          CPPLUGINS_OBJECT                                              \
+          );                                                            \
+      _cpPlugins_error_message_                                         \
+        << "\""                                                         \
+        << _cpPlugins_Object->GetName( ) << "\"@\""                     \
+        << _cpPlugins_Object->GetClassName( ) << "\": ";                \
+    }                                                                   \
+    _cpPlugins_error_message_ CPPLUGINS_MESSAGE;                        \
+    throw std::runtime_error( _cpPlugins_error_message_.str( ) );       \
+  }
+
+#define _cpPluginsErrorMacro_1( CPPLUGINS_MESSAGE )                     \
+  {                                                                     \
+    std::stringstream _cpPlugins_error_message_;                        \
+    _cpPlugins_error_message_                                           \
+      << "Error in \"" << __FILE__                                      \
+      << "\", line \"" << __LINE__ << "\": ";                           \
+    _cpPlugins_error_message_ CPPLUGINS_MESSAGE;                        \
+    throw std::runtime_error( _cpPlugins_error_message_.str( ) );       \
+  }
 
-    // ---------------------------------------------------------------------
-    inline static std::string CanonicalPath( const std::string& path )
-      {
-        std::string ret = "";
-#ifdef cpPlugins_SYS_WINDOWS
-        TCHAR  buffer[ 4096 ] = TEXT( "" );
-        TCHAR** lppPart = { NULL };
-        GetFullPathName( path.c_str( ), 4096, buffer, lppPart );
-        ret = std::string( buffer );
-#else // cpPlugins_SYS_WINDOWS
-        char* canonical_path = realpath( path.c_str( ), NULL );
-        if( canonical_path != NULL )
-        {
-          ret = canonical_path;
-          free( canonical_path );
+#define _cpPluginsErrorMacro_0( )               \
+  _cpPluginsErrorMacro_1( << "Unknown error." )
 
-        } // fi
-#endif // cpPlugins_SYS_WINDOWS
-        return( ret );
-      }
-  };
+#define _cpPluginsErrorMacro_( x, A, B, FUNC, ... ) FUNC
 
-} // ecapseman
+#define cpPluginsErrorMacro( ... )                                      \
+  _cpPluginsErrorMacro_(, ##__VA_ARGS__,                                \
+                        _cpPluginsErrorMacro_2(__VA_ARGS__),            \
+                        _cpPluginsErrorMacro_1(__VA_ARGS__),            \
+                        _cpPluginsErrorMacro_0(__VA_ARGS__)             \
+    )
 
-#endif // __CPPLUGINS__CONFIG__H__
+#endif // __cpPlugins__Config__h__
 
 // eof - $RCSfile$