/*! * @file resource.h * @brief Definition of a Resource. */ #ifndef _RESOURCE_H #define _RESOURCE_H #include "base_object.h" #include "multi_type.h" #include #include #include #include "filesys/directory.h" //! A Resource is an Object, that can be loaded from Disk /** * */ class Resource : virtual public BaseObject { ObjectListDeclaration(Resource); public: class KeepLevel { public: void setKeepLevelName(unsigned int level, const std::string& name); private: std::vector _keepLevelName; }; protected: class Type { public: Type(const ClassID& classID) : _id(-1), _classID(classID) { }; void addExtension(const std::string& extension); void addResourcePath(const std::string& path); void addResourceSubPath(const std::string& subPath); /// Retrieve Functions const ClassID& storedClassID() const { return _classID; }; int id() const { return _id; }; const std::vector& resourcePaths() const { return _resourcePaths; }; const std::vector& resourceSubPaths() const { return _resourceSubPaths; }; const std::vector& storedResources() const { return _storedResources; }; void setID(int id); void addResource(Resource* resource); private: int _id; const ClassID& _classID; std::vector _resourcePaths; std::vector _resourceSubPaths; std::vector _fileExtensions; std::vector _storedResources; }; class Pointer { public: Pointer(const std::string& loadString, const Resource::KeepLevel& keeplevel); const std::string& loadString() const { return _loadString; }; const Resource::KeepLevel& keepLevel() const { return _keepLevel; }; private: std::string _loadString; //!< An identifier, to match when loading a File. Resource::KeepLevel _keepLevel; //!< The Priority of this resource. (can only be increased, so none else will delete this) }; public: Resource(Resource::Type* type); virtual ~Resource(); virtual bool reload() { return false; }; virtual bool unload() { return false; }; std::string locateFile(const std::string& fileName); public: static void setMainGlobalPath(const Directory& directory); static void addGlobalPath(const Directory& directory); protected: Resource::Pointer* acquireResource(const std::string& loadString); void addResource(Resource::Pointer* pointer); private: Resource::Pointer* _pointer; //!< Virtual Pointer to the ResourceData. Resource::Type* _type; //!< Type of the Resource. static std::vector _resourceTypes; //! GLOBALS static Directory _mainGlobalPath; static std::vector _globalPaths; }; #endif /* _RESOURCE_H */