FirteX-高性能全文索引和检索平台

API Documentation


首页 | 名字空间列表 | 类继承关系 | 组合类型列表 | $(BL\录(B | 文件列表 | 名字空间成员 | 组合类型成员 | 文件成员

ComObject.h

浏览该文件的文档。
00001 //
00002 // Copyright(C) 2005--2006 Institute of Computing Tech, Chinese Academy of Sciences. 
00003 // All rights reserved.
00004 // This file is part of FirteX (www.firtex.org)
00005 //
00006 // Use of the FirteX is subject to the terms of the software license set forth in 
00007 // the LICENSE file included with this software, and also available at
00008 // http://www.firtex.org/license.html
00009 //
00010 // Author       : 郭瑞杰(GuoRuijie)
00011 // Email        : ruijieguo@software.ict.ac.cn,ruijieguo@gmail.com
00012 // Created      : 2006/5/15
00013 //
00014 #ifndef __COMOBJECT_H
00015 #define __COMOBJECT_H
00016 
00017 #if _MSC_VER > 1000
00018 #pragma once
00019 #endif // _MSC_VER > 1000
00020 
00021 #include "../utility/StdHeader.h"
00022 #include <stddef.h>
00023 #include "../com/Com.h"
00024 
00025 namespace firtex
00026 {
00027         namespace plugin
00028         {
00029                 class CComObject
00030                 {
00031                 public:
00032                         CComObject(void);
00033                         virtual ~CComObject(void);
00034                 public:
00035                         //FX_STDMETHOD(QueryInterface)( firtex::com::FX_IID const& riid, void** ptr );
00036                         FX_STDMETHOD_(uint32_t,AddRef)();
00037                         FX_STDMETHOD_(uint32_t,Release)();
00038 
00039                 private:
00040                         uint32_t        m_refCount;
00041                 };
00042 
00043         #define FX_METHOD_PROLOGUE(theClass, localClass) \
00044                 theClass* pThis = \
00045                 ((theClass*)((byte*)this - offsetof(theClass, m_x##localClass))); \
00046                 pThis; // avoid warning from compiler \
00047 
00048         #define INTERFACE_TO_CLASS(icClass, icInterface, icIn, icOut)   \
00049                 icClass * icOut = (icClass *)( (byte*) icIn - offsetof( icClass, m_x##icInterface ) );
00050         
00051         #define CLASS_TO_INTERFACE(icClass, icInterface, icIn, icOut)   \
00052                 X##icInterface* icOut = (X##icInterface*)( (byte*) icIn + offsetof( icClass, m_x##icInterface ) );
00053 
00054         #define BEGIN_INTERFACE_PART(localClass, baseClass) \
00055                 class X##localClass : public baseClass \
00056                 { \
00057                 public: \
00058                         FX_STDMETHOD(QueryInterface)(firtex::com::FX_REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject); \
00059                         FX_STDMETHOD_(uint32_t, AddRef)(); \
00060                         FX_STDMETHOD_(uint32_t, Release)(); \
00061                         
00062         #define END_INTERFACE_PART(localClass) \
00063                 } m_x##localClass; \
00064                 friend class X##localClass;\
00065 
00066         #define IMPLEMENT_UNKNOWN(theClass, localClass)                                 \
00067                 FX_STDMETHODIMP_(uint32_t) theClass::X##localClass::AddRef()    \
00068                 {                                                                                                                       \
00069                         FX_METHOD_PROLOGUE(theClass, localClass)                                        \
00070                         return pThis->AddRef();                                                                 \
00071                 }                                                                                                                       \
00072                 FX_STDMETHODIMP_(uint32_t) theClass::X##localClass::Release()   \
00073                 {                                                                                                                       \
00074                         FX_METHOD_PROLOGUE(theClass, localClass)                                        \
00075                         return pThis->Release();                                                                \
00076                 }                                                                                                                       \
00077                 FX_STDMETHODIMP theClass::X##localClass::QueryInterface(firtex::com::FX_REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)      \
00078                 {                                                                                                                       \
00079                         FX_METHOD_PROLOGUE(theClass, localClass)                                        \
00080                         if ( firtex::com::FX_IsEqualIID( riid, firtex::com::IUnknown::iid ) )\
00081                         {                                                                                                               \
00082                                 *ppvObject = static_cast<firtex::com::IUnknown*>(this); \
00083                                 pThis->AddRef();                                                                        \
00084                                 return FX_S_OK;                                                                         \
00085                         }                                                                                                               \
00086                         if ( firtex::com::FX_IsEqualIID( riid, X##localClass::iid ) ) \
00087                         {                                                                                                               \
00088                                 *ppvObject = static_cast<X##localClass*>( this );               \
00089                                 pThis->AddRef();                                                                        \
00090                                 return FX_S_OK;                                                                         \
00091                         }                                                                                                               \
00092                         return FX_E_NOINTERFACE;                                                                        \
00093                 }                                       
00094 
00095                 class GUIDX
00096                 {
00097                 public:
00098                         static tstring encode(const void * pInGUID);
00099                         static bool decode(const tchar* pszIn, void* pOutGUID);
00100                         inline static bool unhex(const tchar* psz, byte* pOut);
00101                 };
00102         }
00103 }
00104 
00105 #endif

http://www.firtex.org http://www.sourceforge.net/projects/firtex