/* Web Polygraph       http://www.web-polygraph.org/
 * (C) 2003-2006 The Measurement Factory
 * Licensed under the Apache License, Version 2.0 */

#ifndef POLYGRAPH__LOGANALYZERS_TESTINFO_H
#define POLYGRAPH__LOGANALYZERS_TESTINFO_H

#include "xstd/Array.h"
#include "xstd/Time.h"
#include "xstd/String.h"
#include "xstd/BigSize.h"
#include "loganalyzers/SomeInfo.h"

class InfoScopes;
class SideInfo;
class BlobDb;

// aggregate stats and other logged information about a test 
// manages info about all sides of the test
class TestInfo: public SomeInfo {
	public:
		TestInfo(const String &aLabel);
		~TestInfo();

		// get/set scope for executive summary
		const Scope &execScope() const;
		void execScope(const Scope &aScope);
		const Scope &guessExecScope();

		const String &label() const;
		const String &pglCfg() const;
		Time startTime() const;

		bool twoSided() const { return cltSideExists() && srvSideExists(); }
		const SideInfo *cltSideExists() const;
		const SideInfo *srvSideExists() const;
		const SideInfo &aSide() const;
		const SideInfo &cltSide() const;
		const SideInfo &srvSide() const;
		SideInfo &cltSide();
		SideInfo &srvSide();
		const SideInfo &side(int logCat) const;
		SideInfo &side(int logCat);

		int scopes(InfoScopes &res) const;

		int repCount(const Scope &scope) const;
		int hitCount(const Scope &scope) const;
		BigSize repVolume(const Scope &scope) const;
		BigSize hitVolume(const Scope &scope) const;

		void checkConsistency();

		void compileStats(BlobDb &db);

	protected:
		void checkCommonPglCfg();
		void checkCommonBenchmarkVersion();
		void checkCommonStartTime();

		void cmplExecSumVars(BlobDb &db);
		void cmplExecSum(BlobDb &db);
		void cmplWorkload(BlobDb &db);

		void cmplSynonyms(BlobDb &db, const Scope &scope);
		void cmplHitRatioVars(BlobDb &db, const Scope &scope);
		void cmplHitRatio(BlobDb &db, const Scope &scope);
		void cmplHitRatioTable(BlobDb &db, XmlTag &parent, const Scope &scope) ;

		void cmplBaseStats(BlobDb &db, const Scope &scope);
		void cmplTraffic(BlobDb &db, const Scope &scope);
		void cmplRptm(BlobDb &db, const Scope &scope);
		void cmplSavings(BlobDb &db, const Scope &scope);
		void cmplLevels(BlobDb &db, const Scope &scope);
		void cmplErrors(BlobDb &db, const Scope &scope);
		void cmplNotes(BlobDb &db);

	protected:
		String theLabel;
		String theBenchmarkVersion;
		String thePglCfg;
		Time theStartTime;

		Array<SideInfo*> theSides;
		Array<InfoScope*> theScopes;
		String theOneSideWarn;
		Scope theExecScope;
};

#endif


syntax highlighted by Code2HTML, v. 0.9.1