00001 // ///////////////////////////////////////////////////////////////////////////// 00002 // 00003 // Name: AssetManager.h 00004 // Author: Michael Bartsch (ZCCdark203) 00005 // 00006 // Desc : Declaration of the AssetManager class. 00007 // 00008 // License: Copyright (C) 2009 Michael Bartsch and Contributors 00009 // 00010 // This program is free software: you can redistribute it 00011 // and/or modify it under the terms of the zlib/libpng License. 00012 // See main.cpp for conditions of distribution and use. 00013 // 00014 // ///////////////////////////////////////////////////////////////////////////// 00015 00016 #ifndef __ASSETMANAGAER_H__ 00017 #define __ASSETMANAGAER_H__ 00018 00019 // Include files 00020 #include "../dependencies.h" 00021 #include "AssetGroup.h" 00022 #include "AssetProcessor.h" 00023 00024 #include "../assets/processors.h" 00025 00026 // Forward declarations 00027 class AssetGroup; 00028 class AssetProcessor; 00029 00030 00031 // AssetManager class 00037 class AssetManager : public ReferenceCounted 00038 { 00039 friend class AssetGroup; 00040 00041 public: 00042 00043 // Initialisation and deinitialisation 00045 AssetManager(); 00047 ~AssetManager(); 00048 00050 void init(); 00052 void clear(); 00053 00054 // Reference counting 00057 void grab(); 00060 void drop(); 00061 00062 // Methods 00066 bool addAssetGroup(AssetGroup *group); 00073 AssetGroup* createAssetGroup(const std::string &name, const std::string &dirName, 00074 bool grab = true); 00075 00078 AssetGroup* getAssetGroup(const u32 id); 00081 AssetGroup* getAssetGroup(const std::string &name); 00082 00085 bool registerProcessorFactory(const std::string &name, AssetProcessor* (*f)(AssetGroup*)); 00088 bool unregisterProcessorFactory(const std::string &name); 00090 void unregisterProcessorFactories(); 00091 00093 void removeAssetGroups(); 00097 bool removeAssetGroup(AssetGroup *group); 00101 bool removeAssetGroup(const u32 id); 00105 bool removeAssetGroup(const std::string &name); 00106 00107 private: 00108 00109 // Private methods 00110 void getAssetProcessors(AssetGroup *group, std::vector<AssetProcessor*> &assetProcessors); 00111 00112 // Normal members 00113 std::vector<AssetGroup*> mGroups; 00114 std::map<std::string, AssetProcessor* (*)(AssetGroup*)> mProcessorFactories; 00115 00116 }; 00117 00118 #endif 00119