blob: a88dbb2f29560dc42d6cbe18676a51a15131e680 [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6#pragma once
7
8#include "Base.h"
9#include "DriverStation.h"
10#include "simulation/simTime.h"
11#include "simulation/MainNode.h"
12
13#define START_ROBOT_CLASS(_ClassName_) \
14 int main() \
15 { \
16 (new _ClassName_())->StartCompetition(); \
17 return 0; \
18 }
19
20/**
21 * Implement a Robot Program framework.
22 * The RobotBase class is intended to be subclassed by a user creating a robot program.
23 * Overridden Autonomous() and OperatorControl() methods are called at the appropriate time
24 * as the match proceeds. In the current implementation, the Autonomous code will run to
25 * completion before the OperatorControl code could start. In the future the Autonomous code
26 * might be spawned as a task, then killed at the end of the Autonomous period.
27 */
28class RobotBase
29{
30 friend class RobotDeleter;
31public:
32 static RobotBase &getInstance();
33 static void setInstance(RobotBase* robot);
34
35 bool IsEnabled() const;
36 bool IsDisabled() const;
37 bool IsAutonomous() const;
38 bool IsOperatorControl() const;
39 bool IsTest() const;
40 virtual void StartCompetition() = 0;
41
42protected:
43 RobotBase();
44 virtual ~RobotBase() = default;
45
46 RobotBase(const RobotBase&) = delete;
47 RobotBase& operator=(const RobotBase&) = delete;
48
49 DriverStation &m_ds;
50
51private:
52 static RobotBase *m_instance;
53};