/*! * @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 //! 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); 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(); virtual ~Resource(); virtual bool reload(); virtual bool unload(); protected: Resource::Pointer* acquireResource(Resource::Type& resourceType, const std::string& loadString); private: Resource::Pointer* _pointer; //!< Virtual Pointer to the ResourceData. static std::vector _resourceTypes; //! GLOBALS static std::string _mainGlobalPath; static std::vector _globalPaths; }; #endif /* _RESOURCE_H */