// SpaFEDTe, a Template based C++ library for creating 
// Discontinuous Finite Element Spaces,
// Copyright (C) 2012 Lorenzo Alessio Botti

/* This library is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Lesser General Public */ 
/* License as published by the Free Software Foundation either */ 
/* version 3.0 of the License, or (at your option) any later version. */

/* This software is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU */
/* Lesser General Public License for more details. */

/* You should have received a copy of the GNU Lesser General Public */
/* License along with this software; if not, a copy of the full */
/* GNU Lesser General Public License can be found at */
/* http://www.gnu.org/licenses/ */

#ifndef __finite_element_quadrature_h__
#define __finite_element_quadrature_h__

#include <vector>
#include "Quadrature.hpp"
#include "Tuple.hpp"
#include "EnumElemType.hpp"

template<class FiniteElementQuadratureT>
class FiniteElementQuadrature
{
public:

  typedef Quadrature::PointVector PointVector;
  typedef Quadrature::RealVector RealVector;
  typedef FiniteElementQuadratureT FiniteElementQuadratureType;

public:

  /** Constructeur de la classe */
  FiniteElementQuadrature() 
    {
      ;
    }
  
  /** Destructeur de la classe */
  ~FiniteElementQuadrature() { }
  
  //! Initialisation
  static void init(Quadrature& quadrature)
  {
    FiniteElementQuadratureType::initQRule(quadrature);  
  }

  static unsigned int nPoints(const unsigned int dim, const unsigned int q_Order, const ElemType itemType = INVALID_ELEM)
  {
    return FiniteElementQuadratureType::nPoints(dim, q_Order, itemType);
  }
  
  static void init(Quadrature& quadrature, const ElemType itemType, const unsigned int order)
  {
    ElemType& q_itemType = quadrature.getItemType();
    unsigned int& q_Order = quadrature.getOrder();
    if (itemType == q_itemType && order == q_Order)
    {
      return;
    }
    else 
    {
      q_itemType = itemType;
      q_Order = order;
    }
    FiniteElementQuadratureType::initQRule(quadrature);  
  }
};

#endif
