//------------------------ CSPSession.h -----------------------

//*************************************************************
//*****       Copyright ©2002 - 2004 Micronovae Ltd       *****
//*****                All rights reserved                *****
//*************************************************************


#ifndef _CSPSESSION
#define _CSPSESSION

#include "CSPConf.h"
#include "CSPLib.h"
#include "CSPMap.h"
#include "CSPString.h"
#include "CSPVariant.h"

class CSPOBJ_CLASS_EXPORT CSPSessionNumber : public CSPObject
{
	public:
		operator const char*()const;
		CSPSessionNumber(const CSPString& strString = CSPString( "AAAAAAAAAAAAAAAAAAAAAAAA" ) );
		virtual ~CSPSessionNumber();
		CSPSessionNumber& operator=( const CSPSessionNumber& SessionNum );
		CSPSessionNumber& operator++();
		CSPSessionNumber operator++(int);

	protected:
		char SessionNumber[25];
};



class CSPOBJ_CLASS_EXPORT CSPSession : public CSPObject
{
	typedef CSPMap< CSPString, CSPVariant > CSPSessionItemMap;
	friend class CSPEngine;

	public:
		unsigned long Timeout;	//minutes


		CSPSession();
		virtual ~CSPSession();
		CSPSession( const CSPSession& session );
		CSPSession& operator = ( const CSPSession& session );

		CSPVariant& operator ()( const CSPString& strItemName );
		CSPVariant& GetValue( const CSPString& strItemName );
		void SetValue( const CSPString& strItemName, const CSPVariant& varValue );
		void RefreshTime();
		unsigned long GetTime() const;
		const CSPString& GetSessionID() const;

	protected:

		CSPString strSessionID;
		unsigned long Time; //seconds
		CSPSessionItemMap ItemsMap;
		
		static CSPSessionNumber NextSessionID;
		CSPSessionNumber SessionID;
};

#endif
