///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Microsoft WMIOLE DB Provider
// (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
//
//
// This module contains the base object for CDatasource, CDBSession, CCommand,
// and CRowset.  It contains routines such as globally registering the object 
// for the cleanup routine and typing the object so persist an other internal
// implementation can know what object they are talking to.
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "headers.h"

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Constructor for this class
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
CBaseObj::CBaseObj(	EBaseObjectType botVal,         // IN Base Object Type
	                LPUNKNOWN		pUnkOuter		// IN Outer Unknown Pointer  
                    ) : m_cs(TRUE)
{

	m_BaseObjectType = botVal;
	m_cRef = 0;
	m_pUnkOuter = pUnkOuter? pUnkOuter : LPUNKNOWN(this);
	InterlockedIncrement(&g_cObj);

}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Destructor for this class
//
//        
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
CBaseObj::~CBaseObj()
{
	InterlockedDecrement(&g_cObj);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Return Base Object type name.
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
WCHAR * CBaseObj::GetBaseObjectTypeName()
{
#ifdef DEBUG
	static WCHAR * s_wszName[] = {
		L"Unknown",
		L"DataSource",
		L"Session",
		L"Command",
		L"Rowset",
		L"Error",
		L"ClassFactory",
		L"Enumerator",
		L"TransactionOptions",
	};
	assert(m_BaseObjectType >= BOT_DATASOURCE	&&     m_BaseObjectType <= BOT_MULTIPLERESULTS);
	return s_wszName[m_BaseObjectType];
#else
	return L"";
#endif
}
