/*! * @file resource.h * @brief Definition of a NewResource. */ #ifndef _RESOURCE_H #define _RESOURCE_H #include "base_object.h" #include #include #include #include "filesys/directory.h" namespace Resources { class KeepLevel { public: KeepLevel(unsigned int keepLevel) { _keepLevel = keepLevel; }; KeepLevel(const std::string& keepLevelName); unsigned int keepLevel() const { return _keepLevel; }; const std::string& name() const; private: unsigned int _keepLevel; }; class StorePointer { public: StorePointer(const std::string& loadString, const Resources::KeepLevel& keeplevel); const std::string& loadString() const { return _loadString; }; const Resources::KeepLevel& keepLevel() const { return _keepLevel; }; private: std::string _loadString; //!< An identifier, to match when loading a File. Resources::KeepLevel _keepLevel; //!< The Priority of this resource. (can only be increased, so none else will delete this) }; class Type { public: Type(const std::string& typeName); ~Type(); bool operator==(const std::string& resourceName) const { return this->_typeName == resourceName; }; void addExtension(const std::string& extension); bool addResourcePath(const std::string& path); bool addResourceSubPath(const std::string& subPath); /// Retrieve Functions const std::string& storedClassName() const { return _typeName; }; 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(Resources::StorePointer* resource); void debug() const; private: int _id; const std::string _typeName; std::vector _resourcePaths; std::vector _resourceSubPaths; std::vector _fileExtensions; std::vector _storedResources; }; //! A NewResource is an Object, that can be loaded from Disk /** * */ class NewResource : virtual public BaseObject { ObjectListDeclaration(NewResource); public: NewResource(Resources::Type* type); virtual ~NewResource(); virtual bool reload() { return false; }; virtual bool unload() { return false; }; std::string locateFile(const std::string& fileName) const; public: protected: Resources::StorePointer* acquireResource(const std::string& loadString); void addResource(Resources::StorePointer* pointer); private: std::string locateFileInSubDir(const Directory& directory, const std::string& fileName) const; private: Resources::StorePointer* _pointer; //!< Virtual Pointer to the ResourceData. Resources::Type* _type; //!< Type of the NewResource. }; } #endif /* _RESOURCE_H */