//===========================================================================//
// File:    lranlyzr.hpp                                                     
// Project: LabRat                                                 		 
// Contents: 				  
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 07/12/96  JSE  Initial coding.                                             
//---------------------------------------------------------------------------//
// Copyright (C) 1996, Virtual World Entertainment, Inc.                     //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//


#include "LabRatdoc.h"

#if !defined (LRANLYZR_HPP)
#	define LRANLYZR_HPP

#define START_MESSAGE_ID WM_USER + 6
#define LAST_MESSAGE_ID  WM_USER + 56

#define ON_ID  START_MESSAGE_ID
#define OFF_ID  START_MESSAGE_ID + 1
#define LOGICANALYZER_ID START_MESSAGE_ID + 2

class TraceAnalyzerRegistry;
class TraceAnalyzer;

#	if !defined (STYLE_HPP)
#		include "style.hpp"
#	endif

#include "storage.hpp"


#include "AnalyzeBox.h"

// Only 50 are allowed without changing last_message_id


//##########################################################################
//#######################    TraceAnalyzerRegistry    
//##########################################################################


#define REGISTER_ANALYZER(name) analyzerList.AddTail((CObject *)new name);

	class TraceAnalyzerRegistry :
		public CObject
	{
	public:
		CObList analyzerList;

		TraceAnalyzerRegistry(void);
		~TraceAnalyzerRegistry(void);

		CMenu *CreateMenu(int type);
		void Analyze(CChildFrame *parent, int indexOfTrace, int nID);

	};

//##########################################################################
//#######################    TraceAnalyzer   
//##########################################################################


	

	class TraceAnalyzer : public CObject
	{
	protected:
		CString textLabel;

	public:

		virtual ~TraceAnalyzer(void)
		{;}

		virtual int * GetAvailableTraces(int &count)
		{count = 0; return NULL;}

		CString GetTextLabel()
		{
			return textLabel;
		}

		virtual int GetMessageID(void)
		{return -1;}

		virtual void RunAnalyzer(CChildFrame * /*parent*/, int /*indexOfTrace*/)
		{;}

		Logical WorkWithTraceType(int type);

	};

 
   

//##########################################################################
//#######################    OnAnalyzer   
//##########################################################################


	class OnAnalyzer : public TraceAnalyzer
	{
		
	public:

		int compatableTracesCount;
		int *compatableTraces;

		OnAnalyzer(void);
		~OnAnalyzer(void)
		{
			delete[] compatableTraces;
		}

		virtual int * GetAvailableTraces(int &count)
		{count = compatableTracesCount; return compatableTraces;}


		int GetMessageID(void)
			{return ON_ID;}

		void RunAnalyzer(CChildFrame *parent, int indexOfTrace);
		
	};

//##########################################################################
//#######################    OffAnalyzer   
//##########################################################################


	class OffAnalyzer : public TraceAnalyzer
	{
		
	public:

		int compatableTracesCount;
		int *compatableTraces;

		OffAnalyzer(void);
		~OffAnalyzer(void)
		{
			delete[] compatableTraces;
		}

		virtual int * GetAvailableTraces(int &count)
		{count = compatableTracesCount; return compatableTraces;}


		int GetMessageID(void)
			{return OFF_ID;}

		void RunAnalyzer(CChildFrame *parent, int indexOfTrace);
		
	};


//##########################################################################
//#######################    LogicalAnalyzer   
//##########################################################################


	class LogicalAnalyzer : public TraceAnalyzer
	{
		
	public:

		int compatableTracesCount;
		int *compatableTraces;

		LogicalAnalyzer(void);
		~LogicalAnalyzer(void)
		{
			delete[] compatableTraces;
		}

		virtual int * GetAvailableTraces(int &count)
		{count = compatableTracesCount; return compatableTraces;}


		int GetMessageID(void)
			{return LOGICANALYZER_ID;}

		void RunAnalyzer(CChildFrame *parent, int indexOfTrace);
		
		void
			AnalyzeTrace(
				CChildFrame *parent, 
				AnalyzeBox *box, 
				TraceLine *trace_line, 
				Time start_time, 
				Time end_time,
				Time &grand_total_time_up
			);

	};
#endif