/********************************************************************/
/* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno          */
/* All rights reserved.                                             */
/********************************************************************/
#ifndef _MGKnotArray_HH_
#define _MGKnotArray_HH_
/** @file */
/** @addtogroup BASE
 *  @{
 */

#include <vector>
#include "mg/Knot.h"

// MGKnotArray.h
//

//Forward Declaration
class MGIfstream;
class MGOfstream;

/// Defines Array of Knots.

///This is not knot vector for B-Rep.
///See MGKnotVector.
class MG_DLL_DECLR MGKnotArray{

///Member Data

public:


///String stream Function.
MG_DLL_DECLR friend std::ostream& operator<< (std::ostream&, const MGKnotArray&);

////////////Constructor////////////

/// Dummy constructor.
MGKnotArray(){;};

///From Knot.
explicit MGKnotArray(const MGKnot&);

///From knot and the multiplicity.
MGKnotArray(double knot, int mult);

//	MGKnotArray(const MGKnotArray&);	//Copy Constructor.

///Destructor
	~MGKnotArray(){;};

////////////Operator overload.////////////

///[ ] reference.
const MGKnot& operator[](int pos) const
{return m_ktArray.operator[](pos);}
MGKnot& operator[](int pos)
{return m_ktArray.operator[](pos);}

////////////Member Function////////////

///Add to the end of list.
MGKnotArray& add(const MGKnot&);
MGKnotArray& add(double knot, int mult=1);

///Get the last element in the vector.
const MGKnot& back() const{return m_ktArray.back();};
MGKnot& back(){return m_ktArray.back();};

///Obtain the iterator of the first element.
std::vector<MGKnot>::iterator begin(){return m_ktArray.begin();};
std::vector<MGKnot>::const_iterator begin() const{return m_ktArray.begin();};

///Clear all the elements in m_CCilist.
void clear(){m_ktArray.clear();};

///Obtain the iterator of the first element.
std::vector<MGKnot>::iterator end(){return m_ktArray.end();};
std::vector<MGKnot>::const_iterator end() const{return m_ktArray.end();};

///Get the first element in the vector.
const MGKnot& front() const{return m_ktArray.front();};
MGKnot& front(){return m_ktArray.front();};

void push_back(const MGKnot& knot){m_ktArray.push_back(knot);};

/// Return the number of items that are in the list.
int length() const {return int(m_ktArray.size());};
int size() const{return int(m_ktArray.size());};

///Operator overload.
///	MGKnotArray& operator =(MGKnotArray&);///Assignment operator overload.

///Dump Functions.
	///Calculate dump size
	int dump_size() const;

	///Dump Function
	int dump(MGOfstream& ) const;

	///Restore Function
	int restore(MGIfstream& );

private:
	std::vector<MGKnot> m_ktArray;

};

/** @} */ // end of BASE group
#endif
