Defs.hpp

00001 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00002 //
00003 //        This file is part of E-Cell Simulation Environment package
00004 //
00005 //                Copyright (C) 1996-2002 Keio University
00006 //
00007 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00008 //
00009 //
00010 // E-Cell is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2 of the License, or (at your option) any later version.
00014 // 
00015 // E-Cell is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 // See the GNU General Public License for more details.
00019 // 
00020 // You should have received a copy of the GNU General Public
00021 // License along with E-Cell -- see the file COPYING.
00022 // If not, write to the Free Software Foundation, Inc.,
00023 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 // 
00025 //END_HEADER
00026 //
00027 // written by Koichi Takahashi <shafi@e-cell.org>,
00028 // E-Cell Project.
00029 //
00030 
00031 
00032 #ifndef __DEFS_HPP
00033 #define __DEFS_HPP
00034 #include "ecell_config.h"
00035 
00036 #include <float.h>
00037 #include <string>
00038 #include <list>
00039 #include <vector>
00040 #include <map>
00041 #include <time.h>
00042 
00043 #include <boost/call_traits.hpp>
00044 #include <boost/smart_ptr.hpp>
00045 
00046 #define DEBUG 1
00047 
00048 // stringifiers.  see preprocessor manual
00049 #define XSTR( S ) STR( S )
00050 #define STR( S ) #S
00051 
00052 
00053 #define USE_LIBECS using namespace libecs
00054 
00055 // cmath
00056 
00057 #if defined( HAVE_CMATH )
00058 #include <cmath>
00059 #elif defined( HAVE_MATH )
00060 #include <math>
00061 #else
00062 #error "either math or cmath header is needed."
00063 #endif /* HAVE_CMATH */
00064 #if defined( USE_MSVC )
00065 #define _USE_MATH_DEFINES
00066 #include <math.h>
00067 #undef _USE_MATH_DEFINES
00068 #endif /* M_PI, M_E */
00069 
00070 
00071 #if defined( HAVE_STDINT_H )
00072 #include <stdint.h>
00073 #endif /* HAVE_STDINT_H */
00074 
00075 #if defined( HAVE_DLFCN_H )
00076 #include <dlfcn.h>
00077 #include <ltdl.h>
00078 #endif /* HAVE_DLFCN_H */
00079 
00080 #if defined( HAVE_WINDOWS_H )
00081 #include <windows.h>
00082 #if defined GetClassInfo
00083 #undef GetClassInfo
00084 #endif
00085 #endif /* HAVE_WINDOWS_H */
00086 
00087 // 
00088 // If USE_COMPILER_EXTENSIONS is defined, the compiler's special
00089 // language syntax and optimizations that are not part of the standard
00090 // (such as ISO C++) are exploited.
00091 //
00092 // Defined macros:
00093 //
00094 // LIBECS_USE_PMF_CONVERSIONS 
00095 // If this macro is defined, conversions from pointer-to-member-functions 
00096 // to usual function pointers can be used.
00097 //
00098 //
00099 // LIBECS_LIKELY( EXP ), LIBECS_UNLIKELY( EXP )
00100 // These macros indicate the expression EXP is very (un)likely to be true,
00101 // and the branch based on this will be frequently (not) taken.
00102 // These are typically used in if() statements.   Unless you are very sure,
00103 // it is a good idea to not to try to do this job by yourself and just 
00104 // rely on the compiler and CPU's branch prediction mechanisms and 
00105 // profile-based branch counters. These macros do nothing when 
00106 // libecs does not support branch prediction on the platform.
00107 //
00108 //
00109 // LIBECS_PREFETCH( ADDR, RW, LOCALITY )
00110 // This macro prefetches the content of memory at the address ADDR,
00111 // and refreshes the cache.   If RW is zero, the cache is prepared for
00112 // a read access, and one for a write access.  LOCALITY (0..3) indicates
00113 // the temporal locality of the access.   Larger values let the
00114 // accessed addresses more sticky on the cache.
00115 // These macros do nothing when libecs does not support prefetching
00116 // on the platform.
00117 //
00118 
00119 #if defined( USE_COMPILER_EXTENSIONS ) && defined( __GNUC__ )
00120 #    define LIBECS_USE_PMF_CONVERSIONS 1
00121 #    define LIBECS_LIKELY( EXP )       __builtin_expect( ( EXP ), 1 )
00122 #    define LIBECS_UNLIKELY( EXP )     __builtin_expect( ( EXP ), 0 )
00123 #    define LIBECS_PREFETCH( ADDR, RW, LOCALITY )\
00124             __builtin_prefetch( ( ADDR ), ( RW ), ( LOCALITY ) )
00125 #else
00126 // do not define LIBECS_USE_PMF_CONVERSIONS
00127 #    define LIBECS_LIKELY( EXP )       ( EXP )
00128 #    define LIBECS_UNLIKELY( EXP )     ( EXP )
00129 #    define LIBECS_PREFETCH            
00130 #endif /* defined( USE_COMPILER_EXTENSIONS ) && defined( __GNUC__ ) */
00131 
00132 
00133 namespace libecs
00134 {
00135 
00136   // Some macros those origins are libCoreLinux++
00137 
00138   /**
00139      IGNORE_RETURN is an indicator that the return
00140      value for a function is ignored.
00141      i.e   IGNORE_RETURN getSomething( ... );
00142      Eliminates a lint warning.
00143   */
00144 
00145 #define IGNORE_RETURN (void)
00146 
00147   /**
00148      Declare a new type and its pointer,
00149      const pointer, reference, and const reference types. For example
00150      DECLARE_TYPE( Dword, VeryLongTime );
00151      @param mydecl The base type
00152      @param mytype The new type
00153   */
00154 
00155 #define DECLARE_TYPE( mydecl, mytype )  \
00156 typedef mydecl         mytype;         \
00157 typedef mytype *       mytype ## Ptr;  \
00158 typedef const mytype * mytype ## Cptr; \
00159 typedef mytype &       mytype ## Ref;  \
00160 typedef const mytype & mytype ## Cref;
00161 
00162   /**
00163      Declare class , class pointer , 
00164      const pointer, class reference 
00165      and const class reference types for classes. For example
00166      DECLARE_CLASS( Exception );
00167      @param tag The class being declared
00168   */
00169 
00170 #define DECLARE_CLASS( tag )            \
00171    class   tag;                        \
00172    typedef tag *       tag ## Ptr;     \
00173    typedef const tag * tag ## Cptr;    \
00174    typedef tag &       tag ## Ref;     \
00175    typedef const tag & tag ## Cref;
00176 
00177 #define DECLARE_SHAREDPTR( type )\
00178   typedef boost::shared_ptr<type> type ## SharedPtr;\
00179   typedef type ## SharedPtr *       type ## SharedPtr ## Ptr;     \
00180   typedef const type ## SharedPtr * type ## SharedPtr ## Cptr;    \
00181   typedef type ## SharedPtr &       type ## SharedPtr ## Ref;     \
00182   typedef const type ## SharedPtr & type ## SharedPtr ## Cref;
00183 
00184 
00185 
00186   // *******************************************
00187   // Define the void pointer type.
00188   // *******************************************
00189    
00190   typedef void * VoidPtr;
00191 
00192   // *******************************************
00193   // Define the NULLPTR
00194   // *******************************************
00195 
00196 #define  NULLPTR  0
00197    
00198   /**
00199      STL list template. This macro generates all
00200      the type references and pointers for the collection and
00201      respective iterators for a list.
00202      @param name The name you want to give the collection
00203      @param type The type object the collection manages
00204   */
00205 #define DECLARE_LIST( type, name )                            \
00206       DECLARE_TYPE(std::list<type>,name);                       \
00207       typedef name::iterator name ## Iterator;                  \
00208       typedef name::iterator& name ## IteratorRef;              \
00209       typedef name::iterator* name ## IteratorPtr;              \
00210       typedef name::const_iterator name ## ConstIterator;       \
00211       typedef name::const_iterator& name ## ConstIteratorRef;   \
00212       typedef name::const_iterator* name ## ConstIteratorPtr;   \
00213       typedef name::reverse_iterator name ## Riterator;         \
00214       typedef name::reverse_iterator& name ## RiteratorRef;     \
00215       typedef name::reverse_iterator* name ## RiteratorPtr
00216 
00217 
00218   /**
00219      STL vector template. This macro generates all
00220      the type references and pointers for the collection and
00221      respective iterators for a vector.
00222      @param name The name you want to give the collection
00223      @param type The type for the vector
00224   */
00225 #define DECLARE_VECTOR( type, name )                            \
00226    DECLARE_TYPE(std::vector<type>,name);                       \
00227    typedef name::iterator name ## Iterator;                    \
00228    typedef name::iterator& name ## IteratorRef;                \
00229    typedef name::iterator* name ## IteratorPtr;                \
00230    typedef name::const_iterator name ## ConstIterator;         \
00231    typedef name::const_iterator& name ## ConstIteratorRef;     \
00232    typedef name::const_iterator* name ## ConstIteratorPtr;     \
00233    typedef name::reverse_iterator name ## Riterator;           \
00234    typedef name::reverse_iterator& name ## RiteratorRef;       \
00235    typedef name::reverse_iterator* name ## RiteratorPtr
00236 
00237 
00238   /**
00239      STL set template. This macro generates all
00240      the type references and pointers for the collection and
00241      respective iterators for a set.
00242      @param name The name you want to give the collection
00243      @param key The object that represents the set key
00244      @param comp The comparator functor
00245   */
00246 #define DECLARE_SET(key,comp,name)                                       \
00247       typedef set<key, comp > name;                                           \
00248       typedef name *       name ## Ptr;                                       \
00249       typedef const name * name ## Cptr;                                      \
00250       typedef name &       name ## Ref;                                       \
00251       typedef const name & name ## Cref;                                      \
00252       typedef name::iterator name ## Iterator;                                \
00253       typedef name::iterator& name ## IteratorRef;                            \
00254       typedef name::iterator* name ## IteratorPtr;                            \
00255       typedef name::const_iterator name ## ConstIterator;                     \
00256       typedef name::const_iterator& name ## ConstIteratorRef;                 \
00257       typedef name::const_iterator* name ## ConstIteratorPtr;                 \
00258       typedef name::reverse_iterator name ## Riterator;                       \
00259       typedef name::reverse_iterator& name ## RiteratorRef;                   \
00260       typedef name::reverse_iterator* name ## RiteratorPtr
00261    
00262   /**
00263      STL multiset template. This macro generates all
00264      the type references and pointers for the collection and
00265      respective iterators for a multiset.
00266      @param name The name you want to give the collection
00267      @param key The object that represents the mutliset key
00268      @param comp The comparator functor
00269   */
00270 #define DECLARE_MULTISET(key,comp,name)                                  \
00271       typedef multiset<key, comp > name;                                      \
00272       typedef name *       name ## Ptr;                                       \
00273       typedef const name * name ## Cptr;                                      \
00274       typedef name &       name ## Ref;                                       \
00275       typedef const name & name ## Cref;                                      \
00276       typedef name::iterator name ## Iterator;                                \
00277       typedef name::iterator& name ## IteratorRef;                            \
00278       typedef name::iterator* name ## IteratorPtr;                            \
00279       typedef name::const_iterator name ## ConstIterator;                     \
00280       typedef name::const_iterator& name ## ConstIteratorRef;                 \
00281       typedef name::const_iterator* name ## ConstIteratorPtr;                 \
00282       typedef name::reverse_iterator name ## Riterator;                       \
00283       typedef name::reverse_iterator& name ## RiteratorRef;                   \
00284       typedef name::reverse_iterator* name ## RiteratorPtr
00285 
00286 
00287   /**
00288      STL map template. This macro generates all
00289      the type references and pointers for the collection and
00290      respective iterators for a map.
00291      @param name The name you want to give the collection
00292      @param key The object that represents the map key
00293      @param value The object that the key is associated to
00294      @param comp The comparator functor
00295   */
00296 #define DECLARE_MAP(key,value,comp,name)                             \
00297       typedef std::map<key,value,comp > name;                      \
00298       typedef name *       name ## Ptr;                            \
00299       typedef const name * name ## Cptr;                           \
00300       typedef name &       name ## Ref;                            \
00301       typedef const name & name ## Cref;                           \
00302       typedef name::iterator name ## Iterator;                     \
00303       typedef name::iterator& name ## IteratorRef;                 \
00304       typedef name::iterator* name ## IteratorPtr;                 \
00305       typedef name::const_iterator name ## ConstIterator;          \
00306       typedef name::const_iterator& name ## ConstIteratorRef;      \
00307       typedef name::const_iterator* name ## ConstIteratorPtr;      \
00308       typedef name::reverse_iterator name ## Riterator;            \
00309       typedef name::reverse_iterator& name ## RiteratorRef;        \
00310       typedef name::reverse_iterator* name ## RiteratorPtr
00311    
00312   /**
00313      STL multimap template. This macro generates all
00314      the type references and pointers for the collection and
00315      respective iterators for a multimap.
00316      @param name The name you want to give the collection
00317      @param key The object that represents the map key
00318      @param value The object that the key is associated to
00319      @param comp The comparator functor
00320   */
00321 
00322 #define DECLARE_MULTIMAP(key,value,comp,name)                 \
00323       typedef std::multimap<key,value,comp > name;                 \
00324       typedef name *       name ## Ptr;                            \
00325       typedef const name * name ## Cptr;                           \
00326       typedef name &       name ## Ref;                            \
00327       typedef const name & name ## Cref;                           \
00328       typedef name::iterator name ## Iterator;                     \
00329       typedef name::iterator& name ## IteratorRef;                 \
00330       typedef name::iterator* name ## IteratorPtr;                 \
00331       typedef name::const_iterator name ## ConstIterator;          \
00332       typedef name::const_iterator& name ## ConstIteratorRef;      \
00333       typedef name::const_iterator* name ## ConstIteratorPtr;      \
00334       typedef name::reverse_iterator name ## Riterator;            \
00335       typedef name::reverse_iterator& name ## RiteratorRef;        \
00336       typedef name::reverse_iterator* name ## RiteratorPtr
00337 
00338 
00339   /**
00340      STL queue template. This macro generates all
00341      the type references and pointers for the collection and
00342      respective iterators for a queue.
00343      @param name The name you want to give the collection
00344      @param type The type to be queued
00345   */
00346 #define DECLARE_QUEUE( type, name )                          \
00347       DECLARE_TYPE(std::deque<type>,name);                     \
00348       typedef name::iterator name ## Iterator;                 \
00349       typedef name::iterator& name ## IteratorRef;             \
00350       typedef name::iterator* name ## IteratorPtr;             \
00351       typedef name::const_iterator name ## ConstIterator;      \
00352       typedef name::const_iterator& name ## ConstIteratorRef;  \
00353       typedef name::const_iterator* name ## ConstIteratorPtr;  \
00354       typedef name::reverse_iterator name ## Riterator;        \
00355       typedef name::reverse_iterator& name ## RiteratorRef;    \
00356       typedef name::reverse_iterator* name ## RiteratorPtr
00357 
00358   /**
00359      STL stack template. This macro generates all
00360      the type references and pointers for the collection and
00361      respective iterators for a stack.
00362      @param name The name you want to give the collection
00363      @param type The type to be stacked
00364   */
00365 #define DECLARE_STACK( type, name )                                 \
00366       DECLARE_TYPE(stack<type>,name)                                   
00367 
00368 
00369   // from Loki
00370 
00371   
00372 #define DECLARE_ASSOCVECTOR(key,value,comp,name)                             \
00373       typedef ::Loki::AssocVector<key,value,comp > name;                      \
00374       typedef name *       name ## Ptr;                            \
00375       typedef const name * name ## Cptr;                           \
00376       typedef name &       name ## Ref;                            \
00377       typedef const name & name ## Cref;                           \
00378       typedef name::iterator name ## Iterator;                     \
00379       typedef name::iterator& name ## IteratorRef;                 \
00380       typedef name::iterator* name ## IteratorPtr;                 \
00381       typedef name::const_iterator name ## ConstIterator;          \
00382       typedef name::const_iterator& name ## ConstIteratorRef;      \
00383       typedef name::const_iterator* name ## ConstIteratorPtr;      \
00384       typedef name::reverse_iterator name ## Riterator;            \
00385       typedef name::reverse_iterator& name ## RiteratorRef;        \
00386       typedef name::reverse_iterator* name ## RiteratorPtr
00387 
00388 #define DECLARE_ASSOCVECTOR_TEMPLATE(key,value,comp,name)                \
00389       typedef ::Loki::AssocVector<key,value,comp > name;                      \
00390       typedef name *       name ## Ptr;                            \
00391       typedef const name * name ## Cptr;                           \
00392       typedef name &       name ## Ref;                            \
00393       typedef const name & name ## Cref;                           \
00394       typedef typename name::iterator name ## Iterator;                     \
00395       typedef typename name::iterator& name ## IteratorRef;                 \
00396       typedef typename name::iterator* name ## IteratorPtr;                 \
00397       typedef typename name::const_iterator name ## ConstIterator;          \
00398       typedef typename name::const_iterator& name ## ConstIteratorRef;      \
00399       typedef typename name::const_iterator* name ## ConstIteratorPtr;      \
00400       typedef typename name::reverse_iterator name ## Riterator;            \
00401       typedef typename name::reverse_iterator& name ## RiteratorRef;        \
00402       typedef typename name::reverse_iterator* name ## RiteratorPtr
00403 
00404 
00405   // Types
00406 
00407   template <typename T>
00408   class Param
00409   {
00410   public:
00411     typedef typename boost::call_traits<T>::param_type type;
00412   };
00413 
00414   // String
00415 
00416   DECLARE_TYPE( std::string, String );
00417 
00418   DECLARE_TYPE( const char* const, StringLiteral );
00419 
00420   // Numeric types
00421 
00422   DECLARE_TYPE( long int, Integer );
00423   DECLARE_TYPE( unsigned long int, UnsignedInteger );
00424   typedef Param<Integer>::type IntegerParam;
00425   typedef Param<UnsignedInteger>::type UnsignedIntegerParam;
00426 
00427 
00428   // these can cause problem when used as template parameters
00429   //  DECLARE_TYPE( int64_t, Integer );
00430   //  DECLARE_TYPE( uint64_t, UnsignedInteger );
00431 
00432   //  DECLARE_TYPE( double, Real );
00433   DECLARE_TYPE( double, Real );
00434   typedef Param<Real>::type RealParam;
00435 
00436 #if defined( HAVE_LONG_DOUBLE )
00437   DECLARE_TYPE( long double, HighReal );
00438 #else
00439   DECLARE_TYPE( double, HighReal );
00440   #define HIGHREAL_IS_REAL 1
00441 #endif /* defined( HAVE_LONG_DOUBLE ) */
00442   typedef Param<HighReal>::type HighRealParam;
00443     
00444   //  DECLARE_TYPE( HighReal, Time );
00445   DECLARE_TYPE( Real, Time );
00446   typedef Param<Time>::type TimeParam;
00447     
00448   //! Infinity.  Currently this is defined as INFINITY symbol of C99 standard.
00449 #if defined( HAVE_INFINITY )
00450   const Real INF( INFINITY );
00451 #else
00452   const Real INF( HUGE_VAL );
00453 #endif
00454 
00455 
00456   //! Avogadro number. 
00457   const Real N_A( 6.0221367e+23 );
00458 
00459   //! 1 / Avogadro number (reciprocal of N_A)
00460   const Real N_A_R( 1.0 / N_A );
00461 
00462   // functions
00463 
00464 #if defined( FP_FAST_FMA )
00465   inline const Real FMA( const Real a, const Real b, const Real c )
00466   {
00467     return ::fma( a, b, c );
00468   }
00469 #else
00470   inline const Real FMA( const Real a, const Real b, const Real c )
00471   {
00472     return a * b + c;
00473   }
00474 #endif /* defined( FP_FAST_FMA ) */
00475 
00476 
00477   // MACROS
00478 
00479 #if !defined( HAVE_PRETTY_FUNCTION )
00480 #define __PRETTY_FUNCTION__ ""
00481 #endif
00482 
00483   /**
00484      Converts each type into a unique, insipid type.
00485      Invocation Type2Type<T> where T is a type.
00486      Defines the type OriginalType which maps back to T.
00487      
00488      taken from loki library.
00489 
00490      @ingroup util
00491   */
00492 
00493   template <typename T>
00494   struct Type2Type
00495   {
00496     typedef T OriginalType;
00497   };
00498 
00499 
00500 } // namespace libecs
00501 
00502 
00503 /**
00504    4 MSVC
00505  */
00506 /**
00507    DLL
00508  */
00509 #if defined( USE_MSVC )
00510 #if defined( ECELL_EXPORTS )
00511 #define ECELL_API __declspec( dllexport )
00512 #else
00513 #define ECELL_API __declspec( dllimport )
00514 #endif /* ECELL_EXPORTS */
00515 #else
00516 #define ECELL_API
00517 #endif /* USE_MSVC */
00518 /**
00519    Virtual Libtool
00520  */
00521 #if defined( USE_MSVC )
00522 
00523 #define DM_PATH "dm"
00524 #define FILE_EXTENSION ".dll"
00525 #define REGISTORY_DM_KEY L"ECELLIDE_DM"
00526 #define REGISTORY_ENV_KEY L"Environment"
00527 #define REGISTORY_SW_KEY L"Software\\KeioUniv\\E-Cell_IDE"
00528 #define SIZE 10000
00529 class Util
00530 {
00531 private:
00532     static std::string getDMPath(HKEY aHKEY, LPCWSTR aSubKey)
00533     {
00534         HKEY hKey;
00535         DWORD dwType;
00536         DWORD dwSize;
00537         LONG errorCode = RegOpenKeyEx(aHKEY, aSubKey, 0, KEY_READ, &hKey);
00538         if(errorCode != 0)
00539         {
00540             return "";
00541         }
00542         wchar_t aValueWide[SIZE];
00543         errorCode = RegQueryValueEx(hKey, REGISTORY_DM_KEY, NULL, &dwType, NULL, &dwSize);
00544         if(errorCode != 0)
00545         {
00546             return "";
00547         }
00548         errorCode = RegQueryValueEx(hKey, REGISTORY_DM_KEY, NULL, &dwType, (LPBYTE)&aValueWide, &dwSize);
00549         if(errorCode != 0)
00550         {
00551             return "";
00552         }
00553         int buffSize = WideCharToMultiByte(CP_ACP, 0, aValueWide, -1, NULL, 0, NULL, NULL);
00554         if(buffSize <= 0)
00555         {
00556             return "";
00557         }
00558         LPSTR aValue = new char [buffSize];
00559         buffSize = WideCharToMultiByte(CP_ACP, 0, aValueWide, -1, aValue, buffSize, NULL, NULL);
00560         if(buffSize <= 0)
00561         {
00562             return "";
00563         }
00564         RegCloseKey(hKey);
00565         return aValue;
00566     }
00567 public:
00568     static std::string getDMPath()
00569     {
00570         std::string aPath;
00571         if((aPath = Util::getDMPath(HKEY_CURRENT_USER, REGISTORY_ENV_KEY)).length() > 0)
00572         {
00573             return aPath;
00574         }
00575         else if((aPath = Util::getDMPath(HKEY_CURRENT_USER, REGISTORY_SW_KEY)).length() > 0)
00576         {
00577             return aPath;
00578         }
00579         else
00580         {
00581             return Util::getDMPath(HKEY_LOCAL_MACHINE, REGISTORY_SW_KEY);
00582         }
00583     }
00584 };
00585 #define lt_dlclose(x) FreeLibrary(x)
00586 #define lt_dlhandle HMODULE
00587 #define lt_dlsym(x, y) GetProcAddress(x, y)
00588 static char errbuf[64];
00589 static char * lt_dlerror()
00590 {
00591   sprintf_s(errbuf, "LoadLibrary/GetProcAddress error %d", static_cast<int>(GetLastError()));
00592   return errbuf;
00593 }
00594 static int lt_dlexit()
00595 {
00596     return 0;
00597 }
00598 static const char * lt_dlgetsearchpath()
00599 {
00600     return 0;
00601 }
00602 static int lt_dlinit()
00603 {
00604     return 0;
00605 }
00606 static lt_dlhandle lt_dlopenext(const char* aFileName)
00607 {
00608     if (aFileName == NULL)
00609     {
00610         return NULL;
00611     }
00612     std::string anAllDMPath = Util::getDMPath();
00613     if (anAllDMPath.size() < 1)
00614     {
00615       anAllDMPath = DM_PATH;
00616     }
00617     while (anAllDMPath.size() > 0)
00618     {
00619         int anIndex = static_cast<int>(anAllDMPath.find(";"));
00620         char aDMPath[SIZE];
00621         if(anIndex == -1)
00622         {
00623             strcpy_s(aDMPath, anAllDMPath.c_str());
00624             anAllDMPath.clear();
00625         }
00626         else if(anIndex == anAllDMPath.size() - 1)
00627         {
00628             strcpy_s(aDMPath, anAllDMPath.substr(0, anIndex).c_str());
00629             anAllDMPath.clear();
00630         }
00631         else
00632         {
00633             strcpy_s(aDMPath, anAllDMPath.substr(0, anIndex).c_str());
00634             anAllDMPath = anAllDMPath.substr(anIndex + 1);
00635         }
00636         std::string dllNameStr = std::string(aDMPath) + "/" + aFileName + FILE_EXTENSION;
00637         char dllName[SIZE];
00638         strcpy_s(dllName, dllNameStr.c_str());
00639         wchar_t dllNameWide[SIZE];
00640         MultiByteToWideChar(CP_ACP, 0, dllName, -1, dllNameWide, SIZE);
00641         lt_dlhandle aHandle = LoadLibrary(dllNameWide);
00642         if (aHandle != NULL)
00643         {
00644             return aHandle;
00645         }
00646     }
00647     return NULL;
00648 }
00649 static int lt_dlsetsearchpath(const char *search_path)
00650 {
00651     return 0;
00652 }
00653 /**
00654    Some Functions
00655  */
00656 #define fmin(x, y) __min(x, y)
00657 #endif /* USE_MSVC */
00658 
00659 #endif /* __DEFS_HPP */
00660 
00661 /*
00662   Do not modify
00663   $Author: sachiboo $
00664   $Revision: 2616 $
00665   $Date: 2006-11-24 12:52:28 +0100 (Fri, 24 Nov 2006) $
00666   $Locker$
00667 */
00668 
00669 
00670 

Generated on Fri Aug 31 18:42:38 2007 for E-CELL C++ libraries (libecs and libemc) 3.1.105 by  doxygen 1.5.3