|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
-
-
-
-
- #include "mdconfiguration.hpp"
-
- MDConfiguration::MDConfiguration(snf_RulebaseHandler& R, string& C) :
- MyCFGReader("mdaemon"),
- MyGeneration(-1),
- MyMessageIPFuncOn(true),
- MyConfiguratorCommand("start notepad"),
- MyAppendConfigurationFileOn(true),
- MyConfigurationPath(C),
- MyRulebase(R) {
-
-
-
-
- MyCFGReader
- .Element("ip-test")
- .Attribute("on-off", MyMessageIPFuncOn, false)
- .End("ip-test")
- .Element("configurator")
- .Attribute("command", MyConfiguratorCommand, "")
- .Attribute("append-path", MyAppendConfigurationFileOn, true)
- .End("configurator")
- .End("mdaemon");
- }
-
- int MDConfiguration::Generation() {
- return MyGeneration;
- }
-
- bool MDConfiguration::MessageIPFuncOn() {
- ScopeMutex EverybodyFreeze(MyMutex);
- updateConfig();
- return MyMessageIPFuncOn;
- }
-
- string MDConfiguration::ConfiguratorCommand() {
- ScopeMutex EverybodyFreeze(MyMutex);
- updateConfig();
- string ConfiguratorCommandString = "";
- if(0 < MyConfiguratorCommand.length()) {
- ConfiguratorCommandString = MyConfiguratorCommand;
- if(MyAppendConfigurationFileOn) {
- ConfiguratorCommandString.append(" ");
- ConfiguratorCommandString.append(MyConfigurationPath);
- }
- }
- return ConfiguratorCommandString;
- }
-
- void MDConfiguration::updateConfig() {
- if(MyGeneration != MyRulebase.Generation()) {
- try {
- string NewConfiguration = MyRulebase.PlatformConfiguration();
- ConfigurationData MyConfigData(
- NewConfiguration.c_str(), NewConfiguration.length());
- MyCFGReader.initialize();
- MyCFGReader.interpret(MyConfigData);
- MyGeneration = MyRulebase.Generation();
- }
- catch(...) { }
- }
- }
-
-
|