Go to the documentation of this file.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
00124 CL_String get_string_resource(
00125 const CL_String &resource_id,
00126 const CL_StringRef &default_value);
00127
00131 public:
00132 CL_ResourceManager &operator =(const CL_ResourceManager ©);
00133
00134 bool operator ==(const CL_ResourceManager &manager) const;
00135
00137 void set_directory(const CL_VirtualDirectory &directory);
00138
00140
00142 void add_resources(const CL_ResourceManager& additional_resources);
00143
00145 void remove_resources(const CL_ResourceManager& additional_resources);
00146
00148 CL_Resource create_resource(const CL_String &resource_id, const CL_String &type);
00149
00151 void destroy_resource(const CL_String &resource_id);
00152
00154 void save(const CL_String &filename);
00155
00160 void save(const CL_String &filename, CL_VirtualDirectory directory);
00161
00165 void save(CL_IODevice file);
00166
00168 void load(const CL_String &filename);
00169
00174 void load(const CL_String &filename, CL_VirtualDirectory directory);
00175
00180 void load(CL_IODevice file, CL_VirtualDirectory directory = CL_VirtualDirectory());
00181
00185 private:
00186
00190 CL_ResourceManager(CL_WeakPtr<CL_ResourceManager_Impl> &impl);
00191
00192 CL_SharedPtr<CL_ResourceManager_Impl> impl;
00193
00194 friend class CL_Resource;
00196 };
00197