Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/util/resource_manager.h @ 3658

Last change on this file since 3658 was 3658, checked in by bensch, 20 years ago

orxonox/trunk: resource manager working, player uses it.

File size: 2.0 KB
Line 
1/*!
2    \file resource_manager.h
3    \brief The Resource Manager checks if a file/resource is loaded.
4
5    If a file/resource was already loaded the resourceManager will
6    return a void pointer to the desired resource.
7    Otherwise it will instruct the coresponding resource-loader to load,
8    and receive a pointer to it.
9*/
10
11#ifndef _RESOURCE_MANAGER_H
12#define _RESOURCE_MANAGER_H
13
14#include "base_object.h"
15
16// FORWARD DEFINITION \\
17//template<class T> class tList;
18#include "list.h"                //! \todo do this by forward definition (ask Patrick)
19enum ResourceType {OBJ, PRIM, WAV, MP3, OGG, IMAGE};
20
21struct Resource
22{
23  void* pointer;             //!< Pointer to the Resource.
24 
25  char* name;                //!< Name of the Resource.
26  ResourceType type;         //!< ResourceType of this Resource.
27  int count;                 //!< How many times this Resource has been loaded.
28};
29
30
31//! The ResourceManager is a class, that decides if a file/resource should be loaded
32/**
33   If a file/resource was already loaded the resourceManager will
34   return a void pointer to the desired resource.
35   Otherwise it will instruct the corresponding resource-loader to load,
36   and receive the pointer to it.
37
38   It does it by looking, if a desired file has already been loaded.
39*/
40class ResourceManager : public BaseObject
41{
42 public:
43  static ResourceManager* getInstance();
44  virtual ~ResourceManager();
45
46  static bool setDataDir(char* dataDir);
47  static bool addImageDir(char* imageDir);
48  static void* load(const char* fileName);
49  static void* load(const char* fileName, ResourceType type);
50  static bool unload(void* pointer);
51
52 private:
53  ResourceManager();
54  static ResourceManager* singletonRef;
55
56  static tList<Resource>* resourceList;
57  static char* dataDir;
58  static tList<char>* imageDirs;
59
60  static Resource* locateResourceByName(const char* fileName);
61  static Resource* locateResourceByPointer(const void* pointer);
62 
63
64  static bool isDir(const char* directory);
65  static bool isFile(const char* directory); 
66};
67
68#endif /* _RESOURCE_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.