Home | History | Annotate | Download | only in Inc
      1 /*******************************************************************************
      2 **+--------------------------------------------------------------------------+**
      3 **|                                                                          |**
      4 **| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/         |**
      5 **|                                                                          |**
      6 **| Licensed under the Apache License, Version 2.0 (the "License");          |**
      7 **| you may not use this file except in compliance with the License.         |**
      8 **| You may obtain a copy of the License at                                  |**
      9 **|                                                                          |**
     10 **|     http://www.apache.org/licenses/LICENSE-2.0                           |**
     11 **|                                                                          |**
     12 **| Unless required by applicable law or agreed to in writing, software      |**
     13 **| distributed under the License is distributed on an "AS IS" BASIS,        |**
     14 **| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
     15 **| See the License for the specific language governing permissions and      |**
     16 **| limitations under the License.                                           |**
     17 **|                                                                          |**
     18 **+--------------------------------------------------------------------------+**
     19 *******************************************************************************/
     20 
     21 /*--------------------------------------------------------------------------*/
     22 /* Module:      TI_OAL.h*/
     23 /**/
     24 /* Purpose:     This file contains a interface for the TI_OAL class.*/
     25 /**/
     26 /*////////////////////////////////////////////////////////////////////*/
     27 
     28 #if !defined(AFX_TIUNILIB_H__F79CA4B8_8596_4F36_B541_2B2FCCF70197__INCLUDED_)
     29 #define AFX_TIUNILIB_H__F79CA4B8_8596_4F36_B541_2B2FCCF70197__INCLUDED_
     30 
     31 #if _MSC_VER > 1000
     32 #pragma once
     33 #endif /* _MSC_VER > 1000*/
     34 
     35 #include "osTIType.h"
     36 #include "TI_Results.h"
     37 
     38 #ifdef _UNICODE
     39     #define tisprintf   swprintf
     40     #define tistrncpy   wcsncpy
     41 #else
     42     #define tisprintf   sprintf
     43     #define tistrncpy   strncpy
     44 #endif
     45 
     46 
     47 class  TI_OSWrapCriticalSection
     48 {
     49     protected:
     50                 tiVOID*     m_pCS;
     51     public:
     52         static  TI_OSWrapCriticalSection*   CreateObject();
     53         static  tiVOID          DeleteObject(TI_OSWrapCriticalSection* pObj);
     54 
     55                     TI_OSWrapCriticalSection() {}
     56         virtual    ~TI_OSWrapCriticalSection() {}
     57         virtual tiVOID    Enter               ()  = 0;
     58         virtual tiVOID    Leave               ()  = 0;
     59 };
     60 
     61 class  TI_OSCriticalSection
     62 {
     63         TI_OSWrapCriticalSection*               m_pWrapCS;
     64 
     65     public:
     66                     TI_OSCriticalSection();
     67                    ~TI_OSCriticalSection();
     68                 tiVOID    Enter               ();
     69                 tiVOID    Leave               ();
     70 };
     71 /*
     72 class  TI_OSWrapEvent
     73 {
     74     protected:
     75                 tiVOID*     m_pEvent;
     76     public:
     77         static  TI_OSWrapEvent*   CreateObject();
     78 
     79                     TI_OSWrapEvent()    {}
     80                    ~TI_OSWrapEvent()    {}
     81         virtual tiUINT32    Wait    ( tiUINT32 uTime )  = 0;
     82         virtual tiVOID      Set     ()  = 0;
     83         virtual tiVOID      Reset   ()  = 0;
     84 };
     85 
     86 class  TI_OSEvent
     87 {
     88         TI_OSWrapEvent*               m_pWrapEvent;
     89 
     90     public:
     91                     TI_OSEvent();
     92                    ~TI_OSEvent();
     93              tiUINT32    Wait    ( tiUINT32 uTime );
     94              tiVOID      Set     ();
     95              tiVOID      Reset   ();
     96 };
     97 */
     98 typedef tiUINT32 (* tiPTHREAD_START_ROUTINE)( tiVOID* pThreadParameter );
     99 
    100 class  TI_OAL
    101 {
    102     protected:
    103 
    104                                 TI_OAL            ();
    105         virtual                ~TI_OAL            ();
    106 
    107         static  TI_OAL*       _instance;
    108         static  tiUINT32        m_uReferenceCount;
    109 
    110     public:
    111         static  TI_OAL*     GetInstance             (); /* static function for create TI_OSlib object*/
    112         static  tiVOID      FreeInstance            (); /* static function for release TI_OAL object*/
    113 
    114         /* list of functions that will call from Utility Adapter and Utility GUI modules */
    115         virtual tiVOID      TIOutputDebugString     (tiCHAR* lpOutputString)                                        = 0;
    116         virtual tiBOOL      TIIsBadWritePtr         (tiVOID* lp, tiUINT32 ucb )                                     = 0;
    117 
    118         /* list of functions that will call from Windows Utility module */
    119         virtual tiUINT32    TILoadLibrary           (tiCHAR*    pLibFileName)                                       = 0;
    120         virtual tiBOOL      TIFreeLibrary           (tiUINT32   hLibModule)                                         = 0;
    121         virtual tiUINT32    TIGetProcAddress        (tiUINT32   hModule, tiCHAR* lpProcName )                       = 0;
    122         virtual tiUINT32    TIRegisterWindowMessage (tiCHAR*    pszMsgName )                                        = 0;
    123         virtual tiBOOL      TIPostMessage           (tiUINT32 hWnd, tiUINT32 Msg, tiUINT32 wParam, tiUINT32 lParam) = 0;
    124         virtual tiVOID      TIPrintLastError        (tiCHAR*    psz)                                                = 0;
    125         virtual tiUINT32    TIGetCurrentThreadId    ()                                                              = 0;
    126         virtual tiUINT32    TICreateThread          (tiPTHREAD_START_ROUTINE pStartAddress, tiVOID* pParameter )    = 0;
    127         virtual tiVOID      TISleep                 (tiUINT32 msec)                                                = 0;
    128 };
    129 
    130 #define TIOALib_OBJECT_CREATOR_IMP( ClassApi, ClassBase )   \
    131 ClassBase* ClassBase::CreateObject(){ return (ClassBase*) new ClassApi;} \
    132 tiVOID  ClassBase::DeleteObject(ClassBase* pObj){ClassApi* pRealObj = (ClassApi*)pObj; \
    133 if(pRealObj)delete pRealObj; }
    134 
    135 
    136 #define TIOALib_SINGLETON_CLASS_IMP( ClassApi )             \
    137 TI_OAL* TI_OAL::GetInstance()                               \
    138 { return (TI_OAL*) ClassApi::GetInstance(); }               \
    139 TI_OAL* ClassApi::GetInstance()                             \
    140 {if( _instance == 0){_instance = new ClassApi();}           \
    141 m_uReferenceCount++; return _instance;}                     \
    142 tiVOID TI_OAL::FreeInstance()                               \
    143 { ClassApi::FreeInstance(); }                               \
    144 tiVOID ClassApi::FreeInstance()                             \
    145 { m_uReferenceCount--;if(!m_uReferenceCount && _instance )  \
    146 {delete (ClassApi*)_instance;_instance = NULL;}}
    147 
    148 #endif /* !defined(AFX_TIUNILIB_H__F79CA4B8_8596_4F36_B541_2B2FCCF70197__INCLUDED_)*/
    149 
    150