笔记,简单类的继承
typedef struct event_info
{
std::string event_name;
std::string event_output;
}event_info_t;
class Event
{
public:
Event(){};
virtual ~Event(){};
virtual bool init() = 0;
virtual void input(std::string input) = 0;
virtual void run() = 0;
virtual event_info_t output() = 0;
};
/
typedef struct feed_conveyor
{
int rotate_direction;
float velocity;
std::string package_seq;
}feed_conveyor_t;
class EventIn : public Event
{
public:
EventIn();
~EventIn();
virtual bool init() override;
virtual void input(std::string input) override;
virtual void run() override;
virtual event_info_t output() override;
private:
std::string generate_package();
feed_conveyor_t config_params_;
std::queue<std::string> package_queue_;
std::string current_package_;
std::string new_package_;
};
EventIn::EventIn()
{
}
EventIn::~EventIn()
{
}
bool EventIn::init()
{
return true;
}
std::string EventIn::generate_package()
{
//simulate a input with random package_num
srand((unsigned)time(NULL));
int suffix = rand();
std::string package_result = "package_";
package_result = package_result + std::to_string(suffix);
return package_result;
}
void EventIn::input(std::string input)
{
}
void EventIn::run()
{
sleep(1);
}
event_info_t EventIn::output()
{
event_info_t info;
return info;
}