-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubsystem.h
51 lines (45 loc) · 1.07 KB
/
Subsystem.h
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
47
48
49
50
51
#pragma once
#include <string>
#include <hash_map>
#include <vector>
namespace Spyder
{
typedef enum {M_AUTO, M_DISABLED, M_TELEOP, M_TEST} RunModes;
class Subsystem;
class SubsystemMgr
{
public:
static SubsystemMgr* GetSingleton();
Subsystem* GetSubsystem(const std::string &strName);
std::vector<Subsystem*>& GetSubsystems();
private:
friend class Subsystem;
void RegisterSubsystem(const std::string &strName, Subsystem* ptr);
std::vector<Subsystem*> m_subsystems;
std::hash_map<std::string, Subsystem*> m_nameToSubsys;
};
class Subsystem
{
public:
Subsystem(const std::string &strName);
virtual ~Subsystem() = 0;
inline const std::string& GetName()
{
return m_strName;
}
virtual void Init(RunModes runmode) = 0;
virtual void Periodic(RunModes runmode) = 0;
virtual void RobotInit() = 0;
inline unsigned short GetPeriod()
{
return m_usPeriod;
}
inline void SetPeriod(unsigned short usPeriod)
{
m_usPeriod = usPeriod;
}
private:
std::string m_strName;
unsigned short m_usPeriod;
};
};