# script_scanner.hpp

Go to the documentation of this file.

    00001 /* $Id: script_scanner.hpp 24487 2012-08-20 21:01:40Z yexo $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef SCRIPT_SCANNER_HPP
    00013 #define SCRIPT_SCANNER_HPP
    00014
    00015 #include <map>
    00016 #include "../fileio_func.h"
    00017 #include "../core/string_compare_type.hpp"
    00018
    00019 typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList;
    00020
    00022 class ScriptScanner : public FileScanner {
    00023 public:
    00024   ScriptScanner();
    00025   virtual ~ScriptScanner();
    00026
    00027   virtual void Initialize() = 0;
    00028
    00032   class Squirrel *GetEngine() { return this->engine; }
    00033
    00037   const char *GetMainScript() { return this->main_script; }
    00038
    00042   const char *GetTarFile() { return this->tar_file; }
    00043
    00047   const ScriptInfoList *GetInfoList() { return &this->info_list; }
    00048
    00052   const ScriptInfoList *GetUniqueInfoList() { return &this->info_single_list; }
    00053
    00057   void RegisterScript(class ScriptInfo *info);
    00058
    00062   char *GetConsoleList(char *p, const char *last, bool newest_only) const;
    00063
    00070   bool HasScript(const struct ContentInfo *ci, bool md5sum);
    00071
    00078   const char *FindMainScript(const ContentInfo *ci, bool md5sum);
    00079
    00080   /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename);
    00081
    00085   void RescanDir();
    00086
    00087 protected:
    00088   class Squirrel *engine;
    00089   char *main_script;
    00090   char *tar_file;
    00091
    00092   ScriptInfoList info_list;
    00093   ScriptInfoList info_single_list;
    00094
    00099   void Initialize(const char *name);
    00100
    00104   virtual void GetScriptName(ScriptInfo *info, char *name, int len) = 0;
    00105
    00109   virtual const char *GetFileName() const = 0;
    00110
    00114   virtual Subdirectory GetDirectory() const = 0;
    00115
    00119   virtual void RegisterAPI(class Squirrel *engine) = 0;
    00120
    00124   virtual const char *GetScannerName() const = 0;
    00125
    00129   void Reset();
    00130
    00131 };
    00132
    00133 #endif /* SCRIPT_SCANNER_HPP */