summaryrefslogtreecommitdiffstats
path: root/source/Concept/Framework/robot.h
blob: 543f1ed24df9bdac4be8a864b5418b46b080d84a (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
37
38
39
40
41
42
43
44
45
46
#ifndef _ROBOT_H
#define _ROBOT_H

#include "stdafx.h"

class IO_Module;
class Sensor;
class Engine;

class Robot
{
public:
	~Robot();

private:
	typedef hash_map<uint32, IO_Module*> moduleMap;
	moduleMap modules;

public:
	bool AddModule(IO_Module* newModule);

	template <class T> T* GetModule(uint32 moduleId)
	{
		moduleMap::const_iterator itr = modules.find(moduleId);
		if(itr == modules.end())
			return NULL;
		else
			return ((T*)itr->second);
	}

	bool RemoveModule(uint32 moduleId)
	{
		moduleMap::iterator itr = modules.find(moduleId);
		if(itr == modules.end())
			return false;
			
		modules.erase(itr);
		return true;
	}

	bool RemoveModule(IO_Module* oldModule);

	void Update();
};

#endif