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


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


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


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

#include <QString>
#include <QList>
#include <QTextStream>
#include <QSharedPointer>

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

#include "periphery.h"


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


class CPeripheryList
{
private:
   QList< QSharedPointer < CPeriphery > > peripheryList;
   QList< QSharedPointer < CPeriphery > > fabricatedPeripheryList;

public:

   EMatchMode getMatchMode(CReference &reference, const CReference &rootReference) const;
   CPeripheryPtr findPeripheryByPeripheryName( const QString  &peripheryName );

   void dump(const QString &title) const;
   void dump(QTextStream &stream) const;
   QSharedPointer <CPeriphery> getPeripheryTypeCount( const QString& peripheryType, int count, int used );
   
   void addPeriphery(QSharedPointer<CPeriphery> periphery)
   {
      peripheryList << periphery;
      //peripheryList.last()->updateId();
   }
   void addFabricatedPeriphery(QSharedPointer<CPeriphery> periphery)
   {
      fabricatedPeripheryList << periphery;
      //peripheryList.last()->updateId();
   }
   const QList< QSharedPointer <CPeriphery> > &listConst() const
   {
      return(peripheryList);
   }
   QList< QSharedPointer <CPeriphery> > &list()
   {
      return(peripheryList);
   }
   void clear()
   {
      peripheryList.clear();
   }
   void sortPeriphery()
   {
      if ( peripheryList.size() > 1 )
      {
         std::sort( peripheryList.begin(), peripheryList.end());
         qWarning("Will sort epmty List: %d", (int)peripheryList.size());
      }
      else
      {
         qWarning("Will not sort epmty List: %d", (int)peripheryList.size());
      }
   }
};


//---fin----------------------------------------------------------------------
#endif // ? ! _PINMUX_BOARD_H_
