| 474 | // provides the cached functions which use Derive classes methods |
| 475 | template<class Derived, class DefaultType = void*> |
| 476 | class lazy_base { |
| 477 | protected: |
| 478 | // This function is needed because every templated function |
| 479 | // with different args has its own static buffer |
| 480 | LAZY_IMPORTER_FORCEINLINE static void*& _cache() noexcept |
| 481 | { |
| 482 | static void* value = nullptr; |
| 483 | return value; |
| 484 | } |
| 485 | |
| 486 | public: |
| 487 | template<class T = DefaultType> |
| 488 | LAZY_IMPORTER_FORCEINLINE static T safe() noexcept |
| 489 | { |
| 490 | return Derived::template get<T, safe_module_enumerator>(); |
| 491 | } |
| 492 | |
| 493 | template<class T = DefaultType, class Enum = unsafe_module_enumerator> |
| 494 | LAZY_IMPORTER_FORCEINLINE static T cached() noexcept |
| 495 | { |
| 496 | auto& cached = _cache(); |
| 497 | if(!cached) |
| 498 | cached = Derived::template get<void*, Enum>(); |
| 499 | |
| 500 | return (T)(cached); |
| 501 | } |
| 502 | |
| 503 | template<class T = DefaultType> |
| 504 | LAZY_IMPORTER_FORCEINLINE static T safe_cached() noexcept |
| 505 | { |
| 506 | return cached<T, safe_module_enumerator>(); |
| 507 | } |
| 508 | }; |
| 509 | |
| 510 | template<offset_hash_pair OHP> |
| 511 | struct lazy_module : lazy_base<lazy_module<OHP>> { |
nothing calls this directly
no outgoing calls
no test coverage detected