#ifndef LICENCE_GENERATOR_H_
#define LICENCE_GENERATOR_H_

#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <wchar.h>
#include <time.h>
#include <map>
#include <stdint.h>
#include "licenceCommon.h"
#include "licenceELC11.h"
#include "licenceELC21.h"
#include "licenceELC31.h"

using namespace std;

 struct InitStructure
  {
    int elcType = 0;
    int licenceType = 0;
    int licenceVersion = 0;
    int licenceIndex = 0;
    int compatibility = 0;
    string licenceFilePath = "";
  };
  
class LicenceGenerator
{

 

public:
  int elcSwitchType;
  string operationErrors = "";
  pugi::xml_document doc;
  bool argumentsCorrect = false;
  ErrorMessage error;
  LicenceELC11 *licence11;
  LicenceELC21 *licence21;
  LicenceELC31 *licence31;

  LicenceGenerator();
  ~LicenceGenerator();
  LicenceGenerator(map<string, string> &arguments);
  // LicenceGenerator(string cid, string csd, string dataFileName, string binaryType);
  LicenceGenerator(string uid, string cid, string csd, string dataFileName);
  LicenceGenerator(int elcType, int licenceType, int licenceVersion, int licenceIndex, int compatibility);
  bool init(int elcType, int licenceType, int licenceVersion, int licenceIndex, int compatibility);
  bool init(InitStructure &initStructure);
  bool initread(int elcType, int licenceType, int licenceVersion, int licenceIndex, int compatibility);
  bool initread(InitStructure &initStructure);
  
  void createLicenceFile();
  void readLicenceFile();

  int getDataPointsCount(int protocolId);
  bool getLicenceInfo(int protocolId, void *returnStructure);
  bool getLicenceItemInfo(int protocolId, void *returnItemStructure);

  LicenceInfoGeneral licenceInfo;

private:
  LicenceIdentification licIdentification;
  LicData licData;
  string configFileName = "";

  void *licence = nullptr;

  bool processInputConfiguration();

  void createLicenceELC1();
  void createLicenceELC2();
  void createLicenceELC3();

  void readLicenceELC1();
  void readLicenceELC2();
  void readLicenceELC3();
};

#endif