/***************************************************************************
    FPGA Brook Source Code
    Copyright (C) by Frank Franjo Plavec 2006-2012

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

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    The full text of the GNU General Public License in the file named
    LICENSE.cTool.
*****************************************************************************/

/*
	Class StreamInfo holds information about a stream
	The information includes a pointer to the stream (Type *),
	number of dimensions (int), number of kernels that read this stream (int),
	and the pointer to the expression(s) representing the stream's size
	(Expression *), and whether it's an out or reduce stream
	More info may be added as necessary.
*/

#include "ctool.h"

class StreamInfo {

public:
	StreamInfo (); // Default constructor, to make sure that size is NULL when vector creates new default objects
	StreamInfo (Decl *stream, unsigned int dimensions, bool out=false, bool reduce=false);
	StreamInfo (Decl *stream, unsigned int dimensions, unsigned int readers, bool out, bool reduce);
	StreamInfo (const StreamInfo &param); // copy constructor - necessary to store objects into vector
									// because vector is expanded by copying elements into new memory
									// at which point destructor is called, which deletes the size array
	StreamInfo& operator=(const StreamInfo &right);
	unsigned int dimensions ();
	unsigned int readers ();
	unsigned int incrementReaders();
	bool isOut ();
	bool isReduce ();
	Expression * getSize (unsigned int dimension);
	bool setSize (unsigned int dimension, Expression *size);

	~StreamInfo ();

	Decl *stream;
private:
	unsigned int dims;
	unsigned int num_readers;
	bool out;
	bool reduce;
	Expression **size;
};

typedef    std::vector<StreamInfo>    StreamInfoVector;
