Radium Engine  1.5.20
Loading...
Searching...
No Matches
ShaderConfigFactory.cpp
1#include <Engine/Data/ShaderConfigFactory.hpp>
2
3#include <map>
4
5#include <Core/Utils/Log.hpp>
6
7namespace Ra {
8namespace Engine {
9namespace Data {
10namespace ShaderConfigurationFactory {
11
12using namespace Core::Utils; // log
13
15
17 if ( config.getName().empty() ) {
18 LOG( logWARNING ) << "Empty name in ShaderConfigurationFactory::addConfiguration call. "
19 "Configuration not added";
20 return;
21 }
22
23 auto found = configs.insert( { config.getName(), config } );
24 if ( !found.second ) {
25 LOG( logDEBUG ) << "Configuration " << config.getName()
26 << " already in ShaderConfigurationFactory. "
27 "Configuration not added";
28 return;
29 }
30}
31
32bool removeConfiguration( const std::string& configName ) {
33 auto found = configs.find( configName );
34 if ( found != configs.end() ) {
35 configs.erase( found );
36 return true;
37 }
38 return false;
39}
40
41Core::Utils::optional<ShaderConfiguration> getConfiguration( const std::string& name ) {
42 if ( name.empty() ) {
43 LOG( logWARNING ) << "Empty name in ShaderConfigurationFactory::getConfiguration call.";
44 return {};
45 }
46
47 auto found = configs.find( name );
48 if ( found != configs.end() ) { return found->second; }
49 else { return {}; }
50}
51
52} // namespace ShaderConfigurationFactory
53} // namespace Data
54} // namespace Engine
55} // namespace Ra
T empty(T... args)
void addConfiguration(const ShaderConfiguration &config)
Core::Utils::optional< ShaderConfiguration > getConfiguration(const std::string &name)
bool removeConfiguration(const std::string &configName)
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3