| 102 | } |
| 103 | |
| 104 | std::shared_ptr<const ResourceLoader> ResourceManager::GetMatchingLoader( const std::string& path ) { |
| 105 | if( path.empty() || ( path == "Default" ) ) { |
| 106 | return std::shared_ptr<const ResourceLoader>(); |
| 107 | } |
| 108 | |
| 109 | // Extract prefix. |
| 110 | auto colon_pos = path.find( ':' ); |
| 111 | std::shared_ptr<const ResourceLoader> loader; |
| 112 | |
| 113 | if( colon_pos != std::string::npos ) { |
| 114 | auto ident = path.substr( 0, colon_pos ); |
| 115 | |
| 116 | auto loader_iter = m_loaders.find( ident ); |
| 117 | |
| 118 | if( loader_iter != m_loaders.end() ) { |
| 119 | loader = loader_iter->second; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | // Use file loader as fallback. |
| 124 | if( !loader ) { |
| 125 | loader = m_loaders["file"]; |
| 126 | } |
| 127 | |
| 128 | return loader; |
| 129 | } |
| 130 | |
| 131 | void ResourceManager::Clear() { |
| 132 | m_loaders.clear(); |