|
1
|
1 #pragma once
|
|
|
2
|
|
|
3 //! Service for handling commandline arguments passed to foobar2000.exe
|
|
|
4 class NOVTABLE commandline_handler : public service_base
|
|
|
5 {
|
|
|
6 public:
|
|
|
7 enum result
|
|
|
8 {
|
|
|
9 RESULT_NOT_OURS,//not our command
|
|
|
10 RESULT_PROCESSED,//command processed
|
|
|
11 RESULT_PROCESSED_EXPECT_FILES,//command processed, we want to takeover file urls after this command
|
|
|
12 };
|
|
|
13 virtual result on_token(const char * token)=0;
|
|
|
14 virtual void on_file(const char* url) { (void)url; };//optional
|
|
|
15 virtual void on_files_done() {};//optional
|
|
|
16 virtual bool want_directories() {return false;}
|
|
|
17
|
|
|
18 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(commandline_handler);
|
|
|
19 };
|
|
|
20
|
|
|
21 //! Helper automatically turning passed file locations into metadb_handle objects (audio track references)
|
|
|
22 class commandline_handler_metadb_handle : public commandline_handler {
|
|
|
23 protected:
|
|
|
24 void on_file(const char * url) override final;
|
|
|
25 bool want_directories() override {return true;}
|
|
|
26 public:
|
|
|
27 //! Override me
|
|
|
28 virtual result on_token(const char * token) override = 0;
|
|
|
29 //! Override me
|
|
|
30 virtual void on_files_done() override {};
|
|
|
31 //! Override me
|
|
|
32 virtual void on_file(const metadb_handle_ptr & ptr) = 0;
|
|
|
33 };
|
|
|
34
|
|
|
35 /*
|
|
|
36
|
|
|
37 how commandline_handler is used:
|
|
|
38
|
|
|
39 scenario #1:
|
|
|
40 creation => on_token() => deletion
|
|
|
41 scenario #2:
|
|
|
42 creation => on_token() returning RESULT_PROCESSED_EXPECT_FILES => on_file(), on_file().... => on_files_done() => deletion
|
|
|
43 */
|
|
|
44
|
|
|
45 template<typename T>
|
|
|
46 class commandline_handler_factory_t : public service_factory_t<T> {};
|