00001 // $Id: rulesystem_8h-source.html,v 1.2 2002/06/20 17:09:51 mkrohn5 Exp $ 00002 00003 // Rule System Header File 00004 // Written by: Marco Krohn 00005 00006 // Copyright (C) 2001 - , Marco Krohn, <marco.krohn@gmx.de> 00007 // 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 1, or (at your option) 00011 // any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 00018 #ifndef __RULESYSTEM_INCLUDED 00019 #define __RULESYSTEM_INCLUDED 00020 00021 #include "common/defs.h" 00022 00023 #include <list> 00024 #include <map> 00025 #include <string> 00026 00027 using namespace std; 00028 00029 class TDataPackageList; 00030 class TFleet; 00031 class TGalaxy; 00032 class TItem; 00033 class TRace; 00034 class TRuleAtom; 00035 class TSystem; 00036 00037 00038 00039 00040 00041 //---------------------------------------- class TRuleSystem ---------------------------------------- 00042 00056 class TRuleSystem 00057 { 00058 public: 00080 typedef struct tError 00081 { 00082 tError() { rule=""; module=""; }; 00083 tError( const tError& err ) { set( err.rule, err.module ); }; 00084 tError( const string& r, const string& m ) { set( r, m ); }; 00085 void set( const string& r, const string& m ) { rule=r; module=m; }; 00087 string rule; 00089 string module; 00090 }; 00091 00102 bool checkDependencies(); 00111 TFleet* createFleet() const; 00120 TItem* createItem( int2 type ) const; 00128 TRace* createRace() const; 00137 TSystem* createSystem() const; 00146 TRuleAtom* fetchRule( const string& ruleName ) const; 00150 const list<TRuleSystem::tError>* getErrorList() const; 00156 string getModule( const string& module ) const; 00160 bool getStatus() const; 00164 static TRuleSystem& instance(); 00173 bool load( TDataPackageList* in ); 00180 void reset(); 00187 bool save( TDataPackageList* out ) const; 00197 bool setModule( const string& module, const string& rule ); 00207 bool setRuleAtom( const string& rule, const string& ruleset ); 00208 00209 protected: 00217 TRuleSystem(); 00218 00219 private: 00221 list<tError> fErrorList; 00223 map<string, string> fModules; 00225 map<string, string> fRules; 00232 bool fVerified; 00233 }; 00234 00235 00236 00237 00238 00239 #endif // __RULESYSTEM_INCLUDED