Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

new_class_id: dynamic loading works completely

try the shell with:
ResourceManger load Texture some-pic-from-data

File size: 2.7 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 loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString);
50
51    void debug() const;
52
53    // utility functions for handling files in and around the data-directory
54    static std::string getFullName(const std::string& fileName);
55    static bool isInDataDir(const std::string& fileName);
56  private:
57    ResourceManager();
58    virtual ~ResourceManager();
59
60  private:
61    static ResourceManager*            _singletonRef;       //!< singleton Reference
62
63    Directory                          _mainGlobalPath;     //!< The main include directory (default at "./")
64    std::vector<Directory>             _globalPaths;        //!< Additional Global include directories.
65
66    std::vector<Resources::Type*>      _resourceTypes;      //!< A Vector of all the stored ResourceTypes @see Resources::Type
67    std::vector<std::string>           _keepLevelNames;     //!< Names of KeepLevels @see Resources::KeepLevel
68  };
69
70}
71
72#endif /* _RESOURCE_MANAGER_H */
Note: See TracBrowser for help on using the repository browser.