Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB

  1. //====== Copyright � 1996-2008, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef IMATERIALPROXYDICT_H
  7. #define IMATERIALPROXYDICT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. class IMaterialProxy;
  12. typedef IMaterialProxy *MaterialProxyFactory_t();
  13. abstract_class IMaterialProxyDict
  14. {
  15. public:
  16. // This is used to instance a proxy.
  17. virtual IMaterialProxy *CreateProxy( const char *proxyName ) = 0;
  18. // virtual destructor
  19. virtual ~IMaterialProxyDict() {}
  20. // Used by EXPOSE_MATERIAL_PROXY to insert all proxies into the dictionary.
  21. virtual void Add( const char *pMaterialProxyName, MaterialProxyFactory_t *pMaterialProxyFactory ) = 0;
  22. };
  23. extern IMaterialProxyDict &GetMaterialProxyDict();
  24. #define EXPOSE_MATERIAL_PROXY( className, proxyName ) \
  25. static IMaterialProxy *C##className##Factory( void ) \
  26. { \
  27. return static_cast< IMaterialProxy * >( new className ); \
  28. }; \
  29. class C##proxyName##Foo \
  30. { \
  31. public: \
  32. C##proxyName##Foo( void ) \
  33. { \
  34. GetMaterialProxyDict().Add( #proxyName, \
  35. &C##className##Factory ); \
  36. } \
  37. }; \
  38. static C##proxyName##Foo g_C##proxyName##Foo;
  39. #endif // IMATERIALPROXYDICT_H