// mdconfiguration.hpp
// SNF MDaemon Plugin: Platform Configuration Module
// Copyright (C) 2007-2008, ARM Research Labs, LLC.

// This module handles the platform specific configuration for the MDaemon
// plugin. The rulebase is passed to the object when constructed. Each call to
// get a parameter from the object causes a quick check to the generation data.
// If the generation is still valid then the data is provided as is. If not then
// the configuration is updated before it is returned. All of this is protected
// by a mutex.

#ifndef included_mdconfiguration_hpp
#define included_mdconfiguration_hpp

#include <windows.h>
#include "../SNF_Service/SNFMulti.hpp"
#include "../SNF_Service/configuration.hpp"
#include "../SNF_Service/threading.hpp"

class MDConfiguration {
  private:

    Mutex MyMutex;                                                              // Protects configuration.
    ConfigurationElement MyCFGReader;                                           // This is how we read our cfg data.

    string& MyConfigurationPath;                                                // Configuration file path.
    snf_RulebaseHandler& MyRulebase;                                            // Rulebase manager at startup.

    volatile int MyGeneration;                                                  // Numeric Generation Tag.
    bool MyMessageIPFuncOn;                                                     // Message IP test on/off switch.
    string MyConfiguratorCommand;                                               // Config editor command string.
    bool MyAppendConfigurationFileOn;                                           // Append config file path to command?

    void updateConfig();                                                        // Update config if needed.

  public:

    MDConfiguration(snf_RulebaseHandler& R, string& C);                         // Default constructor.

    int Generation();                                                           // Numeric generation tag.
    bool MessageIPFuncOn();                                                     // Message IP test on/off switch.
    string ConfiguratorCommand();                                               // Configure function command string.

};

#endif

