35 lines
685 B
C++
35 lines
685 B
C++
#ifndef INTERFACE_H
|
|
#define INTERFACE_H
|
|
|
|
#include "tier0/platform.h"
|
|
|
|
abstract_class IInterface
|
|
{
|
|
public:
|
|
virtual void Init() = 0;
|
|
virtual void Frame() = 0;
|
|
virtual void Deinit() = 0;
|
|
};
|
|
|
|
typedef IInterface*( *InterfaceRegistryFn )( void );
|
|
|
|
class CInterfaceRegistry
|
|
{
|
|
public:
|
|
CInterfaceRegistry( const char *szName, InterfaceRegistryFn pfn );
|
|
};
|
|
|
|
|
|
#define DECLARE_ENGINE_INTERFACE(iface, impl) \
|
|
IInterface *__interface_alloc_##impl() \
|
|
{ \
|
|
return new impl; \
|
|
}; \
|
|
CInterfaceRegistry __interface_##iface##_registry(#iface, __interface_alloc_##impl); \
|
|
I##iface *iface() { \
|
|
static I##iface *pInterface = (I##iface*)__interface_alloc_##impl(); \
|
|
return pInterface; \
|
|
}
|
|
|
|
#endif
|