implemented config-load command with new config system
authorLogxen <logxen@hotmail.com>
Wed, 20 Jun 2012 01:10:40 +0000 (18:10 -0700)
committerLogxen <logxen@hotmail.com>
Wed, 20 Jun 2012 01:10:40 +0000 (18:10 -0700)
src/modules/utils/configurator/Configurator.cpp

index 748e49b..238ffcd 100644 (file)
@@ -102,5 +102,22 @@ void Configurator::config_set_command( string parameters, StreamOutput* stream )
 }
 
 // Reload config values from the specified ConfigSource
-void Configurator::config_load_command( string parameters, StreamOutput* stream ){}
+void Configurator::config_load_command( string parameters, StreamOutput* stream ){
+    string source = shift_parameter(parameters);
+    if(source == ""){
+        this->kernel->config->config_cache_load();
+        this->kernel->call_event(ON_CONFIG_RELOAD);
+        stream->printf( "Reloaded settings\r\n" );
+    } else {
+        uint16_t source_checksum = get_checksum(source);
+        for(int i=0; i < this->kernel->config->config_sources.size(); i++){
+            if( this->kernel->config->config_sources[i]->is_named(source_checksum) ){
+                this->kernel->config->config_sources[i]->transfer_values_to_cache(this->kernel->config->config_cache);
+                this->kernel->call_event(ON_CONFIG_RELOAD);
+                stream->printf( "Loaded settings from %s\r\n", source.c_str() );
+                break;
+            }
+        }
+    }
+}