mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 07:26:38 +00:00 
			
		
		
		
	Engine controls lifetime of managers therefore it should own them. Environment is only access provider. This allows to avoid redundant virtual calls and also some functions from managers base classes can be removed if they are used only by Engine.
		
			
				
	
	
		
			33 lines
		
	
	
	
		
			590 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
	
		
			590 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #ifndef OPENMW_COMPONENTS_MISC_NOTNULLPTR_H
 | |
| #define OPENMW_COMPONENTS_MISC_NOTNULLPTR_H
 | |
| 
 | |
| #include <cassert>
 | |
| #include <cstddef>
 | |
| #include <type_traits>
 | |
| 
 | |
| namespace Misc
 | |
| {
 | |
|     template <class T>
 | |
|     class NotNullPtr
 | |
|     {
 | |
|     public:
 | |
|         NotNullPtr(T* value)
 | |
|             : mValue(value)
 | |
|         {
 | |
|             assert(mValue != nullptr);
 | |
|         }
 | |
| 
 | |
|         NotNullPtr(std::nullptr_t) = delete;
 | |
| 
 | |
|         operator T*() const { return mValue; }
 | |
| 
 | |
|         T* operator->() const { return mValue; }
 | |
| 
 | |
|         T& operator*() const { return *mValue; }
 | |
| 
 | |
|     private:
 | |
|         T* mValue;
 | |
|     };
 | |
| }
 | |
| 
 | |
| #endif
 |