dllaccesbridge.h
Upload User: zhongxx05
Upload Date: 2007-06-06
Package Size: 33641k
Code Size: 8k
Category:

Symbian

Development Platform:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. #ifndef _DLLACCESBRIDGE_H_
  36. #define _DLLACCESBRIDGE_H_
  37. /************************************************************************
  38.  *  Defines
  39.  */
  40. #if defined(HELIX_FEATURE_DLLACCESS_CLIENT)
  41. #define DLL_ACCESSBRIDGE_IMPL DLLAccessClient
  42. #define DLL_ACCESSBRIDGE_OPEN(x, y, z) open((x), (y), (z))
  43. #include "dllaccesclient.h"
  44. #else // HELIX_FEATURE_DLLACCESS_CLIENT
  45. #define DLL_ACCESSBRIDGE_IMPL DLLAccess
  46. #define DLL_ACCESSBRIDGE_OPEN(x, y, z) open((x), (y))
  47. #include "dllacces.h"
  48. #endif // HELIX_FEATURE_DLLACCESS_CLIENT
  49. /************************************************************************
  50.  *  Includes
  51.  */
  52. #include "hxcom.h"
  53. class DLLAccessBridge
  54. {
  55. public:
  56.     /////////////////////////////////////////////////////////////
  57.     // Function: 
  58.     //     DLLAccessBridge
  59.     //
  60.     // Parameters:
  61.     //     None
  62.     //
  63.     // Returns:
  64.     //     Nothing
  65.     //
  66.     // Notes:
  67.     //     Default constructor initializes internal structures for
  68.     //     subsequent call to open()
  69.     //
  70.     DLLAccessBridge()
  71.     {
  72. ;
  73.     }
  74.     /////////////////////////////////////////////////////////////
  75.     // Function:
  76.     //     DLLAccessBridge
  77.     //
  78.     // Parameters:
  79.     //     dllName - Name of shared library
  80.     //
  81.     // Returns:
  82.     //     Nothing
  83.     //
  84.     // Notes:
  85.     //     Attempts to load library dllName. If unsuccessful, m_curError
  86.     //     is set to DLLAccess::NO_LOAD and platform specific error
  87.     //     info is stored in m_curStringError.
  88.     //     
  89.     DLLAccessBridge(const char* dllName, 
  90.     UINT16 nLibType = 0, 
  91.     IUnknown* pContext = NULL)
  92.     {
  93. m_Impl.DLL_ACCESSBRIDGE_OPEN(dllName, nLibType, pContext);
  94.     }
  95.     //////////////////////////////////////////////////////////////
  96.     // Function:
  97.     //     ~DLLAccessBridge
  98.     //
  99.     // Paramters:
  100.     //     None
  101.     //
  102.     // Returns:
  103.     //     Nothing
  104.     //
  105.     // Notes:
  106.     //     Unloads library from memory. See 'close' below.
  107.     //
  108.     ~DLLAccessBridge()
  109.     {
  110. ;
  111.     }
  112.     ///////////////////////////////////////////////////////////////
  113.     // Function:
  114.     //     open(const char* dllName)
  115.     //
  116.     // Parameters:
  117.     //     dllName - Name of shared library
  118.     //
  119.     // Returns:
  120.     //     DLLAccess::OK if successful, else DLLAccess::NO_LOAD.
  121.     //     Platform specific error info is stored in m_curStringError.
  122.     //
  123.     // Notes:
  124.     //     
  125.     int open(const char* dllName, 
  126.      UINT16 nLibType = 0, 
  127.      IUnknown* pContext = NULL)
  128.     {
  129. return m_Impl.DLL_ACCESSBRIDGE_OPEN(dllName, nLibType, pContext);
  130.     }
  131.     ///////////////////////////////////////////////////////////////
  132.     // Function:
  133.     //     close()
  134.     //
  135.     // Parameters:
  136.     //     none
  137.     //
  138.     // Returns:
  139.     //     DLLAccess::OK if successful, else DLL_ACCESS::NO_LOAD.
  140.     //
  141.     // Notes:
  142.     //     Shared library usage is typically reference counted by the
  143.     //     OS: the library is actually unloaded when the reference count
  144.     //     reaches zero. Thus this call does not guarantee that the 
  145.     //     library will be removed from memory.
  146.     //
  147.     int close()
  148.     {
  149. return m_Impl.close();
  150.     }
  151.     ///////////////////////////////////////////////////////////////
  152.     // Function:
  153.     //     getSymbol(const char* symName)
  154.     //
  155.     // Parameters:
  156.     //     symName: symbol to retrieve from shared library
  157.     //
  158.     // Returns:
  159.     //     ptr to code in library if successful, else returns NULL
  160.     //     and m_curError is set to DLLAccess::BAD_SYMBOL.
  161.     //
  162.     // Notes:
  163.     //
  164.     void* getSymbol(const char* symName)
  165.     {
  166. return m_Impl.getSymbol(symName);
  167.     }
  168.     ///////////////////////////////////////////////////////////////
  169.     // Function:
  170.     //     getError
  171.     //
  172.     // Parameters:
  173.     //     none
  174.     //
  175.     // Returns:
  176.     //     value of m_curError
  177.     //
  178.     // Notes:
  179.     //     none
  180.     //
  181.     int getError()
  182.     {
  183. return m_Impl.getError();
  184.     }
  185.     ///////////////////////////////////////////////////////////////
  186.     // Function:
  187.     //     getErrorString
  188.     //
  189.     // Parameters:
  190.     //     none
  191.     //
  192.     // Returns:
  193.     //     value of m_curErrorString
  194.     //
  195.     // Notes:
  196.     //     none
  197.     //
  198.     const char* getErrorString() 
  199.     { 
  200. return m_Impl.getErrorString();
  201.     }
  202.     ///////////////////////////////////////////////////////////////
  203.     // Function:
  204.     //     getDLLName
  205.     //
  206.     // Parameters:
  207.     //     none
  208.     //
  209.     // Returns:
  210.     //     value of m_DLLName
  211.     //
  212.     // Notes:
  213.     //     none
  214.     //
  215.     const char* getDLLName()
  216.     {
  217. return m_Impl.getDLLName();
  218.     }
  219.     ///////////////////////////////////////////////////////////////
  220.     // Function:
  221.     //     getVersion
  222.     //
  223.     // Parameters:
  224.     //     none
  225.     //
  226.     // Returns:
  227.     //     value of m_Version
  228.     //
  229.     // Notes:
  230.     //     none
  231.     //
  232.     const char* getVersion() 
  233.     { 
  234. return m_Impl.getVersion();
  235.     }
  236.     void CreateName(const char* short_name, 
  237.     const char* long_name, 
  238.     char* out_buf,
  239.     UINT32& out_buf_len)
  240.     {
  241. m_Impl.CreateName(short_name, 
  242.   long_name, 
  243.   out_buf, 
  244.   out_buf_len);
  245.     }
  246.     // This overloaded version has been added to allow user to specify major and minor
  247.     // version of the DLL name you are trying to create. It will append major and minor version
  248.     // to the name. If you use the other function, then the major and minor versions of pnmisc
  249.     // will be used. See pnmisc.ver in that case.
  250.     void CreateName(const char* short_name, 
  251.     const char* long_name, 
  252.     char* out_buf,
  253.     UINT32& out_buf_len, 
  254.     UINT32 nMajor, 
  255.     UINT32 nMinor)
  256.     {
  257. m_Impl.CreateName(short_name, 
  258.   long_name, 
  259.   out_buf, 
  260.   out_buf_len,
  261.   nMajor,
  262.   nMinor);
  263.     }
  264.     ///////////////////////////////////////////////////////////////
  265.     // Function:
  266.     //     isOpen
  267.     //
  268.     // Parameters:
  269.     //     none
  270.     //
  271.     // Returns:
  272.     //     value of m_isOpen
  273.     //
  274.     // Notes:
  275.     //     none
  276.     //
  277.     BOOL isOpen(void)
  278.     { 
  279. return m_Impl.isOpen(); 
  280.     }
  281.     
  282. private:
  283.     DLL_ACCESSBRIDGE_IMPL m_Impl;
  284. };
  285. #endif // _DLLACCESBRIDGE_H_