/****************************************************************************
 * Copyright (c) 1992-2026 MAK Technologies, Inc
 * All rights reserved.
 ****************************************************************************/

//! \file applicationSettings.h
//! \brief Contains the DtApplicationSettings class declaration.
//! \ingroup mtl

#pragma once

#include <mtl/variableGroup.h>
#include <mtl/envReader.h>

#ifdef DtUSE_UTILITIES_NAMESPACE
namespace DtUSE_UTILITIES_NAMESPACE
{
#endif

class DtString;
class DtBaseVar;
class DtEnvironment;

class DT_DLL_MTL DtApplicationSettings : public DtVariableGroup
{
public:

   DtApplicationSettings( const DtString& applicationName,
      const DtString& appVersion, const DtString& implicitGroupName = "settings" );

   virtual ~DtApplicationSettings();

   //! \brief Copy CTOR
   DtApplicationSettings(const DtApplicationSettings& orig);

   //! \brief Assignment operator
   DtApplicationSettings& operator = (const DtApplicationSettings& other);

   void setChangeOnce( bool flag );
   virtual bool changeOnce() const;

   // not virtual because this is called in other ctors
   void parseCommandLine( int argc, char** argv,
#ifdef _WIN32
      bool pressAnyKey = true );
#else
      bool pressAnyKey = false );
#endif
   virtual bool loadConfigFile( const DtString& filename );

   virtual bool loadMtlFile( const DtString& filename );
   virtual bool loadXmlFile( const DtString& filename );

   // not virtual because this is called in other dtors
   bool saveConfigFile(const DtString& filename, const DtString& schemaName,
      bool generateSchemaFile = false );

   virtual void generateConfigFileSchema( const DtString& filename ) const;
   virtual void generateElements( DtEnvironment worker ) const;
   virtual void addBaseVar( DtBaseConfigVariable* var );

   virtual const DtString& applicationName() const;
   virtual const DtString& applicationVersion() const;

protected:

   virtual bool readFileIntoEnvironment( const DtString& filename,
      DtEnvReader& reader );

protected:

   DtString myAppName;
   DtString myAppVersion;
   DtVariableGroup* myRootGroup;
   bool myChangeOnceFlag;

};

#ifdef DtUSE_UTILITIES_NAMESPACE
}
#endif
