Shared pointer to resource loader

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
andrecaldas
Halfling
Posts: 55
Joined: Mon May 06, 2024 1:06 am
x 4

Shared pointer to resource loader

Post by andrecaldas »

I am learning about manual mesh creation. And I see that a resource has a pointer to its "loader". In the case of manual mesh, it is recommended that I implement a ManualResourceLoader.

I came across this "note":
"The loader must remain valid for the entire life of the resource, so that if need be it can be called upon to re-load the resource at any time."

And then I thought:

  • Wouldn't it be nice if each resource had a "std::shared_ptr" to its loader? Then I could simply forget about it.

To keep compatibility, creation of new resources could be done using a raw pointer or a shared_ptr. In any case, the raw pointer would be could be kept exactly as it is now, and the shared_ptr would never be used. It would just be stored to make sure the resource does not get destroyed.