/*
Copyright (c) 2003                      RIPE NCC


All Rights Reserved

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of the author not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.

THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/*
-------------------------------------------------------------------------------
Module Header
Filename          : TTMHistograms.h
Author            : Rene Wilhelm
Date              : 17-JAN-2003
Description       : TTM Histograms Class defintion
Language Version  : C++
OSs Tested        : Solaris 2.6, Linux gcc2.95

The TTMHistograms class groups all histogram data and funtions needed to
create one TTM plots for a given source and target box. The TTMDelayData
class will create as many instances of this object as are required by
the configured source and target boxes.

The interface to the outside is provided by two methods:

  Fill() - and fills ROOT histograms
  Plot() - create plot(s) from the previously filled histograms. 
	
$Id: TTMHistograms.h,v 1.1 2003/01/16 17:29:13 wilhelm Exp $
-------------------------------------------------------------------------------
*/

#ifndef TTMHistograms_included
#define TTMHistograms_included


#include <time.h>  
#include <TH1.h>
#include <TH2.h>
#include <TPad.h>
#include <TStyle.h>
#include "TestBox.h"
#include "Percentiles.h"
#include "RoutingInfo.h"
#include "TTMOptions.h"
#include "utils.h"

class TTMHistograms {
private:
	TestBox *source;
	int     targetNum;		// index in source's targetList

	int 	verbose;

	// pointers to histogram objects.

	TH2F	*Delay2D;
	TH1F	*Delay1D;
	TH1F	*PacketsSent;
	TH1F	*ClocksOK;
	TH1F	*BadSourceClock;
	TH1F	*BadTargetClock;
	TH1F	*BadClocks;
	TH2F	*RoutesNHops;
	TH1F	*PacketsLost;


	TH1F	*Arrived;

	Percentiles *LossPercentile;	  
	Percentiles *DelayPercentile;	 
	RoutingInfo *RoutesInfo;	

	char*  outputDir;

	time_t starttime;
	char*  cstarttime1;	// full  char reprensation of start time
	char*  cstarttime2;	// short char reprensation of start time
	time_t endtime;
	char*  cendtime1;	// full  char reprensation of end time
	char*  cendtime2;	// short char reprensation of end time

	TStyle *rootstyle;

	// parameters for histograms

	int	ipVersion;	// IPv4 or IPv6
	double	mindelay;	// lower delays will go to underflow bin
	double	maxdelay;	// higher delays will go to overflow bin
	short	logscale;	// whether or not to use logscale for delays
	short	allpackets;	// also include packets with bad clocks in plots
	int	binsX;		// number of bins on X-axis
	int	binsY;		// number of bins on Y-axis

	plotformat plotFormat;	// gif, ps, ...

	// private methods

	void ClearHistos();
	void CreateHistos();
	void DeleteHistos();
	void PlotHistos(char* sourcename, char* targetname);

	void write_stats(TPad* pad, const char* ptr_text, const Float_t x,
                const Float_t y, const Short_t align, Font_t font);

public:
	TTMHistograms();
	~TTMHistograms();
	void Fill(Delay* packet);
	void SetConfig(TestBox* source, int targetnum, TTMOptions* opt);
	void Plot();
	
};
#endif

//	void processDelay(Delay* delay);     UNUSED?
