ReactOS Fundraising Campaign 2012
 
€ 4,060 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

atlcore.h
Go to the documentation of this file.
00001 /*
00002  * ReactOS ATL
00003  *
00004  * Copyright 2009 Andrew Hill <ash77@reactos.org>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #pragma once
00022 
00023 #include <malloc.h>
00024 #include <olectl.h>
00025 #include <ocidl.h>
00026 
00027 #include <crtdbg.h>
00028 
00029 #ifndef ATLASSERT
00030 #define ATLASSERT(expr) _ASSERTE(expr)
00031 #endif // ATLASSERT
00032 
00033 namespace ATL
00034 {
00035 
00036 class CComCriticalSection
00037 {
00038 public:
00039     CRITICAL_SECTION                        m_sec;
00040 public:
00041     CComCriticalSection()
00042     {
00043         memset(&m_sec, 0, sizeof(CRITICAL_SECTION));
00044     }
00045 
00046     virtual ~CComCriticalSection()
00047     {
00048     }
00049 
00050     HRESULT Lock()
00051     {
00052         EnterCriticalSection(&m_sec);
00053         return S_OK;
00054     }
00055 
00056     HRESULT Unlock()
00057     {
00058         LeaveCriticalSection(&m_sec);
00059         return S_OK;
00060     }
00061 
00062     HRESULT Init()
00063     {
00064         InitializeCriticalSection(&m_sec);
00065         return S_OK;
00066     }
00067 
00068     HRESULT Term()
00069     {
00070         DeleteCriticalSection(&m_sec);
00071         return S_OK;
00072     }
00073 };
00074 
00075 class CComFakeCriticalSection
00076 {
00077 public:
00078     HRESULT Lock()
00079     {
00080         return S_OK;
00081     }
00082 
00083     HRESULT Unlock()
00084     {
00085         return S_OK;
00086     }
00087 
00088     HRESULT Init()
00089     {
00090         return S_OK;
00091     }
00092 
00093     HRESULT Term()
00094     {
00095         return S_OK;
00096     }
00097 };
00098 
00099 class CComAutoCriticalSection : public CComCriticalSection
00100 {
00101 public:
00102     CComAutoCriticalSection()
00103     {
00104         HRESULT                             hResult;
00105 
00106         hResult = CComCriticalSection::Init();
00107         ATLASSERT(SUCCEEDED(hResult));
00108     }
00109     ~CComAutoCriticalSection()
00110     {
00111         CComCriticalSection::Term();
00112     }
00113 };
00114 
00115 class CComSafeDeleteCriticalSection : public CComCriticalSection
00116 {
00117 private:
00118     bool                                    m_bInitialized;
00119 public:
00120     CComSafeDeleteCriticalSection()
00121     {
00122         m_bInitialized = false;
00123     }
00124 
00125     ~CComSafeDeleteCriticalSection()
00126     {
00127         Term();
00128     }
00129 
00130     HRESULT Lock()
00131     {
00132         ATLASSERT(m_bInitialized);
00133         return CComCriticalSection::Lock();
00134     }
00135 
00136     HRESULT Init()
00137     {
00138         HRESULT                             hResult;
00139 
00140         ATLASSERT(!m_bInitialized);
00141         hResult = CComCriticalSection::Init();
00142         if (SUCCEEDED(hResult))
00143             m_bInitialized = true;
00144         return hResult;
00145     }
00146 
00147     HRESULT Term()
00148     {
00149         if (!m_bInitialized)
00150             return S_OK;
00151         m_bInitialized = false;
00152         return CComCriticalSection::Term();
00153     }
00154 };
00155 
00156 class CComAutoDeleteCriticalSection : public CComSafeDeleteCriticalSection
00157 {
00158 private:
00159     // CComAutoDeleteCriticalSection::Term should never be called
00160     HRESULT Term();
00161 };
00162 
00163 struct _ATL_BASE_MODULE70
00164 {
00165     UINT                                    cbSize;
00166     HINSTANCE                               m_hInst;
00167     HINSTANCE                               m_hInstResource;
00168     bool                                    m_bNT5orWin98;
00169     DWORD                                   dwAtlBuildVer;
00170     GUID                                    *pguidVer;
00171     CRITICAL_SECTION                        m_csResource;
00172 #ifdef NOTYET
00173     CSimpleArray<HINSTANCE>                 m_rgResourceInstance;
00174 #endif
00175 };
00176 typedef _ATL_BASE_MODULE70 _ATL_BASE_MODULE;
00177 
00178 class CAtlBaseModule : public _ATL_BASE_MODULE
00179 {
00180 public :
00181     static bool                             m_bInitFailed;
00182 public:
00183     CAtlBaseModule()
00184     {
00185         cbSize = sizeof(_ATL_BASE_MODULE);
00186         GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)this, &m_hInst);
00187         m_hInstResource = m_hInst;
00188     }
00189 
00190     HINSTANCE GetModuleInstance()
00191     {
00192         return m_hInst;
00193     }
00194 
00195     HINSTANCE GetResourceInstance()
00196     {
00197         return m_hInstResource;
00198     }
00199 };
00200 
00201 extern CAtlBaseModule _AtlBaseModule;
00202 
00203 }; // namespace ATL

Generated on Tue May 22 2012 04:40:05 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.