Team Fortress 2 Source Code as on 22/4/2020
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.

41 lines
803 B

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include "toolframework/itooldictionary.h"
  3. #include "utlvector.h"
  4. class CToolDictionary : public IToolDictionary
  5. {
  6. public:
  7. virtual int GetToolCount() const
  8. {
  9. return m_Tools.Count();
  10. }
  11. virtual IToolSystem *GetTool( int index )
  12. {
  13. if ( index < 0 || index >= m_Tools.Count() )
  14. {
  15. return NULL;
  16. }
  17. return m_Tools[ index ];
  18. }
  19. public:
  20. void RegisterTool( IToolSystem *tool )
  21. {
  22. m_Tools.AddToTail( tool );
  23. }
  24. private:
  25. CUtlVector< IToolSystem * > m_Tools;
  26. };
  27. static CToolDictionary g_ToolDictionary;
  28. EXPOSE_SINGLE_INTERFACE_GLOBALVAR( IToolDictionary, CToolDictionary, VTOOLDICTIONARY_INTERFACE_VERSION, g_ToolDictionary );
  29. void RegisterTool( IToolSystem *tool )
  30. {
  31. g_ToolDictionary.RegisterTool( tool );
  32. }