Scanner to help finding scripts. */
| 17 | |
| 18 | /** Scanner to help finding scripts. */ |
| 19 | class ScriptScanner : public FileScanner { |
| 20 | public: |
| 21 | ScriptScanner(); |
| 22 | virtual ~ScriptScanner(); |
| 23 | |
| 24 | virtual void Initialize() = 0; |
| 25 | |
| 26 | /** |
| 27 | * Get the engine of the main squirrel handler (it indexes all available scripts). |
| 28 | */ |
| 29 | class Squirrel *GetEngine() { return this->engine.get(); } |
| 30 | |
| 31 | /** |
| 32 | * Get the current main script the ScanDir is currently tracking. |
| 33 | */ |
| 34 | std::string GetMainScript() { return this->main_script; } |
| 35 | |
| 36 | /** |
| 37 | * Get the current tar file the ScanDir is currently tracking. |
| 38 | */ |
| 39 | std::string GetTarFile() { return this->tar_file; } |
| 40 | |
| 41 | /** |
| 42 | * Get the list of all registered scripts. |
| 43 | */ |
| 44 | const ScriptInfoList *GetInfoList() { return &this->info_list; } |
| 45 | |
| 46 | /** |
| 47 | * Get the list of the latest version of all registered scripts. |
| 48 | */ |
| 49 | const ScriptInfoList *GetUniqueInfoList() { return &this->info_single_list; } |
| 50 | |
| 51 | /** |
| 52 | * Register a ScriptInfo to the scanner. |
| 53 | */ |
| 54 | void RegisterScript(std::unique_ptr<class ScriptInfo> &&info); |
| 55 | |
| 56 | /** |
| 57 | * Get the list of registered scripts to print on the console. |
| 58 | * @param output_iterator The iterator to write the output to. |
| 59 | * @param newest_only Whether to only show the newest scripts. |
| 60 | */ |
| 61 | void GetConsoleList(std::back_insert_iterator<std::string> &output_iterator, bool newest_only) const; |
| 62 | |
| 63 | /** |
| 64 | * Check whether we have a script with the exact characteristics as ci. |
| 65 | * @param ci The characteristics to search on (shortname and md5sum). |
| 66 | * @param md5sum Whether to check the MD5 checksum. |
| 67 | * @return True iff we have a script matching. |
| 68 | */ |
| 69 | bool HasScript(const struct ContentInfo &ci, bool md5sum); |
| 70 | |
| 71 | /** |
| 72 | * Find a script of a #ContentInfo |
| 73 | * @param ci The information to compare to. |
| 74 | * @param md5sum Whether to check the MD5 checksum. |
| 75 | * @return A filename of a file of the content, else \c nullptr. |
| 76 | */ |