| 106 | |
| 107 | template <typename FetchPtrs> |
| 108 | bool initLibrary(LibraryPtr& libPtr, std::string const& libName, FetchPtrs fetchFunc) |
| 109 | { |
| 110 | if (libPtr != nullptr) |
| 111 | { |
| 112 | return true; |
| 113 | } |
| 114 | try |
| 115 | { |
| 116 | libPtr.reset(new DynamicLibrary{libName}); |
| 117 | fetchFunc(libPtr.get()); |
| 118 | } |
| 119 | catch (std::exception const& e) |
| 120 | { |
| 121 | libPtr.reset(); |
| 122 | sample::gLogError << "Could not load library " << libName << ": " << e.what() << std::endl; |
| 123 | return false; |
| 124 | } |
| 125 | catch (...) |
| 126 | { |
| 127 | libPtr.reset(); |
| 128 | sample::gLogError << "Could not load library " << libName << std::endl; |
| 129 | return false; |
| 130 | } |
| 131 | |
| 132 | return true; |
| 133 | } |
| 134 | #endif // !TRT_STATIC |
| 135 | |
| 136 | bool initNvinfer() |
no test coverage detected