CTRE Phoenix C++ 5.33.1
DeviceCatalog.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
4#include "IMotorController.h"
5#include <vector>
6
7namespace ctre {
8namespace phoenix {
9namespace motorcontrol {
10
11/**
12 * Class to keep track of multiple devices
13 */
15public:
16 /**
17 * Add motor controller to catalog
18 * @param motorController motorController to add
19 */
20 void Register(IMotorController *motorController) {
21 _mcs.push_back(motorController);
22 }
23
24 /**
25 * @return count of motor controllers in catalog
26 */
28 return _mcs.size();
29 }
30
31 /**
32 * Get motor controller at index
33 * @param idx index of motor controller in catalog
34 * @return motor controller at specified index
35 */
37 return _mcs[idx];
38 }
39
40 /**
41 * @return static instance of deviceCatalog
42 */
44 if (!_instance)
45 _instance = new DeviceCatalog();
46 return *_instance;
47 }
48private:
49 std::vector<IMotorController*> _mcs;
50
51 static DeviceCatalog * _instance;
52};
53
54}
55} // namespace phoenix
56}
57
Class to keep track of multiple devices.
Definition: DeviceCatalog.h:14
DeviceCatalog & GetInstance()
Definition: DeviceCatalog.h:43
void Register(IMotorController *motorController)
Add motor controller to catalog.
Definition: DeviceCatalog.h:20
size_t MotorControllerCount()
Definition: DeviceCatalog.h:27
IMotorController * Get(int idx)
Get motor controller at index.
Definition: DeviceCatalog.h:36
Interface for motor controllers.
Definition: IMotorController.h:35
namespace ctre
Definition: paramEnum.h:5