//---------------------------------------------------------------------------

#ifndef SoPLAH
#define SoPLAH

class SoPLA {
  private:
	string name;
	unsigned int inputs;
	list<Cube> data;
    bool indexed;        // are indexes valid?
	bool type;			// true = f, false = r

	bool DFF;		// true if DFF.

	vector<CubeList::iterator> indexterm;		// vector of terms, if SoPLA is indexed

	vector<string> inames;          // names of input variables

	void Reindex(void);

public:
	unsigned int tmp;				// for public use. Must not be modified by the kernel.
	unsigned int tmp1;				// for public use. Must not be modified by the kernel.

    SoPLA(void);
    SoPLA( const unsigned int iv );
	SoPLA( const unsigned int iv, bool _type );
    SoPLA( const SoPLA *_pla );			// This is not a copying constructor! Just creates PLA with the same dimensions and type
	~SoPLA(void);

	void clear(void);			// clears all the PLA structures

    // setters, getters
	unsigned int GetInputs(void) const {return inputs;};
	void SetInputs( const int i );
	list<Cube> *GetData() {return &data;};		// returns pointer to data
    unsigned int GetTerms(void) const { return data.size(); };
	string GetIName(const unsigned int i) const;
	vector<string> GetINames(void) const { return inames; };
	void SetINames( const vector<string> _names ) { inames = _names; };
	void SetIName(const unsigned int i, const string name);
	bool GetType(void) const { return type; };
	void SetType(bool _type) { type = _type; };
	bool IsDFF(void) const { return DFF; };
	void SetDFF(const bool _DFF) { DFF = _DFF; };
	string GetName(void) const { return name; };
	void SetName( const string _name ) { name = _name; };

	list<Cube>::iterator GetTerm(const unsigned int i);	// returns iterator to a term with a given index

	
	void RemoveAbsorbed(void);

	// data manipulation
	list<Cube>::iterator AppendTerm( const Cube &t );	// appends a term to the SoPLA
	list<Cube>::iterator AppendTerm( const string s );	// appends a term to the SoPLA
	list<Cube>::iterator DeleteTerm(const list<Cube>::iterator ti);   // Deletes term pointed by iterator. Returns iterator of the next one
	void AppendPLA( const SoPLA &_pla );	// appends a given PLA. Terms are copied to the end
	void Splice( SoPLA &_pla );	// appends a given PLA. Terms are copied to the end, the argument pla is cleared
	void Splice( CubeList &terms );  // appends a given term list. Terms are copied to the end, the argument term list is cleared

	// info functions

	bool empty(void) const;			// returns true if the SoPLA is empty
	unsigned int GetLiterals(void);
	unsigned int GetGEs(void);		// Returns GEs*2
	void RemoveAllDCCols(void);		// removes all-DC columns from the PLA


};


//---------------------------------------------------------------------------
#endif
