Salome HOME
Fix compilation pb.
[modules/kernel.git] / src / SALOMELocalTrace / LocalTraceBufferPool.cxx
index c7d321ec6597dbb7093f1f8e1547a5fcf7efdcfc..f41e57593b0c60599283b6b11c3468b1f44a820e 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2004  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  copyright (C) 2004  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
 // 
 //  This library is free software; you can redistribute it and/or 
@@ -15,7 +15,7 @@
 //  License along with this library; if not, write to the Free Software 
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 // 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //  Author : Paul RASCLE (EDF)
 //  Module : KERNEL
@@ -31,6 +31,7 @@
 #ifndef WNT
 #include <dlfcn.h>
 #else
+#include <windows.h>
 #endif
 
 //#define _DEVDEBUG_
@@ -51,12 +52,12 @@ using namespace std;
 // Class static attributes initialisation
 
 LocalTraceBufferPool* LocalTraceBufferPool::_singleton = 0;
-#ifndef WNT
-pthread_mutex_t LocalTraceBufferPool::_singletonMutex;
-#else
+//#ifndef WNT
+//pthread_mutex_t LocalTraceBufferPool::_singletonMutex;
+//#else
 pthread_mutex_t LocalTraceBufferPool::_singletonMutex =
   PTHREAD_MUTEX_INITIALIZER;
-#endif
+//#endif
 BaseTraceCollector *LocalTraceBufferPool::_myThreadTrace = 0;
 
 // ============================================================================
@@ -93,10 +94,8 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance()
          // --- start a trace Collector
 
          char* traceKind = getenv("SALOME_trace");
-         assert(traceKind);
-         //cerr<<"SALOME_trace="<<traceKind<<endl;
 
-         if (strcmp(traceKind,"local")==0)
+         if ( !traceKind || strcmp(traceKind,"local")==0 ) // mkr : 27.11.2006 : PAL13967 - Distributed supervision graphs - Problem with "SALOME_trace"
            {
              _myThreadTrace = LocalTraceCollector::instance();
            }
@@ -112,27 +111,33 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance()
            }
          else // --- try a dynamic library
            {
-             void* handle;
 #ifndef WNT
+             void* handle;
              string impl_name = string ("lib") + traceKind 
                + string("TraceCollector.so");
              handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ;
 #else
+             HINSTANCE handle;
              string impl_name = string ("lib") + traceKind + string(".dll");
-             handle = dlopen( impl_name.c_str() , 0 ) ;
+             handle = LoadLibrary( impl_name.c_str() );
 #endif
              if ( handle )
                {
                  typedef BaseTraceCollector * (*FACTORY_FUNCTION) (void);
+#ifndef WNT
                  FACTORY_FUNCTION TraceCollectorFactory =
                    (FACTORY_FUNCTION) dlsym(handle, "SingletonInstance");
-                 char *error ;
-                 if ( (error = dlerror() ) != NULL)
-                   {
+#else
+                 FACTORY_FUNCTION TraceCollectorFactory =
+                   (FACTORY_FUNCTION)GetProcAddress(handle, "SingletonInstance");
+#endif
+                 if ( !TraceCollectorFactory )
+                 {
                      cerr << "Can't resolve symbol: SingletonInstance" <<endl;
-                     cerr << "dlerror: " << error << endl;
-                     assert(error == NULL); // to give file and line
-                     exit(1);               // in case assert is deactivated
+#ifndef WNT
+                     cerr << "dlerror: " << dlerror() << endl;
+#endif
+                     exit( 1 );
                    }
                  _myThreadTrace = (TraceCollectorFactory) ();
                }