#ifndef IRFOX_ANALYZER_H
#define IRFOX_ANALYZER_H

#include <Analyzer.h>
#include "IrFoxAnalyzerSettings.h"
#include "IrFoxAnalyzerResults.h"
#include "IrFoxSimulationDataGenerator.h"
#include <memory>
#include <string>
#include <unordered_map>

class ANALYZER_EXPORT IrFoxAnalyzer : public Analyzer2
{
public:
	IrFoxAnalyzer();
	virtual ~IrFoxAnalyzer();

	virtual void SetupResults();
	virtual void WorkerThread();

	virtual U32 GenerateSimulationData(U64 newest_sample_requested, U32 sample_rate,
									 SimulationChannelDescriptor** simulation_channels);
	virtual U32 GetMinimumSampleRateHz();

	virtual const char* GetAnalyzerName() const;
	virtual bool NeedsRerun();

	const char* PacketHexForFrame(U64 frame_id);
	const char* BubbleTextForFrame(U64 frame_id) const;

protected:
	IrFoxAnalyzerSettings mSettings;
	std::unique_ptr<IrFoxAnalyzerResults> mResults;
	AnalyzerChannelData* mIr;

	IrFoxSimulationDataGenerator mSimulationDataGenerator;
	bool mSimulationInitilized;

	std::unordered_map<U64, std::string> m_packet_hex_by_frame;
	std::unordered_map<U64, std::string> m_bubble_text_by_frame;
	mutable std::string m_hex_scratch;
	mutable std::string m_bubble_scratch;
};

extern "C" ANALYZER_EXPORT const char* __cdecl GetAnalyzerName();
extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer();
extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer(Analyzer* analyzer);

#endif
