// Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos. // All rights reserved. // Code licensed under the BSD License. // http://www.anki3d.org/LICENSE #pragma once #include #include #include #include namespace anki { // Forward class XmlDocument; /// @addtogroup resource /// @{ /// The base of all resource objects. class ResourceObject { friend class ResourceManager; public: ResourceObject(ResourceManager* manager); virtual ~ResourceObject(); /// @privatesection ResourceManager& getManager() { return *m_manager; } ResourceAllocator getAllocator() const; TempResourceAllocator getTempAllocator() const; Atomic& getRefcount() { return m_refcount; } const Atomic& getRefcount() const { return m_refcount; } CString getFilename() const { ANKI_ASSERT(!m_fname.isEmpty()); return m_fname.toCString(); } anki_internal: void setFilename(const CString& fname) { ANKI_ASSERT(m_fname.isEmpty()); m_fname.create(getAllocator(), fname); } void setUuid(U64 uuid) { ANKI_ASSERT(uuid > 0); m_uuid = uuid; } /// To check if 2 resource pointers are actually the same. U64 getUuid() const { ANKI_ASSERT(m_uuid > 0); return m_uuid; } ANKI_USE_RESULT Error openFile( const ResourceFilename& filename, ResourceFilePtr& file); ANKI_USE_RESULT Error openFileReadAllText( const ResourceFilename& filename, StringAuto& file); ANKI_USE_RESULT Error openFileParseXml( const ResourceFilename& filename, XmlDocument& xml); private: ResourceManager* m_manager; Atomic m_refcount; String m_fname; ///< Unique resource name. U64 m_uuid = 0; }; /// @} } // end namespace anki