Loading [MathJax]/extensions/tex2jax.js
Radium Engine  1.5.26
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ShaderConfigFactory.cpp
1#include <Core/Utils/Log.hpp>
2#include <Core/Utils/StdOptional.hpp>
3#include <Engine/Data/ShaderConfigFactory.hpp>
4#include <Engine/Data/ShaderConfiguration.hpp>
5#include <map>
6#include <ostream>
7#include <string>
8#include <utility>
9
10namespace Ra {
11namespace Engine {
12namespace Data {
13namespace ShaderConfigurationFactory {
14
15using namespace Core::Utils; // log
16
18
20 if ( config.getName().empty() ) {
21 LOG( logWARNING ) << "Empty name in ShaderConfigurationFactory::addConfiguration call. "
22 "Configuration not added";
23 return;
24 }
25
26 auto found = configs.insert( { config.getName(), config } );
27 if ( !found.second ) {
28 LOG( logDEBUG ) << "Configuration " << config.getName()
29 << " already in ShaderConfigurationFactory. "
30 "Configuration not added";
31 return;
32 }
33}
34
35bool removeConfiguration( const std::string& configName ) {
36 auto found = configs.find( configName );
37 if ( found != configs.end() ) {
38 configs.erase( found );
39 return true;
40 }
41 return false;
42}
43
44Core::Utils::optional<ShaderConfiguration> getConfiguration( const std::string& name ) {
45 if ( name.empty() ) {
46 LOG( logWARNING ) << "Empty name in ShaderConfigurationFactory::getConfiguration call.";
47 return {};
48 }
49
50 auto found = configs.find( name );
51 if ( found != configs.end() ) { return found->second; }
52 else { return {}; }
53}
54
55} // namespace ShaderConfigurationFactory
56} // namespace Data
57} // namespace Engine
58} // 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:4