Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/util/loading/resource_manager.h @ 9851

Last change on this file since 9851 was 9851, checked in by bensch, 18 years ago

orxonox/new_class_id: Resources now get Loaded and Unloaded correctly by will alone

File size: 2.8 KB
Line 
1/*!
2 * @file resource_manager.h
3 */
4
5#ifndef _RESOURCE_MANAGER_H
6#define _RESOURCE_MANAGER_H
7
8#include "resource.h"
9#include "filesys/file.h"
10#include "filesys/directory.h"
11
12namespace Resources
13{
14
15  class ResourceManager : public BaseObject
16  {
17    ObjectListDeclaration(ResourceManager);
18  public:
19    /** @returns a Pointer to the only object of this Class */
20    inline static ResourceManager* getInstance() { if (!_singletonRef) _singletonRef = new ResourceManager();  return _singletonRef; };
21    /** @brief deletes the Instance if it exists. */
22    inline static void deleteInstance() { if (_singletonRef) delete _singletonRef; };
23
24
25    void setMainGlobalPath(const Directory& directory);
26    void addGlobalPath(const Directory& directory);
27
28    bool addResourcePath(const std::string& resourceName, const std::string& pathName);
29    bool addResourceSubPath(const std::string& resourceName, const std::string& pathName);
30    void registerType(Resources::Type* type);
31    void unregisterType(Resources::Type* type);
32
33    unsigned int addKeepLevelName(const std::string& keepLevelName);
34    unsigned int getKeepLevelID(const std::string& keepLevelName) const;
35    const std::string& getKeepLevelName(unsigned int keepLevelID) const;
36
37    /** @returns the Types of Resources */
38    const std::vector<Resources::Type*> resourceTypes() const { return _resourceTypes; };
39    /** @returns the main global search Path */
40    const Directory& mainGlobalPath() const { return _mainGlobalPath; };
41    /** @returns all global paths without mainGlobalPath */
42    const std::vector<Directory>& globalPaths() const { return _globalPaths; };
43
44
45    bool checkFileInMainPath(const File& fileInside);
46    std::string prependAbsoluteMainPath(const std::string& fileName);
47
48    void unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel);
49    void unloadAllBelowKeepLevelINT(unsigned int level) { unloadAllBelowKeepLevel(level); };
50    void loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString);
51
52    void debug() const;
53
54    // utility functions for handling files in and around the data-directory
55    static std::string getFullName(const std::string& fileName);
56    static bool isInDataDir(const std::string& fileName);
57  private:
58    ResourceManager();
59    virtual ~ResourceManager();
60
61  private:
62    static ResourceManager*            _singletonRef;       //!< singleton Reference
63
64    Directory                          _mainGlobalPath;     //!< The main include directory (default at "./")
65    std::vector<Directory>             _globalPaths;        //!< Additional Global include directories.
66
67    std::vector<Resources::Type*>      _resourceTypes;      //!< A Vector of all the stored ResourceTypes @see Resources::Type
68    std::vector<std::string>           _keepLevelNames;     //!< Names of KeepLevels @see Resources::KeepLevel
69  };
70
71}
72
73#endif /* _RESOURCE_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.