00001 #ifndef _FOOBAR2000_SDK_COMMANDLINE_H_ 00002 #define _FOOBAR2000_SDK_COMMANDLINE_H_ 00003 00004 #include "service.h" 00005 00006 class NOVTABLE commandline_handler : public service_base 00007 { 00008 public: 00009 enum result 00010 { 00011 RESULT_NOT_OURS,//not our command 00012 RESULT_PROCESSED,//command processed 00013 RESULT_PROCESSED_EXPECT_FILES,//command processed, we want to takeover file urls after this command 00014 }; 00015 virtual result on_token(const char * token)=0; 00016 virtual void on_file(const char * url) {};//optional 00017 virtual void on_files_done() {};//optional 00018 virtual bool want_directories() {return false;} 00019 00020 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(commandline_handler); 00021 }; 00022 00023 class commandline_handler_metadb_handle : public commandline_handler//helper 00024 { 00025 protected: 00026 virtual void on_file(const char * url); 00027 virtual bool want_directories() {return true;} 00028 public: 00029 virtual result on_token(const char * token)=0; 00030 virtual void on_files_done() {}; 00031 00032 virtual void on_file(const metadb_handle_ptr & ptr)=0; 00033 }; 00034 00035 /* 00036 00037 how commandline_handler is used: 00038 00039 scenario #1: 00040 creation => on_token() => deletion 00041 scenario #2: 00042 creation => on_token() returning RESULT_PROCESSED_EXPECT_FILES => on_file(), on_file().... => on_files_done() => deletion 00043 */ 00044 00045 template<typename T> 00046 class commandline_handler_factory_t : public service_factory_t<T> {}; 00047 00048 00049 00050 #endif //_FOOBAR2000_SDK_COMMANDLINE_H_
1.5.5