#ifndef _PINMUX_CONSTRUCTOR_H_
#define _PINMUX_CONSTRUCTOR_H_
//----------------------------------------------------------------------------
///
/// \file   constructor.h
///
/// \brief  See implementation for further details
///
/// \date   20190313
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//----------------------------------------------------------------------------


//---Documentation------------------------------------------------------------


//---Includes -----------------------------------------------------------------


//---General--------------------------

#include <QString>
#include <QList>
#include <QJsonArray>
#include <QJsonObject>

//---Own------------------------------

#include "periphery.h"
#include "path.h"
#include "peripheryHelper.h"
#include <jsonObject.h>


//---Declaration --------------------------------------------------------------

class CConstructor;

class CConstructorPool: public CPath
{
private:
   QList<CConstructor> constructorList;
   QStringList m_loadedFiles;
   QString m_frameWork;

public:
   void addConstructor(const CConstructor &constructor)
   {
      constructorList << constructor;
   }
   const CConstructor *getConstructor(CPeripheryConstPtr periphery) const;

   bool loadFile(const QString &fileName);
   bool loadByteArray(const QByteArray &array, const QString &fileName);
   int parseJson(const QJsonObject &jsonObject, QStringList &includes);
   int count()
   {
      return( constructorList.count() );
   }
   const QStringList &getLoadedFiles( ) const
   {
      return(m_loadedFiles);
   };
   void setFrameWork(const QString &frameWork)
   {
      m_frameWork=frameWork;
   }
   const QString &getFrameWork() const
   {
      return(m_frameWork);
   }
};

class CConstructor: public CJsonObject
{
private:
    QString m_type;
    QJsonArray m_arguments;
    QString m_className;
    QString m_includeHeader;
    QString m_implementation;
    QString m_frameWork;
    // QString m_initFunction;

public:
    CConstructor(const QString &type, const QJsonArray &arguments)
       :m_type(type)
       ,m_arguments(arguments)
    {

    }

    const QString &getType() const
    {
       return(m_type);
    }

    const QString &getClass() const
    {
       return(m_className);
    }
    void setClass(const QString &className)
    {
       m_className=className;
       return;
    }
    const QString &getIncludeHeader() const
    {
       return(m_includeHeader);
    }
    void setIncludeHeader(const QString &includeHeader)
    {
       m_includeHeader=includeHeader;
    }
    /*
    void setImplementation(const QString implementation)
    {
       m_implementation=implementation;
    }
    const QString &getImplementation() const
    {
       return(m_implementation);
    }
    */
    /*
    void setInitFunction(const QString initFunction)
    {
       m_initFunction=initFunction;
    }
    const QString &getInitFunction() const
    {
       return(m_initFunction);
    }
    */
    const QJsonArray &getArguments() const
    {
       return(m_arguments);
    }
    void setFrameWork(const QString &frameWork)
    {
       m_frameWork=frameWork;
    }
    const QString &getFrameWork() const
    {
       return(m_frameWork);
    }
};


//---fin----------------------------------------------------------------------
#endif // ? ! _PINMUX_CONSTRUCTOR_H_
