Loading [MathJax]/extensions/TeX/AMSsymbols.js
Radium Engine  1.5.27
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MaterialConverters.cpp
1#include <Core/Utils/Log.hpp>
2#include <Engine/Data/MaterialConverters.hpp>
3#include <cstddef>
4#include <functional>
5#include <map>
6#include <ostream>
7#include <string>
8#include <utility>
9
13
14namespace Ra {
15namespace Engine {
16namespace Data {
17using namespace Core::Utils; // log
18
22
23namespace EngineMaterialConverters {
27
29 auto result = MaterialConverterRegistry.insert( { name, converter } );
30 return result.second;
31}
32
34 std::size_t removed = MaterialConverterRegistry.erase( name );
35 return ( removed == 1 );
36}
37
39 auto search = MaterialConverterRegistry.find( name );
40 if ( search != MaterialConverterRegistry.end() ) { return { true, search->second }; }
41 auto result = std::make_pair( false, [name]( AssetMaterialPtr ) -> RadiumMaterialPtr {
42 LOG( logERROR ) << "Required material converter " << name << " not found!";
43 return nullptr;
44 } );
45 return result;
46}
47
48bool cleanup() {
50 return true;
51}
52
53} // namespace EngineMaterialConverters
54} // namespace Data
55} // namespace Engine
56} // namespace Ra
represent material data loaded by a file loader. Material data must be identified by a unique name....
Base class for materials.
Definition Material.hpp:24
T make_pair(T... args)
bool removeMaterialConverter(const std::string &name)
bool registerMaterialConverter(const std::string &name, ConverterFunction converter)
std::pair< bool, ConverterFunction > getMaterialConverter(const std::string &name)
static std::map< std::string, std::function< RadiumMaterialPtr(AssetMaterialPtr)> > MaterialConverterRegistry
Map that stores each conversion function.
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:4