Xiaofei Qiu / Command

Command.h

Committer:
Xiaofei
Date:
2015-11-28
Revision:
8:0752270a196e
Parent:
7:3dee2b884e1f
Child:
9:a4334ac1435f

File content as of revision 8:0752270a196e:

#pragma once
#include <cstdint>

/** Command class.
 *  Author Xiaofei Qiu
 */
class Command
{
public:
    Command();
    
    Command(const Command&);
    
    virtual ~Command(){}
    
    /** Uses vitual function for dynamic binding */
    virtual void execute() = 0; 
    
    /** Sets Speed, if is_negative is true, then speed will be negative. otherwaise, speed is posotive */
    void setSpeed(const std::int8_t& sp, const std::int8_t& is_negative = 0);
    
protected:
    float _SPEED;
    
    /** Direction of the motor speed */
    bool  _IS_NEGATIVE;
};

class LedCommand : public Command
{
public:
    LedCommand(){}
    virtual void execute();
};

class TurnLeftCommand : public Command
{
public:
    TurnLeftCommand(){}
    virtual void execute();
};

class TurnRightCommand : public Command
{
public:
    TurnRightCommand(){}
    virtual void execute();
};

class StopCommand : public Command
{
public:
    StopCommand(){}
    virtual void execute();
};