소스 검색

resource: updated doc/tests

Michele Caini 4 년 전
부모
커밋
e8d85d9269
2개의 변경된 파일10개의 추가작업 그리고 12개의 파일을 삭제
  1. 8 10
      docs/md/resource.md
  2. 2 2
      test/entt/resource/resource.cpp

+ 8 - 10
docs/md/resource.md

@@ -51,14 +51,12 @@ struct my_loader final: entt::resource_loader<my_loader, my_resource> {
 ```
 
 Where `my_resource` is the type of resources it creates.<br/>
-A resource loader must also expose a public const member function named `load`
-that accepts a variable number of arguments and returns a shared pointer to a
-resource.<br/>
-As an example:
+It must also expose a public const member function named `load` that accepts a
+variable number of arguments and returns a resource handle:
 
 ```cpp
 struct my_loader: entt::resource_loader<my_loader, my_resource> {
-    std::shared_ptr<my_resource> load(int value) const {
+    entt::resource_handle<my_resource> load(int value) const {
         // ...
         return std::shared_ptr<my_resource>(new my_resource{ value });
     }
@@ -130,9 +128,9 @@ cache.load<my_loader>(identifier, 0);
 cache.load<my_loader>("another/identifier"_hs, 42);
 ```
 
-The function returns a handle to the resource, whether it already exists or is
-loaded. In case the loader returns an invalid pointer, the handle is invalid as
-well and therefore it can be easily used with an `if` statement:
+The function returns a resource handle, whether it already exists or is loaded.
+In case the loader returns an invalid pointer, the handle is invalid as well and
+therefore it can be easily used with an `if` statement:
 
 ```cpp
 if(entt::resource_handle handle = cache.load<my_loader>("another/identifier"_hs, 42); handle) {
@@ -154,8 +152,8 @@ existing resource if needed:
 auto handle = cache.reload<my_loader>("another/identifier"_hs, 42);
 ```
 
-As above, the function returns a handle to the resource that is invalid in case
-of errors. The `reload` member function is a kind of alias of the following
+As above, the function returns a resource handle that is invalid in case of
+errors. The `reload` member function is a kind of alias of the following
 snippet:
 
 ```cpp

+ 2 - 2
test/entt/resource/resource.cpp

@@ -27,7 +27,7 @@ struct derived_resource: resource {
 
 template<typename Resource>
 struct loader: entt::resource_loader<loader<Resource>, Resource> {
-    std::shared_ptr<Resource> load(int value) const {
+    entt::resource_handle<Resource> load(int value) const {
         auto res = std::shared_ptr<Resource>(new Resource);
         res->value = value;
         return res;
@@ -36,7 +36,7 @@ struct loader: entt::resource_loader<loader<Resource>, Resource> {
 
 template<typename Resource>
 struct broken_loader: entt::resource_loader<broken_loader<Resource>, Resource> {
-    std::shared_ptr<Resource> load(int) const {
+    entt::resource_handle<Resource> load(int) const {
         return nullptr;
     }
 };