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


//! \file envList.h
//! \ingroup mtl
//! \brief Contains DtEnvList class.

#ifndef envList_H__
#define envList_H__

#if DT_ENV_THREAD_SAFE
#include <vlutil/vlMutex.h>
#endif

#include "envValue.h"
#include <list>

#ifdef DtUSE_UTILITIES_NAMESPACE
namespace DtUSE_UTILITIES_NAMESPACE
{
#endif



//! \brief DtEnvList is a list of DtEnvValue pointers. Which themselves can
//! be any type.
//! \ingroup mtl
class DT_DLL_MTL DtEnvList : public DtEnvValue
{
public:
   friend class DtEnvironment;   

   //! \brief Get the first value in the list.
   virtual DtEnvValueSP first() const;

   //! \brief Get the last value in the list.
   virtual DtEnvValueSP last()  const;

   //! \brief Get the next value after the value passed in.
   //! Returns null if there is no next child.
   //! \Example
   //! 
   //!  for(DtEnvValueSP child = list.first();child;child = child->next(child))
   //!  { ...
   //!  }
   //!
   virtual DtEnvValueSP next(DtEnvValueSP) const;

   //! \brief Check to see if a value is a list.
   static bool isList(const DtEnvValueSP&);

   //! \brief Cast a value to a list.
   //! \retval NULL If object is not a list.
   static DtEnvList* castToList(const DtEnvValueSP& value);

protected:   

   //! CTOR
   explicit DtEnvList(const DtString& value);

   //! Create a deep copy.
   virtual DtEnvValue* clone() const;

   //! Duplicate children in object.
   virtual void cloneChildren(DtEnvList* list) const;

   //! Append a child into the list.
   virtual void append(DtEnvValueSP);

   //! Remove a child from the list.
   virtual void remove(DtEnvValueSP);

   //! The list of values.
   DtEnvValueList myValues;
   
#if DT_ENV_THREAD_SAFE
   //! The mutex to access children in a threadsafe manor.
   mutable DtMutex myChildrenMutex;
#endif
};

#ifdef DtUSE_UTILITIES_NAMESPACE
}
#endif


#endif
