FirteX-高性能全文索引和检索平台API Documentation |
00001 #include "com/Com.h" 00002 #include <pthread.h> 00003 00004 /* Windows maps COINIT values to 0x80 for apartment threaded, 0x140 00005 * for free threaded, and 0 for uninitialized apartments. There is 00006 * no real advantage in us doing this and certainly no release version 00007 * of an app should be poking around with these flags. So we need a 00008 * special value for uninitialized */ 00009 #define COINIT_UNINITIALIZED 0x100 00010 00011 namespace firtex 00012 { 00013 namespace com 00014 { 00015 namespace internal 00016 { 00017 struct apartment_t 00018 { 00019 int32_t lock_count; 00020 uint32_t model; 00021 IErrorInfo* errorinfo; 00022 pthread_t tid; 00023 pthread_mutex_t mutex; 00024 apartment_t* parent; 00025 apartment_t* next; 00026 apartment_t* prev; 00027 }; 00028 00029 enum log_level 00030 { 00031 ERROR=1,WARN,INFO,NONE 00032 }; 00033 00034 struct marshal_id 00035 { 00036 uint32_t processid; 00037 uint32_t objectid; /* unique value corresp. IUnknown of object */ 00038 FX_IID iid; 00039 }; 00040 00041 00042 struct thread_data_t 00043 { 00044 apartment_t* apartment; 00045 }; 00046 00047 class pthread_mutex_lock 00048 { 00049 public: 00050 pthread_mutex_lock( pthread_mutex_t* m ) 00051 { m_ = m; ::pthread_mutex_lock( m ); }; 00052 ~pthread_mutex_lock() 00053 { ::pthread_mutex_unlock( m_ ); }; 00054 private: 00055 pthread_mutex_t* m_; 00056 }; 00057 00058 class zstr 00059 { 00060 public: 00061 zstr() { s_ = 0; }; 00062 zstr( char const* rhs ); 00063 zstr( wchar_t const* rhs ); 00064 ~zstr(); 00065 00066 operator char const*() const { return s_; }; 00067 00068 zstr& operator=( char const* rhs ); 00069 zstr& operator=( wchar_t const* rhs ); 00070 bool append( char const* rhs ); 00071 bool append( wchar_t const* rhs ); 00072 00073 private: 00074 char* s_; 00075 zstr( zstr const& ); 00076 }; 00077 00078 class wzstr 00079 { 00080 public: 00081 wzstr() { s_ = 0; }; 00082 wzstr( char const* rhs ); 00083 wzstr( wchar_t const* rhs ); 00084 ~wzstr(); 00085 00086 operator wchar_t const*() const { return s_; }; 00087 00088 wzstr& operator=( char const* rhs ); 00089 wzstr& operator=( wchar_t const* rhs ); 00090 bool append( char const* rhs ); 00091 bool append( wchar_t const* rhs ); 00092 00093 private: 00094 wchar_t* s_; 00095 wzstr( wzstr const& ); 00096 }; 00097 00098 template <class T> 00099 T* create() 00100 { 00101 T* ret = 0; 00102 try 00103 { 00104 ret = new T(); 00105 } 00106 catch (... ) 00107 { 00108 // do nothing 00109 } 00110 return ret; 00111 } 00112 00113 00114 void log_printf( log_level, char const* format, ... ); 00115 apartment_t* CreateApartment( uint32_t ); 00116 void DestroyApartment( apartment_t* ); 00117 thread_data_t* GetThreadSpecificData(); 00118 00119 FX_HRESULT GetRegisteredClassObject( FX_REFCLSID rclsid, uint32_t dwClsContext, IUnknown** ppUnk); 00120 00121 // InprocServer32 Module 00122 FX_HRESULT GetInprocClassObject( FX_REFCLSID rclsid, IUnknown** ppUnk ); 00123 void FreeUnusedInprocServers(); 00124 00125 // special hooks for UNIX implementation 00126 wchar_t const* regsvr32_get_filename(); 00127 FX_HRESULT regsvr32_set_filename( wchar_t const* filename ); 00128 00129 };//end internal 00130 00131 };//end com 00132 }//end firtex 00133
http://www.firtex.org http://www.sourceforge.net/projects/firtex