Program Listing for File subsystem.hpp
↰ Return to documentation for file (src/tap/control/subsystem.hpp
)
/*
* Copyright (c) 2020-2021 Advanced Robotics at the University of Washington <robomstr@uw.edu>
*
* This file is part of Taproot.
*
* Taproot is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Taproot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Taproot. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef TAPROOT_SUBSYSTEM_HPP_
#define TAPROOT_SUBSYSTEM_HPP_
#include <cstdint>
#include "tap/util_macros.hpp"
namespace tap
{
class Drivers;
namespace control
{
class Command;
class Subsystem
{
public:
Subsystem(Drivers* drivers);
virtual ~Subsystem();
virtual void initialize() {}
void registerAndInitialize();
mockable void setDefaultCommand(Command* defaultCommand);
mockable inline Command* getDefaultCommand() const { return defaultCommand; }
virtual void refresh() {}
virtual void refreshSafeDisconnect() {}
mockable void setTestCommand(Command* testCommand);
mockable inline Command* getTestCommand() const { return testCommand; }
virtual const char* getName() const;
mockable inline int getGlobalIdentifier() const { return globalIdentifier; }
protected:
Drivers* drivers;
private:
Command* defaultCommand;
Command* testCommand;
const int globalIdentifier;
#if defined(PLATFORM_HOSTED) && defined(ENV_UNIT_TESTS)
//> Testing Related Stuff ---
public:
// Define default constructor to allow NiceMocks to call default constructor and actually
// construct :/, because setpoint subsystem inherits virtually from Subsystem *sigh*
Subsystem();
#endif
}; // class Subsystem
} // namespace control
} // namespace tap
#endif // TAPROOT_SUBSYSTEM_HPP_