1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ 2 3 #ifndef _INTERFACE_H 4 #define _INTERFACE_H 5 6 #include "ExternalAI/Interface/SSkirmishAILibrary.h" 7 #include "SSkirmishAISpecifier.h" 8 #include "CUtils/SharedLibrary.h" 9 10 #include <map> 11 #include <set> 12 #include <vector> 13 #include <string> 14 15 enum LevelOfSupport; 16 struct SStaticGlobalData; 17 18 class CInterface { 19 public: 20 CInterface(int interfaceId, 21 const struct SAIInterfaceCallback* callback); 22 23 // // static properties 24 // LevelOfSupport GetLevelOfSupportFor( 25 // const char* engineVersion, int engineAIInterfaceGeneratedVersion); 26 27 // skirmish AI methods 28 const SSkirmishAILibrary* LoadSkirmishAILibrary( 29 const char* const shortName, 30 const char* const version); 31 int UnloadSkirmishAILibrary( 32 const char* const shortName, 33 const char* const version); 34 int UnloadAllSkirmishAILibraries(); 35 36 private: 37 // these functions actually load and unload the libraries 38 sharedLib_t Load(const SSkirmishAISpecifier& aiKeyHash, SSkirmishAILibrary* ai); 39 sharedLib_t LoadSkirmishAILib(const std::string& libFilePath, 40 SSkirmishAILibrary* ai); 41 42 static void reportInterfaceFunctionError(const std::string& libFileName, 43 const std::string& functionName); 44 static void reportError(const std::string& msg); 45 std::string FindLibFile(const SSkirmishAISpecifier& sAISpecifier); 46 47 bool FitsThisInterface(const std::string& requestedShortName, 48 const std::string& requestedVersion); 49 private: 50 const int interfaceId; 51 const struct SAIInterfaceCallback* callback; 52 53 typedef std::set<SSkirmishAISpecifier, SSkirmishAISpecifier_Comparator> 54 T_skirmishAISpecifiers; 55 // typedef std::map<const SSkirmishAISpecifier, 56 // std::map<std::string, std::string>, 57 // SSkirmishAISpecifier_Comparator> T_skirmishAIInfos; 58 typedef std::map<const SSkirmishAISpecifier, SSkirmishAILibrary*, 59 SSkirmishAISpecifier_Comparator> T_skirmishAIs; 60 typedef std::map<const SSkirmishAISpecifier, sharedLib_t, 61 SSkirmishAISpecifier_Comparator> T_skirmishAILibs; 62 63 T_skirmishAISpecifiers mySkirmishAISpecifiers; 64 // T_skirmishAIInfos mySkirmishAIInfos; 65 T_skirmishAIs myLoadedSkirmishAIs; 66 T_skirmishAILibs myLoadedSkirmishAILibs; 67 }; 68 69 #endif // _INTERFACE_H 70