00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00031
00032 #pragma once
00033
00034 #include "../api_core.h"
00035 #include "../Resources/resource.h"
00036 #include "../System/weakptr.h"
00037 #include "../IOData/virtual_directory.h"
00038 #include <vector>
00039
00040 class CL_IODevice;
00041 class CL_Resource;
00042 class CL_VirtualDirectory;
00043 class CL_ResourceManager_Impl;
00044
00048 class CL_API_CORE CL_ResourceManager
00049 {
00052 public:
00054 CL_ResourceManager();
00055
00059 CL_ResourceManager(const CL_String &filename);
00060
00065 CL_ResourceManager(const CL_String &filename, CL_VirtualDirectory directory);
00066
00071 CL_ResourceManager(CL_IODevice file, CL_VirtualDirectory directory = CL_VirtualDirectory());
00072
00076 CL_ResourceManager(const CL_ResourceManager &other);
00077
00078 ~CL_ResourceManager();
00079
00083 public:
00085 bool resource_exists(const CL_String &resource_id) const;
00086
00088 std::vector<CL_String> get_section_names() const;
00089
00091
00092 std::vector<CL_String> get_resource_names() const;
00093
00094 std::vector<CL_String> get_resource_names(const CL_String §ion) const;
00095
00097
00098 std::vector<CL_String> get_resource_names_of_type(const CL_String &type) const;
00099
00100 std::vector<CL_String> get_resource_names_of_type(
00101 const CL_String &type,
00102 const CL_String §ion) const;
00103
00105 CL_Resource get_resource(
00106 const CL_String &resource_id,
00107 bool resolve_alias = true,
00108 int reserved = 0);
00109
00111 CL_VirtualDirectory get_directory(const CL_Resource &resource) const;
00112
00114 bool get_boolean_resource(
00115 const CL_String &resource_id,
00116 bool default_value);
00117
00119 int get_integer_resource(
00120 const CL_String &resource_id,
00121 int default_value);
00122
00126 public:
00127 CL_ResourceManager &operator =(const CL_ResourceManager ©);
00128
00129 bool operator ==(const CL_ResourceManager &manager) const;
00130
00132 void set_directory(const CL_VirtualDirectory &directory);
00133
00135
00137 void add_resources(const CL_ResourceManager& additional_resources);
00138
00140 void remove_resources(const CL_ResourceManager& additional_resources);
00141
00143 CL_Resource create_resource(const CL_String &resource_id, const CL_String &type);
00144
00146 void destroy_resource(const CL_String &resource_id);
00147
00149 void save(const CL_String &filename);
00150
00155 void save(const CL_String &filename, CL_VirtualDirectory directory);
00156
00160 void save(CL_IODevice file);
00161
00163 void load(const CL_String &filename);
00164
00169 void load(const CL_String &filename, CL_VirtualDirectory directory);
00170
00175 void load(CL_IODevice file, CL_VirtualDirectory directory = CL_VirtualDirectory());
00176
00180 private:
00181
00185 CL_ResourceManager(CL_WeakPtr<CL_ResourceManager_Impl> &impl);
00186
00187 CL_SharedPtr<CL_ResourceManager_Impl> impl;
00188
00189 friend class CL_Resource;
00191 };
00192