/// @file compressor_statistical.hpp
/// Skeleton for statistical compressors
///
/// @remarks
/// This is a base class available for use in building statistical coders
///  which use a parser+model+coder component architecture.  You can't use
///  this "as-is", you need to derive from it and fill in the constructor
///  at a minimum, to create the appropriate model/parser/coder.
///
/// @author mouser
/// @date   2003.07.29
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// recursive header protection
#ifndef OctaneCompressor_StatisticalH
#define OctaneCompressor_StatisticalH
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// application includes
#include "../modelers/modeler.hpp"
#include "../parsers/parser.hpp"
#include "../coders/coder.hpp"
#include "../bitio/bitio.hpp"
#include "compressor.hpp"
#include "../core/compressormanager.hpp"
//---------------------------------------------------------------------------



//---------------------------------------------------------------------------
/// The Statistical compressor class is a base class from which to derive
///  specific statistical compressors that make use of the parser/modeler/coder
///  framework.
///
/// @ingroup Compressors
///
class OctaneCompressor_Statistical : public OctaneCompressor
{
protected:
	// children components
	/// Pointer to the derived (and dynamically allocated) statistical parser.
	OctaneParser* parserp;
	/// Pointer to the derived (and dynamically allocated) statistical modeler.
	OctaneModeler* modelerp;
	/// Pointer to the derived (and dynamically allocated) statistical coder.
	OctaneCoder* coderp;
public:
	/// constructor
	OctaneCompressor_Statistical(bool registerme=false);
	/// destructor
	virtual ~OctaneCompressor_Statistical();
public:
	//---------------------------------------------------------------------------
	// OCTANE PUBLIC API - RTTI AND HELP FUNCTIONS - these are supported by all derived classes
	virtual std::string GetClassName() {return "StatisticalCompressorBase";}
	virtual std::string GetDescription() {return "Statistical Compressor Base Class";}
	virtual std::string GetHelpInformation();
	//---------------------------------------------------------------------------
public:
	//---------------------------------------------------------------------------
	// OCTANE PUBLIC API - AUXILIARY FUNCTIONS - these are supported by all derived classes
	virtual void ShowDebuggingInfo();
	virtual unsigned int GetMemoryUsed();
	virtual unsigned int GetDiskspaceUsed(bool fortempdecompressiononly);
	virtual std::string GetParametersInformation();
	virtual void SetDefaultParameters();
	virtual bool SetParameter(const std::string &parametername,const std::string &parametervalue);
	//---------------------------------------------------------------------------
public:
	//---------------------------------------------------------------------------
	// COMPRESSOR PUBLIC API - PREPARATION FOR COMPRESSING/DECOMPRESSING
	virtual void ResetState();
	virtual void SynchronizeStateForNewStream();
	virtual bool PrepareForCompression();
	virtual void SetupAnyDefaultParser();
	virtual bool IsReadyToCompress();
	//---------------------------------------------------------------------------
protected:
	//---------------------------------------------------------------------------
	// COMPRESSOR DERIVED COMPRESSION/DECOMPRESSING - implement these in derived classes
	virtual bool DoProtectedCompress(bitreader &from, bitwriter &to);
	virtual bool DoProtectedDecompress(bitreader &from, bitwriter &to);
	//---------------------------------------------------------------------------
protected:
	//---------------------------------------------------------------------------
	// OCTANE PROTECTED DERIVED STATE LOADING AND SAVING
	virtual bool DoProtectedCreateSymbolsAndModelsUsingStream(bitreader &from);
	virtual bool DoProtectedSaveState(bitwriter &to,bool fortempdecompressiononly);
	virtual bool DoProtectedLoadState(bitreader &from);
	//---------------------------------------------------------------------------
};
//---------------------------------------------------------------------------






//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------

