aboutsummaryrefslogtreecommitdiff
path: root/primedev/plugins/interfaces/interface.cpp
blob: 4c006f2c788ee95846d871e4182f8bb2c5ec513b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <string.h>
#include "interface.h"

InterfaceReg* s_pInterfaceRegs;

InterfaceReg::InterfaceReg(InstantiateInterfaceFn fn, const char* pName) : m_pName(pName)
{
	m_CreateFn = fn;
	m_pNext = s_pInterfaceRegs;
	s_pInterfaceRegs = this;
}

void* CreateInterface(const char* pName, InterfaceStatus* pReturnCode)
{
	for (InterfaceReg* pCur = s_pInterfaceRegs; pCur; pCur = pCur->m_pNext)
	{
		if (strcmp(pCur->m_pName, pName) == 0)
		{
			if (pReturnCode)
			{
				*pReturnCode = InterfaceStatus::IFACE_OK;
			}

			NS::log::PLUGINSYS->info("creating interface {}", pName);
			return pCur->m_CreateFn();
		}
	}

	if (pReturnCode)
	{
		*pReturnCode = InterfaceStatus::IFACE_FAILED;
	}

	NS::log::PLUGINSYS->error("could not find interface {}", pName);
	return NULL;
}