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

//! \file multiConfigVariable.h
//! \brief Contains the DtMultiConfigVariable class declaration.
//! \ingroup vl

#pragma once

#include "baseConfigVariable.h"
#include "variableGroup.h"
#include "varType.h"

#include <mtl/environment.h>
#include <vlutil/vlExceptions.h>
#include <cmdLine/cmdLine.h>

#include <vector>

template <typename T>
class DtMultiConfigVariable : public DtBaseConfigVariable
{
public:

   //! \breif Var CTOR, using Group pointer.
   DtMultiConfigVariable( DtVariableGroup* group, const DtString& aName,
      const DtString& itemName, const DtString& aDescription = "",
      DtVariableScope aScope = DtBaseConfigVariable::DtScopeBoth,
      bool isRequired = false, const DtString& aShortcut = "" );

   //! \breif Var CTOR, using Group reference.
   DtMultiConfigVariable( DtVariableGroup& group, const DtString& aName,
      const DtString& itemName, const DtString& aDescription = "",
      DtVariableScope aScope = DtBaseConfigVariable::DtScopeBoth,
      bool isRequired = false, const DtString& aShortcut = "" );

   //! \brief Var Copy CTOR, using Group pointer.
   DtMultiConfigVariable( DtVariableGroup* group,
      const DtMultiConfigVariable<T>& orig );

   //! \brief Var Copy CTOR, using Group reference.
   DtMultiConfigVariable( DtVariableGroup& group,
      const DtMultiConfigVariable<T>& orig );

   //! \brief DTOR
   virtual ~DtMultiConfigVariable();

   //! \brief Assignment operator.
   //! Assigns all defining attributes of the variable.
   //! The variable's group that it belongs to remains unchanged.
   DtMultiConfigVariable& operator = ( const DtMultiConfigVariable& other );

   //! \brief Create a command line argument for the native value.
   virtual void getCommandLineArg(DtCmdLine::CmdLine&);

   //! \brief Update the native value from the command line argument.
   virtual void updateFromCommandLineArg();

   //! \brief Get Environment schema type.
   virtual void getEnvironmentSchemaType(DtEnvironment env,TypeSet& usedTypes) const;

   //! \brief Create an Environment Value from the native value.
   virtual DtEnvValueSP getEnvironmentValue(DtEnvironment env);

   //! \brief Update the native value from the Environment Value.
   virtual void updateFromEnvironment(DtEnvironment env);

   //! \brief Get the Var's type.
   virtual DtString type() const;

   //! \brief Get if the var is required.
   virtual bool isRequired() const;

   //! @name Get/Set the variable name.
   //! @{

   virtual const DtString& name() const;
   void setName( const DtString& name );

   //! @}

   //! @name Get/Set the variable value.
   //! @{

   const std::vector<T>& values() const;
   void setValues(const std::vector<T>& aValue);
   void addValue(T aValue);
   void removeValue(T aValue);
   void clearValues();
   //@}

   //! @}

   //! @name Get/Set the variable's shortcut
   //! @{

   const DtString& shortcut() const;
   void setShortcut( const DtString& aShortcut );

   //! @}

protected:

   //! \brief Copy CTOR (not implemented).
   DtMultiConfigVariable( const DtMultiConfigVariable& other );

protected:

   //Internal Type
   typedef typename DtVarType<T>::ArgType ArgType;

   DtString myName;
   DtString myItemName;
   DtString myShortcut;
   bool myRequiredFlag;

   DtVariableGroup* myGroup;

   std::vector<T> myValues;

};

#include "multiConfigVariable.inl"
