![]() |
nomlib
|
Resources management. More...
#include <ResourceCache.hpp>
Public Types | |
| typedef ResourceCache | self_type |
| typedef self_type * | raw_ptr |
| typedef std::unique_ptr< self_type > | unique_ptr |
| typedef std::shared_ptr< self_type > | shared_ptr |
| typedef std::function< void(const ResourceFile &, ResourceType &)> | callback_type |
Public Member Functions | |
| ResourceCache (void) | |
| Default constructor. | |
| ~ResourceCache (void) | |
| Destructor – free all of the stored resources. | |
| nom::size_type | size (void) const |
| Get the total number of stored resources. | |
| const ResourceFile & | find_resource (const std::string &key) const |
| Search the cache for a resource. | |
| void | set_resource_handler (const callback_type &delegate) |
| Set an optional callback to use in creation of the resource before it is inserted into the cache. | |
| bool | append_resource (const ResourceFile &res) |
| Add a file-based resource object. | |
| ResourceType * | load_resource (const std::string &key) |
| Fully initialize a resource. | |
| void | clear (void) |
| Erase all resource elements in the cache. | |
| void | erase (const std::string &key) |
| Destroy a resource. | |
| void | dump (void) |
| Output the stored resource name and file paths. | |
Private Attributes | |
| std::map< ResourceFile, std::shared_ptr< ResourceType > > | resources_ |
| The available resources list. | |
| callback_type | callback_ |
| Optional delegate that is executed upon the creation of a resource. | |
Resources management.
Note that pure abstract object types are not supported. The implementation does not support the external use of object pointers, i.e.: nom::ResourceCache<IFont*>. This is handled internally.
Definition at line 47 of file ResourceCache.hpp.
| typedef std::function<void( const ResourceFile&, ResourceType& )> nom::ResourceCache< ResourceType >::callback_type |
Definition at line 56 of file ResourceCache.hpp.
| typedef self_type* nom::ResourceCache< ResourceType >::raw_ptr |
Definition at line 52 of file ResourceCache.hpp.
| typedef ResourceCache nom::ResourceCache< ResourceType >::self_type |
Definition at line 50 of file ResourceCache.hpp.
| typedef std::shared_ptr<self_type> nom::ResourceCache< ResourceType >::shared_ptr |
Definition at line 54 of file ResourceCache.hpp.
| typedef std::unique_ptr<self_type> nom::ResourceCache< ResourceType >::unique_ptr |
Definition at line 53 of file ResourceCache.hpp.
|
inline |
Default constructor.
Definition at line 59 of file ResourceCache.hpp.
|
inline |
Destructor – free all of the stored resources.
Definition at line 65 of file ResourceCache.hpp.
|
inline |
Add a file-based resource object.
Definition at line 110 of file ResourceCache.hpp.
|
inline |
Erase all resource elements in the cache.
Definition at line 200 of file ResourceCache.hpp.
|
inline |
Output the stored resource name and file paths.
Definition at line 216 of file ResourceCache.hpp.
|
inline |
Destroy a resource.
| key | The resource descriptor (name) to be destroyed. |
Definition at line 208 of file ResourceCache.hpp.
|
inline |
Search the cache for a resource.
| key | The resource name for lookup. |
Definition at line 85 of file ResourceCache.hpp.
|
inline |
Fully initialize a resource.
Definition at line 160 of file ResourceCache.hpp.
|
inline |
Set an optional callback to use in creation of the resource before it is inserted into the cache.
Definition at line 99 of file ResourceCache.hpp.
|
inline |
Get the total number of stored resources.
Definition at line 74 of file ResourceCache.hpp.
|
private |
Optional delegate that is executed upon the creation of a resource.
Definition at line 230 of file ResourceCache.hpp.
|
private |
The available resources list.
Definition at line 226 of file ResourceCache.hpp.