#pragma once #include #include #include using namespace cv; enum SCAN_TASK_TYPE{ SCAN_TASK_TYPE_NORMAL, SCAN_TASK_TYPE_ADJUST_BATCH, SCAN_TASK_TYPE_ADJUST_EXAMINNE, }; enum DATABASE_STATE{ //创建 DATABASE_STATE_CREATE, //扫描中 DATABASE_STATE_SCANNING, //扫描完成 DATABASE_STATE_SCAN_OVER, //放弃 DATABASE_STATE_GIVEUP, //成绩上传中 DATABASE_STATE_RESULT_UPLOADING, //成绩上传完成 DATABASE_STATE_RESULT_UPLOADED, //图片上传中 DATABASE_STATE_IMG_UPLOADING, //图片上传暂停 DATABASE_STATE_IMG_PAUSED, //图片上传完成 DATABASE_STATE_IMG_UPLOADED, //正在删除数据库 DATABASE_STATE_DELETING, //数据库已经删除 DATABASE_STATE_DELETED, //无效状态 DATABASE_STATE_CREATE_INVALID=9999, }; enum ServiceState{ stoped, starting, running, pausing, paused, resuming, stoping }; class IService{ public: IService(void); ~IService(void); // 启动服务 virtual BOOL Start(void); // 停止服务 virtual BOOL Stop(void); // 暂停服务 virtual BOOL Pause(void); // 恢复服务 virtual BOOL Resume(void); // 是否支持暂停 virtual BOOL SupportPause(void); //获取服务当前状态 ServiceState GetServiceSate(void); //运行函数 UINT Run0(); protected: enum command{ command_none, command_start, command_pause, command_resume, command_stop }; command m_command; //服务状态 ServiceState m_serviceState; //状态同步锁 RTL_CRITICAL_SECTION m_state_lock; //在服务状态为oldState时,设置服务状态 inline BOOL SetServiceSate(ServiceState newState,ServiceState oldState); // 服务执行方法 virtual int Run(void); virtual ServiceState OnStarting(void); virtual ServiceState OnRunning(void); virtual ServiceState OnPausing(void); virtual ServiceState OnPaused(void); virtual ServiceState OnResuming(void); virtual ServiceState OnStoping(void); private: //服务线程 CWinThread * m_serviceThread; };