
// Title:	Signal.h
// Date:	28-8-08 (start), 1-12-08 (updated)

#include "Block.h"

#ifndef SIGNAL_H
	#define SIGNAL_H					// inclusion guard

	#include <list>						// rqd. for list (below)
	using namespace std;

	// User defined types
	
	// Signal			
	class CSignal
	{
	public:
		void SetOutputSignalString(CString string);
		CString GetOutputSignalString(void);
		void GetSignalDataDimensions(int *nrows, int *ncols);
		int GetSignalValidity(void);
		void SetSignalData(double **matrix, int nrows, int ncols);
		double** GetSignalData(int *nrows, int *ncols);
		void ResetSignalData(void);
		CSignal(void);				
		~CSignal(void);

		// Accessor methods
		CString GetSignalName(void);		
		void SetSignalName(CString name);
		void SetSignalValidity(int valid);
	
	private:
		int m_iNrows;				// no. of rows of signal matrix
		int m_iNcols;				// no. of cols of signal matrix
		int m_iValidity;			// signal data-based validity
		double **m_dSignalMatrix;	// matrix signal value
		CString m_strOutputSignal;	// str version of output signal
		CString m_strSignalName;	// signal name
	};


	// Connection
	class CConnection
	{
	public:
		CConnection(const CConnection &con);
		CConnection(CPoint ptFrom, CPoint ptTo);
		CConnection(void);				
		~CConnection(void);
		void ReadConnectionDataFromFile(ifstream &fin);
		void WriteConnectionDataToFile(ofstream &fout);
		void SetRefFromPoint(CPoint *from_pt);
		CPoint* GetRefFromPoint(void);
		list<CPoint>& GetConnectionBendPointsList(void);
		list<CPoint> GetConnectionBendPointsListCopy(void) const;
		void SetRefToPort(CPort *to_port);
		void SetRefFromPort(CPort *from_port);
		CPort* GetRefToPort(void);
		CPort* GetRefFromPort(void);
		void SetConnectionPointHead(CPoint new_pt);
		void SetConnectionPointTail(CPoint new_pt);
		CPoint GetConnectionPointHead() const;
		CPoint GetConnectionPointTail() const;
		void DrawArrowHead(CDC *pDC, CPoint tail, CPoint head);
		void DrawConnection(CDC *pDC);
		CSignal *GetSignal(void);			// gets the private member var m_pSignal of type ptr-to-CSignal
	
	private:
		CPoint	m_ptTail;				// starting pt from which connection is drawn
		CPoint	m_ptHead;				// ending pt to whcih connection is drawn
		CPoint  *m_pRefFromPoint;		// bend point from which a connection (tail point) emanates
		CPort	*m_pRefFromPort;		// singular, since 1 connection has only 1 from-port (ptr used since block ports not known at this stage)
		CPort	*m_pRefToPort;			// singular, since 1 connection has only 1 to-port (ptr used since block ports not known at this stage)
		CSignal	*m_pSignal;				// singular, since 1 signal (like a current) travels down 1 connection (like a wire).
		list<CPoint> m_lstBendPoints;	// list of bend points used in a bendable connection.
	};

#endif

// eof