/******************************************************************************
 *                                                                         
 *               (C) COPYRIGHT Pacific MindWorks, Inc. 2001-2005
 *                          All rights reserved.
 *
 *****************************************************************************/

#ifndef __NTLCALLCONTEXT_INCLUDED
#define __NTLCALLCONTEXT_INCLUDED

#include <atlstr.h>
#include <atlcoll.h>

////////////////////////////////////////////////////////////////////////////////
//
//	Forward declarations
//

class CCallContext;

///////////////////////////////////////////////////////////////////////////////
//
//	CCallContextManager
//

class CCallContextManager
{
public:
	virtual CCallContext* GetCallContext() = 0;
	virtual void PushCallContext(CCallContext* pCallContext) = 0;
	virtual CCallContext* PopCallContext() = 0;

	// General format is, for example:  Agilent54600Trace[trace1].Agilent54600Channel[ch1]
	virtual CString GetRepeatedCapabilityIdentifier() = 0;
};

///////////////////////////////////////////////////////////////////////////////
//
//	CCallContext
//

class CCallContext
{
public:
	CCallContext(CCallContextManager* pCallContextManager, const CString& strClass, const CString& strInterface, const CString& strMethod)
		: m_pCallContextManager(pCallContextManager), m_strClass(strClass), m_strInterface(strInterface), m_strMethod(strMethod)
	{
		m_pCallContextManager->PushCallContext(this);
	}

	~CCallContext()
	{
		if (m_pCallContextManager != NULL)
		{
			m_pCallContextManager->PopCallContext();
		}
	}

public:
	CCallContextManager* GetCallContextManager() { return m_pCallContextManager; }
	const CString& GetClass() { return m_strClass; }
	const CString& GetInterface() { return m_strInterface; }
	const CString& GetMethod() { return m_strMethod; }

private:
	CCallContextManager* m_pCallContextManager;
	const CString m_strClass;
	const CString m_strInterface;
	const CString m_strMethod;
};

#endif // __NTLCALLCONTEXT_INCLUDED
