Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

resource_manager.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2005 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00029 #ifndef header_resource_manager
00030 #define header_resource_manager
00031 
00032 #include "weakptr.h"
00033 #include <vector>
00034 
00035 class CL_IODevice;
00036 class CL_Resource;
00037 class CL_VirtualDirectory;
00038 class CL_ResourceManager_Impl;
00039 
00040 class CL_ResourceManager
00041 {
00043 public:
00044         //: Construct a resource manager.
00045         CL_ResourceManager();
00046 
00047         ~CL_ResourceManager();
00048 
00050 public:
00051         //: Returns true if a resource exists.
00052         bool resource_exists(const CL_StringA &resource_id) const;
00053 
00054         //: Returns all the resource sections available.
00055         std::vector<CL_StringA> get_section_names() const;
00056 
00057         //: Returns a list of all resources available.
00058         //- <p>The returned resources are in the form "section/subsection/.../resourcename".</p>
00059         std::vector<CL_StringA> get_resource_names() const;
00060 
00061         std::vector<CL_StringA> get_resource_names(const CL_StringA &section) const;
00062 
00063         //:  Returns a list of all resources available matching a given type.
00064         //- <p>The returned resources are in the form "section/subsection/.../resourcename".</p>
00065         std::vector<CL_StringA> get_resource_names_of_type(const CL_StringA &type) const;
00066 
00067         std::vector<CL_StringA> get_resource_names_of_type(
00068                 const CL_StringA &type,
00069                 const CL_StringA &section) const;
00070 
00071         //: Returns CL_Resource representing the given resource.
00072         CL_Resource get_resource(
00073                 const CL_StringA &resource_id,
00074                 bool resolve_alias = true,
00075                 int reserved = 0);
00076 
00077         //: Returns the directory to load resource data from.
00078         CL_VirtualDirectory get_directory() const;
00079 
00081 public:
00082         //: Add resources from an other resource manager.
00083         //- <p>This function only makes the resource manager search other managers, it
00084         //- does not copy the resources into this manager.</p>
00085         void add_resources(const CL_ResourceManager& additional_resources);
00086 
00087         //: Remove resources from an other resource manager.
00088         void remove_resources(const CL_ResourceManager& additional_resources);
00089 
00090         //: Construct a new resource object.
00091         CL_Resource create_resource(const CL_StringA &resource_id, const CL_StringA &type);
00092 
00093         //: Destroy resource object.
00094         void destroy_resource(const CL_StringA &resource_id);
00095 
00096         void destroy_resource(const CL_Resource &resource);
00097 
00098         //: Save resource XML tree to file.
00099         void save(const CL_StringA &filename);
00100 
00101         void save(const CL_StringA &filename, const CL_VirtualDirectory &directory);
00102 
00103         void save(const CL_IODevice *file);
00104 
00105         //: Load resource XML tree from file.
00106         void load(const CL_StringA &filename);
00107 
00108         void load(const CL_StringA &filename, const CL_VirtualDirectory &directory);
00109 
00110         void load(const CL_IODevice *file, const CL_VirtualDirectory &directory);
00111 
00112         //: Set the resource data directory.
00113         void set_directory(const CL_VirtualDirectory &directory);
00114 
00116 private:
00117         CL_ResourceManager(CL_WeakPtr<CL_ResourceManager_Impl> &impl);
00118 
00119         CL_SharedPtr<CL_ResourceManager_Impl> impl;
00120 
00121         friend class CL_Resource;
00122 };
00123 
00124 #endif

Generated on Sat Feb 19 22:51:16 2005 for npcore by  doxygen 1.4.1