Squashed 'third_party/Phoenix-frc-lib/' content from commit 666d176
Change-Id: Ibaca2fc8ffb1177e786576cc1e4cc9f7a8c98f13
git-subtree-dir: third_party/Phoenix-frc-lib
git-subtree-split: 666d176a08151793044ab74e0005f13d3732ed96
diff --git a/cpp/include/ctre/phoenix/Tasking/ButtonMonitor.h b/cpp/include/ctre/phoenix/Tasking/ButtonMonitor.h
new file mode 100644
index 0000000..2578d35
--- /dev/null
+++ b/cpp/include/ctre/phoenix/Tasking/ButtonMonitor.h
@@ -0,0 +1,49 @@
+#pragma once
+
+#include "ctre/phoenix/Tasking/ILoopable.h"
+#include "ctre/phoenix/Tasking/IProcessable.h"
+#include <functional>
+
+#ifndef CTR_EXCLUDE_WPILIB_CLASSES
+
+/* forward proto's */
+namespace frc {
+ class GenericHID;
+}
+
+namespace ctre {
+namespace phoenix {
+namespace tasking {
+
+class ButtonMonitor: public IProcessable, public ILoopable {
+public:
+
+ class IButtonPressEventHandler {
+ public:
+ virtual ~IButtonPressEventHandler(){}
+ virtual void OnButtonPress(int idx, bool isDown) = 0;
+ };
+
+ ButtonMonitor(frc::GenericHID * controller, int buttonIndex, IButtonPressEventHandler * ButtonPressEventHandler);
+ ButtonMonitor(const ButtonMonitor & rhs);
+ virtual ~ButtonMonitor() { }
+
+ /* IProcessable */
+ virtual void Process();
+
+ /* ILoopable */
+ virtual void OnStart();
+ virtual void OnLoop();
+ virtual bool IsDone();
+ virtual void OnStop();
+
+private:
+ frc::GenericHID * _gameCntrlr;
+ int _btnIdx;
+ IButtonPressEventHandler * _handler;
+ bool _isDown = false;
+};
+}
+}
+}
+#endif // CTR_EXCLUDE_WPILIB_CLASSES
diff --git a/cpp/include/ctre/phoenix/Tasking/ILoopable.h b/cpp/include/ctre/phoenix/Tasking/ILoopable.h
new file mode 100644
index 0000000..db1dd50
--- /dev/null
+++ b/cpp/include/ctre/phoenix/Tasking/ILoopable.h
@@ -0,0 +1,13 @@
+#pragma once
+
+namespace ctre { namespace phoenix { namespace tasking {
+
+class ILoopable{
+public:
+ virtual ~ILoopable(){}
+ virtual void OnStart() = 0;
+ virtual void OnLoop() = 0;
+ virtual bool IsDone() = 0;
+ virtual void OnStop() = 0;
+};
+}}}
diff --git a/cpp/include/ctre/phoenix/Tasking/IProcessable.h b/cpp/include/ctre/phoenix/Tasking/IProcessable.h
new file mode 100644
index 0000000..0e93180
--- /dev/null
+++ b/cpp/include/ctre/phoenix/Tasking/IProcessable.h
@@ -0,0 +1,9 @@
+#pragma once
+namespace ctre { namespace phoenix { namespace tasking{
+
+class IProcessable {
+public:
+ virtual ~IProcessable(){}
+ virtual void Process() = 0;
+};
+}}}
diff --git a/cpp/include/ctre/phoenix/Tasking/Schedulers/ConcurrentScheduler.h b/cpp/include/ctre/phoenix/Tasking/Schedulers/ConcurrentScheduler.h
new file mode 100644
index 0000000..7481d29
--- /dev/null
+++ b/cpp/include/ctre/phoenix/Tasking/Schedulers/ConcurrentScheduler.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <vector>
+#include "ctre/phoenix/Tasking/ILoopable.h"
+#include "ctre/phoenix/Tasking/IProcessable.h"
+
+namespace ctre {
+namespace phoenix {
+namespace tasking {
+namespace schedulers {
+
+class ConcurrentScheduler: public ILoopable, public IProcessable {
+public:
+ std::vector<ILoopable*> _loops;
+ std::vector<bool> _enabs;
+
+ ConcurrentScheduler();
+ virtual ~ConcurrentScheduler();
+ void Add(ILoopable *aLoop, bool enable = true);
+ void RemoveAll();
+ void Start(ILoopable *toStart);
+ void Stop(ILoopable *toStop);
+ void StartAll();
+ void StopAll();
+
+ //IProcessable
+ void Process();
+
+ //ILoopable
+ bool Iterated();
+ void OnStart();
+ void OnLoop();
+ void OnStop();
+ bool IsDone();
+};
+}
+}
+}
+}
diff --git a/cpp/include/ctre/phoenix/Tasking/Schedulers/SequentialScheduler.h b/cpp/include/ctre/phoenix/Tasking/Schedulers/SequentialScheduler.h
new file mode 100644
index 0000000..f550b31
--- /dev/null
+++ b/cpp/include/ctre/phoenix/Tasking/Schedulers/SequentialScheduler.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <vector>
+#include "ctre/phoenix/Tasking/ILoopable.h"
+#include "ctre/phoenix/Tasking/IProcessable.h"
+
+namespace ctre { namespace phoenix { namespace tasking { namespace schedulers {
+
+class SequentialScheduler: public ILoopable, public IProcessable{
+public:
+ bool _running = false;
+ std::vector<ILoopable*> _loops;
+ unsigned int _idx = 0;
+ bool _iterated = false;
+
+ SequentialScheduler();
+ virtual ~SequentialScheduler();
+
+ void Add(ILoopable *aLoop);
+ ILoopable * GetCurrent();
+ void RemoveAll();
+ void Start();
+ void Stop();
+
+ //IProcessable
+ void Process();
+
+ //ILoopable
+ void OnStart();
+ void OnLoop();
+ void OnStop();
+ bool IsDone();
+};
+}}}}