/** @file stats.h
 *
 *	Declaration and definitions of simple classes designed to hold some
 *	statistics data.
 *
 *	(C) Ceslav Przywara 2008, MFF UK Prague
 *
 */

#ifndef _STATS_H
#define	_STATS_H

#include <string>
#include <vector>

namespace ace {

/** Class implements simple statistics counter.
 */
struct DataFileStats {
	/** Words counter.
	 */
	size_t words;
	/** Sentences counter.
	 */
	size_t sentences;
	/** N-grams counter. E = P + F.
	 */
	struct NGramsStats {
		/** E(xtracted) N-grams.
		 */
		size_t extracted;
		/** P(assed) the filtration.
		 */
		size_t passed;
		/** F(iltered).
		 */
		size_t filtered;
		/** Default constructor inits all fields to 0.
		 */
		NGramsStats(void): extracted(0), passed(0), filtered(0) {}
		/** @param rhs NGramStats object to be added to current instance.
		 *	@return NGramsStats object with all fields incremented
		 *	by values of passed stats.
		 */
		inline NGramsStats& operator+=(const NGramsStats& rhs) {
			extracted += rhs.extracted;
			passed += rhs.passed;
			filtered += rhs.filtered;
			return *this;
		}
	} ngrams;
	/** Default constructor initializes all statistics with 0 values.
	 */
	DataFileStats(void): words(0), sentences(0), ngrams() {}
	/** @param rhs DataFileStats object to be added to current instance.
	 *	@return DataFileStats object with all fields incremented
	 *	by values of passed stats.
	 */
	inline DataFileStats& operator+=(const DataFileStats& rhs) {
		words += rhs.words;
		sentences += rhs.sentences;
		ngrams += rhs.ngrams;
		return *this;
	}
};

/** Class extends DataFileStats: adds "label" (for filename).
 */
struct NamedDataFileStats: public DataFileStats {
	/** Filename.
	 */
	std::string filename;

	/** Constructor needs filename to go.
	 *	@param file_name Filename of file, which stats are counted.
	 */
	NamedDataFileStats(const std::string& file_name): DataFileStats(), filename(file_name) {}
};

/** Typedef for container of datafiles statistics.
 */
typedef std::vector<NamedDataFileStats> stats_t;

} // namespace ace

#endif
