/*
Copyright (c) 2001                      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          : TTMOptions.h
Author            : Rene Wilhelm
Date              : 18-10-2001
Revised           : 10-12-2002, add IP version option (v4, v6)
Description       : TTM Options class definition
Language Version  : C++
OSs Tested        : Solaris 2.6, Solaris 8, Debian Linux 2.2

A TTMOptions object stores the various command line options of TTM programs
Encapsulating this information in one object allows for more flexible
code and eliminates the need for globally scoped parameters.

$Id: TTMOptions.h,v 1.2 2003/01/16 17:29:27 wilhelm Exp $
-------------------------------------------------------------------------------
*/


#ifndef TTMOPTIONS_H
#define TTMOPTIONS_H



#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include "utils.h"

#define TTCONFIG_COMMAND        "/ncc/ttpro/bin/ttconfig"
#define TTCONFIG_COMMAND_ARGS   "-v active"
#define TTCONFIG_COMMAND_ARGS6  "-v active6"

class TTMOptions {
private:
        uint		sourceId, targetId;
	time_t		endTime, timePeriod;
	char		*inputPath, *outputPath;
	float   	minDelay, maxDelay;
	short		logScale, allPackets;
	period		sumPeriod;
	plotformat	plotFormat;
	char		storageType;		// storage type of ROOT data
					        // 'H' = yyyyy/mm/dd hierarchy
	char 		*progName;
	char		*configCmd;		// command to fetch TB config

	int   		verbose;
	int   		ipVersion;		// which data to use IPv4, IPv6

	char* optionString;

	void usage();
	void invaliddate();
	void decodePeriod (char *datestring, time_t& end, time_t& period);
	void parseISO8601 (char *text, time_t& isotime, char& flag);

public:
	int  Verbose()      {return verbose;}
	int  IPversion()    {return ipVersion;}
	uint SourceId()     {return sourceId;}
	uint TargetId()     {return targetId;}
	char* InputPath()   {return inputPath;}
	char* OutputPath()  {return outputPath;}
	float MinDelay()    {return minDelay;}
	float MaxDelay()    {return maxDelay;}
	short Logscale()    {return logScale;}
	short AllPackets()  {return allPackets;}
	time_t EndTime()    {return endTime;}
	time_t TimePeriod() {return timePeriod;}
	char* ProgramName() {return progName;}
	char StorageType()  {return storageType;}
	char* ConfigCommand()   {return configCmd;}
	period SummaryPeriod()  {return sumPeriod;}
	plotformat PlotFormat() {return plotFormat;}

	TTMOptions(int argc, char** argv, char* optstring);
	~TTMOptions();
};

#endif
