PlayerTaskServiceProtocol.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef __PLAYER_TASK_SERVICE_PROTOCOL_H
  2. #define __PLAYER_TASK_SERVICE_PROTOCOL_H
  3. #include <string>
  4. #include "cocos2d.h"
  5. #include "PlayerMacros.h"
  6. #include "PlayerServiceProtocol.h"
  7. PLAYER_NS_BEGIN
  8. class PlayerTask : public cocos2d::Ref
  9. {
  10. public:
  11. static const int STATE_IDLE = 0;
  12. static const int STATE_RUNNING = 1;
  13. static const int STATE_COMPLETED = 2;
  14. virtual ~PlayerTask() {};
  15. std::string getName() const;
  16. std::string getExecutePath() const;
  17. std::string getCommandLineArguments() const;
  18. std::string getOutput() const;
  19. int getState() const;
  20. bool isIdle() const;
  21. bool isRunning() const;
  22. bool isCompleted() const;
  23. float getLifetime() const;
  24. int getResultCode() const;
  25. virtual bool run() = 0;
  26. virtual void stop() = 0;
  27. virtual void runInTerminal() = 0;
  28. protected:
  29. PlayerTask(const std::string &name,
  30. const std::string &executePath,
  31. const std::string &commandLineArguments);
  32. std::string _name;
  33. std::string _executePath;
  34. std::string _commandLineArguments;
  35. std::string _output;
  36. float _lifetime;
  37. int _state;
  38. int _resultCode;
  39. };
  40. class PlayerTaskServiceProtocol : public PlayerServiceProtocol
  41. {
  42. public:
  43. virtual PlayerTask *createTask(const std::string &name,
  44. const std::string &executePath,
  45. const std::string &commandLineArguments) = 0;
  46. virtual PlayerTask *getTask(const std::string &name) = 0;
  47. virtual void removeTask(const std::string &name) = 0;
  48. };
  49. PLAYER_NS_END
  50. #endif // __PLAYER_TASK_SERVICE_PROTOCOL_H