1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef I_AI_LIBRARY_MANAGER_H
#define I_AI_LIBRARY_MANAGER_H
#include "AIInterfaceLibraryInfo.h"
#include "SkirmishAILibraryInfo.h"
#include <vector>
#include <map>
#include <set>
class AIInterfaceKey;
class SkirmishAIKey;
class CSkirmishAILibrary;
/**
* @brief manages AIs and AI interfaces
* @see CAILibraryManager
*/
class IAILibraryManager {
public:
IAILibraryManager() {}
virtual ~IAILibraryManager() {}
typedef std::set<AIInterfaceKey> T_interfaceSpecs;
typedef std::set<SkirmishAIKey> T_skirmishAIKeys;
virtual const T_interfaceSpecs& GetInterfaceKeys() const = 0;
virtual const T_skirmishAIKeys& GetSkirmishAIKeys() const = 0;
typedef std::map<const AIInterfaceKey, CAIInterfaceLibraryInfo> T_interfaceInfos;
typedef std::map<const SkirmishAIKey, CSkirmishAILibraryInfo> T_skirmishAIInfos;
virtual const T_interfaceInfos& GetInterfaceInfos() const = 0;
virtual const T_skirmishAIInfos& GetSkirmishAIInfos() const = 0;
typedef std::map<const AIInterfaceKey, std::set<std::string> > T_dupInt;
typedef std::map<const SkirmishAIKey, std::set<std::string> >
T_dupSkirm;
/**
* Returns a set of files which contain duplicate AI Interface infos.
* This can be used for issueing warnings.
*/
virtual const T_dupInt& GetDuplicateInterfaceInfos() const = 0;
/**
* Returns a set of files which contain duplicate Skirmish AI infos.
* This can be used for issueing warnings.
*/
virtual const T_dupSkirm& GetDuplicateSkirmishAIInfos() const = 0;
/**
* Returns a resolved aikey
* @see SkirmishAIKey::IsUnspecified()
*/
SkirmishAIKey ResolveSkirmishAIKey(const SkirmishAIKey& skirmishAIKey)
const;
/**
* A Skirmish AI (its library) is only really loaded when it is not yet
* loaded.
*/
virtual const CSkirmishAILibrary* FetchSkirmishAILibrary(
const SkirmishAIKey& skirmishAIKey) = 0;
/**
* A Skirmish AI is only unloaded when ReleaseSkirmishAILibrary() is called
* as many times as GetSkirmishAILibrary() was.
* loading and unloading of the interfaces
* is handled internally/automatically.
*/
virtual void ReleaseSkirmishAILibrary(const SkirmishAIKey& skirmishAIKey) = 0;
/** Guaranteed to not return NULL. */
static IAILibraryManager* GetInstance();
/** Should only be called at end of game/process */
static void Destroy();
static void OutputAIInterfacesInfo();
static void OutputSkirmishAIInfo();
protected:
virtual std::vector<SkirmishAIKey> FittingSkirmishAIKeys(
const SkirmishAIKey& skirmishAIKey) const = 0;
/**
* Compares two version strings.
* Splits the version strings at the '.' signs, and compares the parts.
* If the number of parts do not match, then the string with less parts
* is filled up with '.0' parts at its right, eg:
* version 1: 0.1.2 -> 0.1.2.0
* version 2: 0.1.2.3 -> 0.1.2.3
* The left most part has the highest significance.
* Comparison of the individual parts is done with std::string::compare(),
* which implies for example that letters > numbers.
* examples:
* ("2", "1") -> 1
* ("1", "1") -> 0
* ("1", "2") -> -1
* ("0.1.1", "0.1") -> 1
* ("1.a", "1.9") -> 1
* ("1.a", "1.A") -> 1
*/
static int VersionCompare(
const std::string& version1,
const std::string& version2);
private:
static IAILibraryManager* gAILibraryManager;
};
#define aiLibManager IAILibraryManager::GetInstance()
#endif // I_AI_LIBRARY_MANAGER_H
|