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

//! \file disDictionary.h
//! \brief Contains DtDisDictionary class.
//! List that will compose itself from specified .csv file and create an entries list to store
//! or retrieve DIS entries

#pragma once

#ifndef DtUSE_UTILITIES_NAMESPACE

#include <vlutil/vlMachineTypes.h>

#include "entityMapperKey.h"

#include <vlutil/vlString.h>

#include <map>
#include <list>

class DT_DLL_OMTREADER DtDisEntry
{
public:
   DtDisEntry();
   DtDisEntry(const DtString&);
   virtual ~DtDisEntry();

public:
   virtual DtDisEntry* addDisEntry(int iVal, const DtString& sVal);
   virtual DtDisEntry* find(int iVal);

public:
   std::map<int, DtDisEntry*> myEntries;
   DtString       myValue;
};

class DT_DLL_OMTREADER DtDisEntityTypeEntry : public DtEntityMapperKey
{
public:
   DtDisEntityTypeEntry(const DtEntityMapperKey& key) : DtEntityMapperKey(key) {};

   void addString(const DtString& str);
   const std::vector<DtString>& strings() const;

   int& operator[](int i) { return DtEntityMapperKey::operator[](i); };
   const int operator[](int i) const  { return DtEntityMapperKey::operator[](i); };

protected:
   std::vector<DtString> myStrings;
};

class DT_DLL_OMTREADER DtDisDictionary
{
public:
   DtDisDictionary();
   virtual ~DtDisDictionary();

   virtual bool loadFromFile(const DtString& file, bool showProgress = true);

   virtual const std::map<DtEntityMapperKey, DtDisEntityTypeEntry*>& enumerationList() const;
   virtual std::map<DtEntityMapperKey, DtDisEntityTypeEntry*>& enumerationList();
   virtual const DtDisEntry& disEntries() const;
   virtual DtDisEntry& disEntries();

   virtual const DtDisEntityTypeEntry* findEntry(const DtEntityMapperKey& entKey) const;
   virtual DtDisEntityTypeEntry* findEntry(const DtEntityMapperKey& entKey);
   virtual DtString findCountry(int c);

   static std::map<int, DtString>& countries();

protected:
   virtual int countLines(const char*);

protected:
   DtDisEntry                  myDisEntries;
   std::map<DtEntityMapperKey, DtDisEntityTypeEntry*> myEntityKeys;
   static std::map<int, DtString> gCountries;
};

#endif
