script_scanner.hpp

Go to the documentation of this file.
00001 /* $Id: script_scanner.hpp 23938 2012-02-12 17:29:58Z smatz $ */
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 
00072   /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename);
00073 
00077   void RescanDir();
00078 
00079 protected:
00080   class Squirrel *engine; 
00081   char *main_script;      
00082   char *tar_file;         
00083 
00084   ScriptInfoList info_list;        
00085   ScriptInfoList info_single_list; 
00086 
00091   void Initialize(const char *name);
00092 
00096   virtual void GetScriptName(ScriptInfo *info, char *name, int len) = 0;
00097 
00101   virtual const char *GetFileName() const = 0;
00102 
00106   virtual Subdirectory GetDirectory() const = 0;
00107 
00111   virtual void RegisterAPI(class Squirrel *engine) = 0;
00112 
00116   virtual const char *GetScannerName() const = 0;
00117 
00121   void Reset();
00122 
00123 };
00124 
00125 #endif /* SCRIPT_SCANNER_HPP */