/**************************************************************************

	StepStream.h												JJS 9/06/95
	
		part of CONICAL, the Computational Neuroscience Class Library
	
	This class implements a column-oriented output stream.  A number of
	columns are defined, with text headers (of length kSSHeaderLen).  At
	each step, the values (tied to the class by pointers) are fetched
	and can be output to any ostream.
	
	WARNING: this class has no means to check whether the pointers it
	is given are valid, or to ensure that they stay that way.  If it
	ends up with an invalid pointer, Disaster May Happen.
	
	Requires:
		Stepper		-- base class
		ostream		-- as declared in <iostream.h>
		string		-- ANSI string functions, declared in <string.h>

**************************************************************************/

#ifndef STEPSTREAM_H
#define STEPSTREAM_H

#include "Stepper.h"
class ostream;

const int kSSHeaderLen = 20;			// maximum chars in column header
const int kSSMaxCols = 64;				// maximum number of columns

#ifndef NULL
#define NULL 0
#endif

class StepStream : virtual public Stepper
{
  public:
  
	StepStream( void );								// constructor
	
	StepStream( ostream& pStream );					// constructor
	
	virtual void Step( const real dt )				// update T, maybe output
	{ T += dt; if (OutputOnStep) Output(); }
	
	// column set-up
	
	virtual int SetColumn( const int pCol, real *pVar=NULL, const char* pHeader=NULL);
	virtual int ClearColumn( const int pCol )
	{ return SetColumn(pCol); }
	
	// inspectors
	
	virtual const char *GetHeader( const int pCol ) const;
	virtual real GetValue( const int pCol ) const;
	virtual void Output( ostream* pStr = NULL ) const;
	virtual void OutputHeader( ostream* pStr = NULL ) const;
	
	// public variables:
	
	real T;						// current time
	ostream *itsOutStream;		// primary output stream
	int OutputOnStep;			// set to 1 to output during Step
	char Delimiter;				// character inserted between the columns
	
  protected:

	char itsColHeader[kSSMaxCols][kSSHeaderLen];
	real *itsColVar[kSSMaxCols];
	int itsHighColNum;
	int itsPrecision;
};

#endif