Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/util/loading/resource.h @ 9800

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

namespaces

File size: 3.1 KB
Line 
1/*!
2 * @file resource.h
3 * @brief Definition of a NewResource.
4*/
5
6#ifndef _RESOURCE_H
7#define _RESOURCE_H
8
9#include "base_object.h"
10#include <string>
11#include <vector>
12#include <set>
13
14#include "filesys/directory.h"
15
16namespace Resources
17{
18  class KeepLevel
19  {
20  public:
21    KeepLevel(unsigned int keepLevel) { _keepLevel = keepLevel; };
22    KeepLevel(const std::string& keepLevelName);
23
24    unsigned int keepLevel() const { return _keepLevel; };
25    const std::string& name() const;
26  private:
27    unsigned int                        _keepLevel;
28  };
29
30  class StorePointer
31  {
32  public:
33    StorePointer(const std::string& loadString, const Resources::KeepLevel& keeplevel);
34    const std::string& loadString() const { return _loadString; };
35    const Resources::KeepLevel& keepLevel() const { return _keepLevel; };
36
37  private:
38    std::string                 _loadString;             //!< An identifier, to match when loading a File.
39    Resources::KeepLevel        _keepLevel;              //!< The Priority of this resource. (can only be increased, so none else will delete this)
40  };
41
42  class Type
43  {
44  public:
45    Type(const std::string& typeName);
46    ~Type();
47    bool operator==(const std::string& resourceName) const { return this->_typeName == resourceName; };
48
49    void addExtension(const std::string& extension);
50
51    bool addResourcePath(const std::string& path);
52    bool addResourceSubPath(const std::string& subPath);
53
54    /// Retrieve Functions
55    const std::string& storedClassName() const { return _typeName; };
56    int id() const { return _id; };
57    const std::vector<Directory>& resourcePaths() const { return _resourcePaths; };
58    const std::vector<Directory>& resourceSubPaths() const { return _resourceSubPaths; };
59    const std::vector<Resources::StorePointer*>& storedResources() const { return _storedResources; };
60
61    void setID(int id);
62    void addResource(Resources::StorePointer* resource);
63
64    void debug() const;
65
66  private:
67    int                             _id;
68    const std::string               _typeName;
69    std::vector<Directory>          _resourcePaths;
70    std::vector<Directory>          _resourceSubPaths;
71    std::vector<std::string>        _fileExtensions;
72
73    std::vector<Resources::StorePointer*> _storedResources;
74  };
75
76
77  //! A NewResource is an Object, that can be loaded from Disk
78  /**
79   *
80   */
81  class NewResource : virtual public BaseObject
82  {
83    ObjectListDeclaration(NewResource);
84
85  public:
86    NewResource(Resources::Type* type);
87    virtual ~NewResource();
88
89    virtual bool reload() { return false; };
90    virtual bool unload() { return false; };
91
92    std::string locateFile(const std::string& fileName) const;
93
94
95  public:
96  protected:
97    Resources::StorePointer* acquireResource(const std::string& loadString);
98    void addResource(Resources::StorePointer* pointer);
99
100  private:
101    std::string locateFileInSubDir(const Directory& directory, const std::string& fileName) const;
102
103  private:
104    Resources::StorePointer*       _pointer;                         //!< Virtual Pointer to the ResourceData.
105    Resources::Type*               _type;                            //!< Type of the NewResource.
106  };
107}
108
109#endif /* _RESOURCE_H */
Note: See TracBrowser for help on using the repository browser.