Xiaofei Qiu / Command

Command.h

Committer:
Xiaofei
Date:
2015-11-28
Revision:
9:a4334ac1435f
Parent:
8:0752270a196e
Child:
10:6e32b53f04c3

File content as of revision 9:a4334ac1435f:

#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:
    /** Motor speed */
    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();
};