Torque3D Documentation / _generateds / resourceManager.h

resourceManager.h

Engine/source/core/resourceManager.h

More...

Classes:

Detailed Description

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#ifndef _RESOURCEMANAGER_H_
25#define _RESOURCEMANAGER_H_
26
27#ifndef __RESOURCE_H__
28#include "core/resource.h"
29#endif
30
31#ifndef _TDICTIONARY_H_
32#include "core/util/tDictionary.h"
33#endif
34
35class ResourceManager
36{
37public:
38
39   static ResourceManager &get();
40
41   ResourceBase load(const Torque::Path &path);
42   ResourceBase find(const Torque::Path &path);
43
44   ResourceBase startResourceList( ResourceBase::Signature inSignature = U32_MAX );
45   ResourceBase nextResource();
46
47   void reloadResource( const Torque::Path &path, bool showMessage = false );
48
49   typedef Signal<void(const Torque::Path &path)> ChangedSignal;
50
51   /// Registering with this signal will give an opportunity to handle a change to the
52   /// resource on disk.  For example, if a PNG file is edited by the artist and saved
53   /// the ResourceManager will signal that the file has changed so the TextureManager
54   /// may act appropriately - which probably means to re-init the materials using that PNG.
55   /// The signal passes the Resource's signature so the callee may filter these.
56   ChangedSignal &getChangedSignal() { return mChangeSignal; }
57
58#ifdef TORQUE_DEBUG
59   void  dumpToConsole();
60#endif
61
62   ~ResourceManager();
63
64protected:
65
66   friend class ResourceBase::Header;
67
68   ResourceManager();
69
70   bool remove( ResourceBase::Header* header );
71
72   void  notifiedFileChanged( const Torque::Path &path );
73
74   typedef HashTable<String,ResourceBase::Header*> ResourceHeaderMap;
75
76   /// The map of resources.
77   ResourceHeaderMap mResourceHeaderMap;
78
79   /// The map of old resources which have been replaced by
80   /// new resources from a file change notification.
81   ResourceHeaderMap mPrevResourceHeaderMap;
82
83   ResourceHeaderMap::Iterator mIter;
84
85   U32 mIterSigFilter;
86
87   ChangedSignal mChangeSignal;
88};
89
90#endif
91