smlfctry.cpp
Upload User: dangjiwu
Upload Date: 2013-07-19
Package Size: 42019k
Code Size: 7k
Category:

Symbian

Development Platform:

Visual C++

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Source last modified: $Id: smlfctry.cpp,v 1.6.2.1 2004/07/09 01:58:10 hubbe Exp $
  3.  * 
  4.  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
  5.  * 
  6.  * The contents of this file, and the files included with this file,
  7.  * are subject to the current version of the RealNetworks Public
  8.  * Source License (the "RPSL") available at
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed
  10.  * the file under the current version of the RealNetworks Community
  11.  * Source License (the "RCSL") available at
  12.  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
  13.  * will apply. You may also obtain the license terms directly from
  14.  * RealNetworks.  You may not use this file except in compliance with
  15.  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
  16.  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
  17.  * the rights, obligations and limitations governing use of the
  18.  * contents of the file.
  19.  * 
  20.  * Alternatively, the contents of this file may be used under the
  21.  * terms of the GNU General Public License Version 2 or later (the
  22.  * "GPL") in which case the provisions of the GPL are applicable
  23.  * instead of those above. If you wish to allow use of your version of
  24.  * this file only under the terms of the GPL, and not to allow others
  25.  * to use your version of this file under the terms of either the RPSL
  26.  * or RCSL, indicate your decision by deleting the provisions above
  27.  * and replace them with the notice and other provisions required by
  28.  * the GPL. If you do not delete the provisions above, a recipient may
  29.  * use your version of this file under the terms of any one of the
  30.  * RPSL, the RCSL or the GPL.
  31.  * 
  32.  * This file is part of the Helix DNA Technology. RealNetworks is the
  33.  * developer of the Original Code and owns the copyrights in the
  34.  * portions it created.
  35.  * 
  36.  * This file, and the files included with this file, is distributed
  37.  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
  38.  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
  39.  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
  40.  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
  41.  * ENJOYMENT OR NON-INFRINGEMENT.
  42.  * 
  43.  * Technology Compatibility Kit Test Suite(s) Location:
  44.  *    http://www.helixcommunity.org/content/tck
  45.  * 
  46.  * Contributor(s):
  47.  * 
  48.  * ***** END LICENSE BLOCK ***** */
  49. #include "hxtypes.h"
  50. #include "hxwintyp.h"
  51. #include "hxcom.h"
  52. #include "hxcomm.h"
  53. #include "hxplugn.h"
  54. #include "hxver.h"
  55. #include "ihxpckts.h"
  56. #include "hxrendr.h"
  57. #include "hxcore.h"
  58. #include "hxhyper.h"
  59. #include "hxasm.h"
  60. #include "hxerror.h"
  61. #include "hxvsurf.h"
  62. #include "hxformt.h"
  63. #include "smiltype.h"
  64. #include "hxsm2sm.h"
  65. #include "baseobj.h"
  66. #include "hxstring.h"
  67. #include "baserend.h"
  68. #include "vbasernd.h"
  69. #if defined(HELIX_FEATURE_SMIL2_BRUSH)
  70. #include "brushff.h"
  71. #include "brushrnd.h"
  72. #endif /* #if defined(HELIX_FEATURE_SMIL2_BRUSH) */
  73. // CSmil1DocumentRenderer needs this fof proxying CSmilDocumentRenderer:
  74. #include "hxgroup.h"
  75. #if defined(HELIX_FEATURE_SMIL2)
  76. #include "smlrendr.h"
  77. #endif /* #if defined(HELIX_FEATURE_SMIL2) */
  78. #if defined(HELIX_FEATURE_SMIL1)
  79. #include "sm1rendr.h"
  80. #endif /* #if defined(HELIX_FEATURE_SMIL1) */
  81. #include "smlfctry.h"
  82. #include "hxheap.h"
  83. #ifdef _DEBUG
  84. #undef HX_THIS_FILE
  85. static char HX_THIS_FILE[] = __FILE__;
  86. #endif
  87. HX_RESULT (STDAPICALLTYPE* const CSmilPluginFactory::m_fpCreateInstanceArray[])(IUnknown**) =
  88. {
  89. #if defined(HELIX_FEATURE_SMIL2)
  90.     CSmilRenderer::HXCreateInstance,
  91. #endif /* #if defined(HELIX_FEATURE_SMIL2) */
  92. #if defined(HELIX_FEATURE_SMIL1)
  93.     CSmil1Renderer::HXCreateInstance,
  94. #endif /* #if defined(HELIX_FEATURE_SMIL1) */
  95. #if defined(HELIX_FEATURE_SMIL2_BRUSH)
  96.     CBrushFileFormat::HXCreateInstance,
  97.     CBrushRenderer::HXCreateInstance,
  98. #endif /* #if defined(HELIX_FEATURE_SMIL2_BRUSH) */
  99.     NULL
  100. };
  101. HX_RESULT (STDAPICALLTYPE* const CSmilPluginFactory::m_fpUnloadArray[])(void) =
  102. {
  103. #if defined(HELIX_FEATURE_SMIL2)
  104.     CSmilRenderer::CanUnload2,
  105. #endif /* #if defined(HELIX_FEATURE_SMIL2) */
  106. #if defined(HELIX_FEATURE_SMIL1)
  107.     CSmil1Renderer::CanUnload2,
  108. #endif /* #if defined(HELIX_FEATURE_SMIL1) */
  109. #if defined(HELIX_FEATURE_SMIL2_BRUSH)
  110.     CBrushFileFormat::CanUnload2,
  111.     CBrushRenderer::CanUnload2,
  112. #endif /* #if defined(HELIX_FEATURE_SMIL2_BRUSH) */
  113.     NULL
  114. };
  115. STDAPI ENTRYPOINT(HXCREATEINSTANCE)(IUnknown** ppIUnknown)
  116. {
  117.     HX_RESULT retVal = HXR_FAIL;
  118.     if (ppIUnknown)
  119.     {
  120.         CSmilPluginFactory* pFactory = new CSmilPluginFactory();
  121.         if (pFactory)
  122.         {
  123.             retVal = pFactory->QueryInterface(IID_IUnknown, (void**) ppIUnknown);
  124.         }
  125.     }
  126.     return retVal;
  127. }
  128. STDAPI ENTRYPOINT(CanUnload2)(void)
  129. {
  130.     for(int i=0; CSmilPluginFactory::m_fpUnloadArray[i]; i++)
  131.     {
  132.         if( HXR_OK != (CSmilPluginFactory::m_fpUnloadArray[i])() )
  133.         {
  134.             return HXR_FAIL;
  135.         }
  136.     }
  137.     return HXR_OK;
  138. }
  139. CSmilPluginFactory::CSmilPluginFactory()
  140. {
  141.     m_lRefCount = 0;
  142.     for (m_usNumPlugins = 0; m_fpCreateInstanceArray[m_usNumPlugins]; m_usNumPlugins++);
  143. }
  144. CSmilPluginFactory::~CSmilPluginFactory()
  145. {
  146. }
  147. STDMETHODIMP CSmilPluginFactory::QueryInterface(REFIID riid, void** ppvObj)
  148. {
  149.     HX_RESULT retVal = HXR_OK;
  150.     if (ppvObj)
  151.     {
  152.         // Set default
  153.         *ppvObj = NULL;
  154.         // Check for IID type
  155.         if (IsEqualIID(riid, IID_IUnknown))
  156.         {
  157.             AddRef();
  158.             *ppvObj = (IUnknown*) (IHXPluginFactory*) this;
  159.         }
  160.         else if (IsEqualIID(riid, IID_IHXPluginFactory))
  161.         {
  162.             AddRef();
  163.             *ppvObj = (IHXPluginFactory*) this;
  164.         }
  165.         else
  166.         {
  167.             retVal = HXR_NOINTERFACE;
  168.         }
  169.     }
  170.     else
  171.     {
  172.         retVal = HXR_FAIL;
  173.     }
  174.     return retVal;
  175. }
  176. STDMETHODIMP_(UINT32) CSmilPluginFactory::AddRef()
  177. {
  178.     return InterlockedIncrement(&m_lRefCount);
  179. }
  180. STDMETHODIMP_(UINT32) CSmilPluginFactory::Release()
  181. {
  182.     if (InterlockedDecrement(&m_lRefCount) > 0)
  183.     {
  184.         return m_lRefCount;
  185.     }
  186.     delete this;
  187.     return 0;
  188. }
  189. STDMETHODIMP_(UINT16) CSmilPluginFactory::GetNumPlugins()
  190. {
  191.     return m_usNumPlugins;
  192. }
  193. STDMETHODIMP CSmilPluginFactory::GetPlugin(UINT16 usIndex, IUnknown** ppPlugin)
  194. {
  195.     HX_RESULT retVal = HXR_FAIL;
  196.     if (usIndex < m_usNumPlugins && ppPlugin)
  197.     {
  198.         retVal = m_fpCreateInstanceArray[usIndex](ppPlugin);
  199.     }
  200.     return retVal;
  201. }