Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.5 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    ///////////////////////
20    //// INSTANZIATION ////
21    /** @returns a Pointer to the only object of this Class */
22    inline static ResourceManager* getInstance() { if (!_singletonRef) _singletonRef = new ResourceManager();  return _singletonRef; };
23    /** @brief deletes the Instance if it exists. */
24    inline static void deleteInstance() { if (_singletonRef) delete _singletonRef; };
25
26    ////////////////////////
27    //// RESOURCE PATHS ////
28    void setMainGlobalPath(const Directory& directory);
29    void addGlobalPath(const Directory& directory);
30
31    bool addResourcePath(const std::string& resourceName, const std::string& pathName);
32    bool addResourceSubPath(const std::string& resourceName, const std::string& pathName);
33    void registerType(Resources::Type* type);
34    void unregisterType(Resources::Type* type);
35
36    /** @returns the main global search Path */
37    const Directory& mainGlobalPath() const { return _mainGlobalPath; };
38    /** @returns all global paths without mainGlobalPath */
39    const std::vector<Directory>& globalPaths() const { return _globalPaths; };
40
41    ////////////////////
42    //// KEEPLEVELS ////
43    unsigned int addKeepLevelName(const std::string& keepLevelName);
44    unsigned int getKeepLevelID(const std::string& keepLevelName) const;
45    const std::string& getKeepLevelName(unsigned int keepLevelID) const;
46    void setDefaultKeepLevel(const KeepLevel& keepLevel) { this->_defaultKeepLevel = keepLevel; };
47    const KeepLevel& defaultKeepLevel() const { return this->_defaultKeepLevel; };
48
49    //////////////////////////
50    //// GENERAL QUERIES ////
51    /** @returns the Types of Resources */
52    const std::vector<Resources::Type*> resourceTypes() const { return _resourceTypes; };
53
54    bool checkFileInMainPath(const File& fileInside);
55    std::string prependAbsoluteMainPath(const std::string& fileName);
56
57    ////////////////////////////////////////
58    //// RESOURCE LOADING AND UNLOADING ////
59    void loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString, const KeepLevel& keepLevel = KeepLevel());
60    void loadFromLoadStringHACK(const std::string& resourceTypeName, const std::string& loadString) { this->loadFromLoadString(resourceTypeName, loadString); };
61
62    void unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel);
63    void unloadAllBelowKeepLevelINT(unsigned int level) { unloadAllBelowKeepLevel(level); };
64
65    ///////////////
66    //// DEBUG ////
67    void debug() const;
68
69  private:
70    ResourceManager();
71    virtual ~ResourceManager();
72
73  private:
74    static ResourceManager*            _singletonRef;       //!< singleton Reference
75
76    Directory                          _mainGlobalPath;     //!< The main include directory (default at "./")
77    std::vector<Directory>             _globalPaths;        //!< Additional Global include directories.
78
79    std::vector<Resources::Type*>      _resourceTypes;      //!< A Vector of all the stored ResourceTypes @see Resources::Type
80
81    std::vector<std::string>           _keepLevelNames;     //!< Names of KeepLevels @see Resources::KeepLevel
82    KeepLevel                          _defaultKeepLevel;   //!< The default KeepLevel.
83  };
84
85}
86
87#endif /* _RESOURCE_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.