FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
OgreLifetime.h
1#pragma once
2#ifdef FH_VISUALIZATION
3
9# include <OgreRoot.h>
10# include <utility>
11# include <vector>
12
13namespace visual
14{
15
29inline bool OgreRootIsAlive()
30{
31 return Ogre::Root::getSingletonPtr() != nullptr;
32}
33
51template<typename ResourcePtr>
52void ParkForShutdown(ResourcePtr& handle)
53{
54 static std::vector<ResourcePtr>* const s_parked = new std::vector<ResourcePtr>();
55 s_parked->push_back(std::move(handle));
56 handle = ResourcePtr();
57}
58
67template<typename ResourcePtr, typename ResourceManager>
68void ReleaseResource(ResourcePtr& handle, ResourceManager* manager)
69{
70 if (!handle) {
71 return;
72 }
73 if (!OgreRootIsAlive() || manager == nullptr) {
74 ParkForShutdown(handle);
75 return;
76 }
77 manager->remove(handle);
78 handle = ResourcePtr();
79}
80
81} // namespace visual
82#endif // FH_VISUALIZATION
Visualization utilities.
Definition EnvironmentSettings.h:15