diff --git a/src/ayab/main.cpp b/src/ayab/main.cpp index 3da59d96..49b112d3 100644 --- a/src/ayab/main.cpp +++ b/src/ayab/main.cpp @@ -32,28 +32,25 @@ #include "solenoids.h" #include "tester.h" -// Global definitions: references elsewhere must use `extern`. -// Each of the following is a pointer to a singleton class -// containing static methods. -constexpr GlobalBeeper *beeper; -constexpr GlobalCom *com; -constexpr GlobalEncoders *encoders; -constexpr GlobalFsm *fsm; -constexpr GlobalKnitter *knitter; -constexpr GlobalSolenoids *solenoids; -constexpr GlobalTester *tester; - // Initialize static members. // Each singleton class contains a pointer to a static instance // that implements a public interface. When testing, a pointer // to an instance of a mock class can be substituted. -BeeperInterface *GlobalBeeper::m_instance = new Beeper(); -ComInterface *GlobalCom::m_instance = new Com(); -EncodersInterface *GlobalEncoders::m_instance = new Encoders(); -FsmInterface *GlobalFsm::m_instance = new Fsm(); -KnitterInterface *GlobalKnitter::m_instance = new Knitter(); -SolenoidsInterface *GlobalSolenoids::m_instance = new Solenoids(); -TesterInterface *GlobalTester::m_instance = new Tester(); +Beeper _Beeper; +Com _Com; +Encoders _Encoders; +Fsm _Fsm; +Knitter _Knitter; +Solenoids _Solenoids; +Tester _Tester; + +BeeperInterface *GlobalBeeper::m_instance = &_Beeper; +ComInterface *GlobalCom::m_instance = &_Com; +EncodersInterface *GlobalEncoders::m_instance = &_Encoders; +FsmInterface *GlobalFsm::m_instance = &_Fsm; +KnitterInterface *GlobalKnitter::m_instance = &_Knitter; +SolenoidsInterface *GlobalSolenoids::m_instance = &_Solenoids; +TesterInterface *GlobalTester::m_instance = &_Tester; /*! * Setup - do once before going to the main loop.