aboutsummaryrefslogtreecommitdiff
path: root/sp/src/public/toolframework/toolframework.cpp
blob: 8d0db6e9a0a7237c5d04d273d7d75511168f64fd (plain) (blame)
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
37
38
39
40
41
//========= Copyright Valve Corporation, All rights reserved. ============//
#include "toolframework/itooldictionary.h"
#include "utlvector.h"

class CToolDictionary : public IToolDictionary
{
public:
	virtual int	GetToolCount() const
	{
		return m_Tools.Count();
	}

	virtual IToolSystem	*GetTool( int index )
	{
		if ( index < 0 || index >= m_Tools.Count() )
		{
			return NULL;
		}
		return m_Tools[ index ];
	}

public:

	void RegisterTool( IToolSystem *tool )
	{
		m_Tools.AddToTail( tool );
	}
private:

	CUtlVector< IToolSystem	* >	m_Tools;
};

static CToolDictionary g_ToolDictionary;

EXPOSE_SINGLE_INTERFACE_GLOBALVAR( IToolDictionary, CToolDictionary, VTOOLDICTIONARY_INTERFACE_VERSION, g_ToolDictionary );

void RegisterTool( IToolSystem *tool )
{
	g_ToolDictionary.RegisterTool( tool );
}