Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# deResourceManager.hpp

Go to the documentation of this file.

    00001 ///////////////////////////////////////////////////////////////////////////////
    00002 /// @file deResourceManager.hpp
    00003 ///
    00004 /// @brief Global resource handler
    00005 ///
    00006 /// @author Assassin
    00007 ///
    00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
    00009 /// contents of this file is subject to the Destiny3D Member License which
    00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
    00011 ///
    00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
    00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
    00014 /// for any particular purpose.
    00015 ///
    00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
    00017 ///
    00018 /// <hr>
    00019 ///                                 Change History
    00020 /// <hr>
    00021 ///
    00022 /// @date Aug 2001
    00023 /// @author Assassin
    00024 /// @remarks Creation
    00025 ///
    00026 /// @date Feb 2002
    00027 /// @author Hootie
    00028 /// @remarks Level 2 Singleton DLL Wrap
    00029 ///
    00030 ///////////////////////////////////////////////////////////////////////////////
    00031
    00032 #ifndef DERESOURCEMANAGER_HPP
    00033 #define DERESOURCEMANAGER_HPP
    00034
    00035
    00036 //=================================================================================
    00037 // Includes
    00038 //=================================================================================
    00039
    00040 #include "deResource.hpp"
    00041 #include "deHash.hpp"
    00042 #include "deThread.hpp"
    00043
    00044
    00045
    00046 //=================================================================================
    00047 // deResourceManager Class
    00048 //
    00049 // Resource Manager
    00050 //=================================================================================
    00051
    00052 class deResourceManager : public IdeResourceManager
    00053 {
    00054 public:
    00055    deResourceManager(void);
    00056    ~deResourceManager(void);
    00057
    00058    long GetUniqueInterfaceID() { ++m_UniqueTypes; return m_UniqueTypes; }
    00059    deBoolean RegisterResourceType(const char *extension, deResourceMakerCB maker);
    00060    IdeResourceBase* GetResource(const char *filename, IdeFileSystem *filesystem, deBoolean DoLoad);
    00061    IdeResourceBase* GetResourceThreaded(const char *filename, IdeFileSystem *filesystem, deBoolean DoLoad);
    00062    IdeResourceBase* GetResourceFromFile(IdeFile* file, const char* filename, deBoolean record);
    00063    IdeResourceBase* GetResourceFromFileThreaded(IdeFile* file, const char* filename, deBoolean record);
    00064    deBoolean RemoveResource(IdeResourceBase * rsc);
    00065    deBoolean RemoveAllResources(void);
    00066
    00067 private:
    00068    deBoolean AddResource(char *extension, IdeResourceBase *ClassPtr);
    00069    void ParseExtension(char *filename, char buffer[]);
    00070    IdeFile* LoadFile(const char * filename, IdeFileSystem* BaseFS, deBoolean Read, deBoolean Write);
    00071
    00072    struct deResource
    00073    {
    00074       IdeResourceBase *ClassPtr;
    00075       char extension[24];
    00076    };
    00077
    00078    deTHashString <deResourceMakerCB>  m_RegisteredTypes;
    00079    deTHashString <deTHashString <deResource>*>  m_Resources;
    00080    long m_UniqueTypes;
    00081
    00082    // threaded load-handler
    00083    struct LoadingResource_t
    00084    {
    00085        deBoolean ready;
    00086        deBoolean failed;
    00087        IdeResourceBase* rsc;
    00088    };
    00089    struct LoadingResourceParams_t
    00090    {
    00091        deResourceManager* manager;
    00092        deResourceMakerCB maker;
    00093        IdeFile* loadfile;
    00094        char filename[256];
    00095    };
    00096    IdeThreadLock* m_GlobalLockObj;
    00097    IdeThreadLock* m_LoadLockObj;
    00098    deTHashString <LoadingResource_t> m_LoadingResources;
    00099    static u32 ThreadedLoadHandler(void* param);
    00100    void ChangeThreadedResourceStatus(LoadingResourceParams_t* params, LoadingResource_t* rsc);
    00101 };
    00102
    00103
    00104 #endif  // End DERESOURCEMANAGER_HPP
    00105
    00106