BVB Source Codes

CRYENGINE Show ICryMannequinProceduralClipFactory.h Source code

Return Download CRYENGINE: download ICryMannequinProceduralClipFactory.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __I_PROCEDURAL_CLIP_FACTORY__H__
  4. #define __I_PROCEDURAL_CLIP_FACTORY__H__
  5.  
  6. #include "ICryMannequinDefs.h" // Needed for SCRCRef
  7.  
  8. class IProceduralClip;
  9. DECLARE_SHARED_POINTERS(IProceduralClip);
  10.  
  11. struct IProceduralParams;
  12. DECLARE_SHARED_POINTERS(IProceduralParams);
  13.  
  14. struct SProceduralClipFactoryRegistrationInfo
  15. {
  16.         typedef IProceduralClipPtr (*   CreateProceduralClipFunction)();
  17.         typedef IProceduralParamsPtr (* CreateProceduralParamsFunction)();
  18.  
  19.         SProceduralClipFactoryRegistrationInfo()
  20.                 : pProceduralClipCreator(NULL)
  21.                 , pProceduralParamsCreator(NULL)
  22.         {
  23.         }
  24.  
  25.         SProceduralClipFactoryRegistrationInfo(const CreateProceduralClipFunction& pClipCreator, const CreateProceduralParamsFunction pParamsCreator)
  26.                 : pProceduralClipCreator(pClipCreator)
  27.                 , pProceduralParamsCreator(pParamsCreator)
  28.         {
  29.         }
  30.  
  31.         CreateProceduralClipFunction   pProceduralClipCreator;
  32.         CreateProceduralParamsFunction pProceduralParamsCreator;
  33. };
  34.  
  35. template<typename T>
  36. inline IProceduralClipPtr CreateProceduralClip()
  37. {
  38.         return IProceduralClipPtr(new T());
  39. }
  40.  
  41. template<typename T>
  42. inline IProceduralParamsPtr CreateProceduralParams()
  43. {
  44.         return IProceduralParamsPtr(new T());
  45. }
  46.  
  47. struct IProceduralClipFactory
  48. {
  49.         typedef SCRCRef<0, SCRCRefHash_CRC32> THash;
  50.  
  51.         virtual ~IProceduralClipFactory() {}
  52.  
  53.         virtual const char* FindTypeName(const THash& typeNameHash) const = 0;
  54.  
  55.         virtual size_t      GetRegisteredCount() const = 0;
  56.         virtual THash       GetTypeNameHashByIndex(const size_t index) const = 0;
  57.         virtual const char* GetTypeNameByIndex(const size_t index) const = 0;
  58.  
  59.         template<typename TProceduralClip, typename TProceduralParams>
  60.         inline bool Register(const char* const typeName)
  61.         {
  62.                 SProceduralClipFactoryRegistrationInfo registrationInfo;
  63.                 registrationInfo.pProceduralClipCreator = &::CreateProceduralClip<TProceduralClip>;
  64.                 registrationInfo.pProceduralParamsCreator = &::CreateProceduralParams<TProceduralParams>;
  65.  
  66.                 const bool registerSuccess = Register(typeName, registrationInfo);
  67.                 return registerSuccess;
  68.         }
  69.  
  70.         virtual bool                 Register(const char* const typeName, const SProceduralClipFactoryRegistrationInfo& registrationInfo) = 0;
  71.  
  72.         virtual IProceduralParamsPtr CreateProceduralClipParams(const char* const typeName) const = 0;
  73.         virtual IProceduralParamsPtr CreateProceduralClipParams(const THash& typeNameHash) const = 0;
  74.  
  75.         virtual IProceduralClipPtr   CreateProceduralClip(const char* const typeName) const = 0;
  76.         virtual IProceduralClipPtr   CreateProceduralClip(const THash& typeNameHash) const = 0;
  77. };
  78.  
  79. struct SProceduralClipRegistrationHelperBase
  80. {
  81.         SProceduralClipRegistrationHelperBase(SProceduralClipRegistrationHelperBase** pFirst)
  82.                 : m_pNext(NULL)
  83.         {
  84.                 m_pNext = *pFirst;
  85.                 * pFirst = this;
  86.         }
  87.  
  88.         virtual ~SProceduralClipRegistrationHelperBase() {}
  89.  
  90.         virtual void Register(IProceduralClipFactory& proceduralClipFactory) const = 0;
  91.  
  92.         SProceduralClipRegistrationHelperBase* m_pNext;
  93. };
  94.  
  95. template<typename TClipType>
  96. struct SProceduralClipRegistrationHelper
  97.         : public SProceduralClipRegistrationHelperBase
  98. {
  99.         SProceduralClipRegistrationHelper(SProceduralClipRegistrationHelperBase** pFirst, const char* const name)
  100.                 : SProceduralClipRegistrationHelperBase(pFirst)
  101.                 , m_name(name)
  102.         {
  103.         }
  104.  
  105.         virtual void Register(IProceduralClipFactory& proceduralClipFactory) const
  106.         {
  107.                 typedef typename TClipType::TParamsType TParamsType;
  108.                 proceduralClipFactory.Register<TClipType, TParamsType>(m_name);
  109.         }
  110.  
  111.         const char* m_name;
  112. };
  113.  
  114. inline SProceduralClipRegistrationHelperBase** GetModuleMannequinProceduralClipAutoRegistrationListPtr()
  115. {
  116.         static SProceduralClipRegistrationHelperBase* s_pModuleMannequinProceduralClipAutoRegistrationList = NULL;
  117.         return &s_pModuleMannequinProceduralClipAutoRegistrationList;
  118. }
  119.  
  120. #define REGISTER_PROCEDURAL_CLIP(clipType, name) SProceduralClipRegistrationHelper<clipType> clipType ## _RegistrationHelper(GetModuleMannequinProceduralClipAutoRegistrationListPtr(), name);
  121.  
  122. namespace mannequin
  123. {
  124. inline void RegisterProceduralClips(IProceduralClipFactory& proceduralClipFactory, const SProceduralClipRegistrationHelperBase* const pFirst)
  125. {
  126.         const SProceduralClipRegistrationHelperBase* pCurrent = pFirst;
  127.         while (pCurrent)
  128.         {
  129.                 pCurrent->Register(proceduralClipFactory);
  130.                 pCurrent = pCurrent->m_pNext;
  131.         }
  132. }
  133.  
  134. inline void RegisterProceduralClipsForModule(IProceduralClipFactory& proceduralClipFactory)
  135. {
  136.         SProceduralClipRegistrationHelperBase** ppModuleMannequinProceduralClipAutoRegistrationList = GetModuleMannequinProceduralClipAutoRegistrationListPtr();
  137.         CRY_ASSERT(ppModuleMannequinProceduralClipAutoRegistrationList != NULL);
  138.  
  139.         RegisterProceduralClips(proceduralClipFactory, *ppModuleMannequinProceduralClipAutoRegistrationList);
  140.  
  141.         *ppModuleMannequinProceduralClipAutoRegistrationList = NULL;
  142. }
  143. }
  144.  
  145. #endif
  146.  
downloadICryMannequinProceduralClipFactory.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top