Click here to Skip to main content
15,896,434 members
Articles / Desktop Programming / WTL

Cyclomatic Complexity Viewer

Rate me:
Please Sign up or sign in to vote.
4.29/5 (13 votes)
30 Jun 20055 min read 109.1K   2.8K   34  
A Cyclomatic complexity viewer application.
// CycloComplexViewer.cpp : Legt die Initialisierungsroutinen f�r die DLL fest.
//

#include "stdafx.h"
#include <initguid.h>
#include "CycloComplexViewer.h"
#include "DSAddIn.h"
#include "Commands.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

CComModule _Module;

BEGIN_OBJECT_MAP(ObjectMap)
	OBJECT_ENTRY(CLSID_DSAddIn, CDSAddIn)
END_OBJECT_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCycloComplexViewerApp

class CCycloComplexViewerApp : public CWinApp
{
public:
	CCycloComplexViewerApp();

// �berladungen
	// Vom Klassenassistenten generierte �berladungen virtueller Funktionen
	//{{AFX_VIRTUAL(CCycloComplexViewerApp)
	public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

	//{{AFX_MSG(CCycloComplexViewerApp)
		// HINWEIS - An dieser Stelle werden Member-Funktionen vom Klassenassistenten eingef�gt und entfernt..
		//    Innerhalb dieser generierten Quelltextabschnitte NICHTS VER�NDERN!
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
// CCycloComplexViewerApp

BEGIN_MESSAGE_MAP(CCycloComplexViewerApp, CWinApp)
	//{{AFX_MSG_MAP(CCycloComplexViewerApp)
		// HINWEIS - Hier werden Mapping-Makros vom Klassenassistenten eingef�gt und entfernt.
		//    Innerhalb dieser generierten Quelltextabschnitte NICHTS VER�NDERN!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Das einzige CCycloComplexViewerApp-Objekt

CCycloComplexViewerApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CCycloComplexViewerApp Konstruktion

CCycloComplexViewerApp::CCycloComplexViewerApp()
{
	// ZU ERLEDIGEN: Hier Code zur Konstruktion einf�gen
	// Alle wichtigen Initialisierungen in InitInstance platzieren
}

/////////////////////////////////////////////////////////////////////////////
// CCycloComplexViewerApp Initialisierung

BOOL CCycloComplexViewerApp::InitInstance()
{
	_Module.Init(ObjectMap, m_hInstance);
	return CWinApp::InitInstance();
}

int CCycloComplexViewerApp::ExitInstance()
{
	_Module.Term();
	return CWinApp::ExitInstance();
}

/////////////////////////////////////////////////////////////////////////////
// Spezielle, f�r Inproc-Server ben�tigte Einsprungpunkte

STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	return _Module.GetClassObject(rclsid, riid, ppv);
}

STDAPI DllCanUnloadNow(void)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
}

// Sie k�nnen regsvr32.exe verwenden, indem Sie DllRegisterServer exportieren
STDAPI DllRegisterServer(void)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	HRESULT hRes = S_OK;
	
	// Registriert Objekt, Typelib und alle Schnittstellen in Typelib
	hRes = _Module.RegisterServer(TRUE);
	if (FAILED(hRes))
		return hRes;

	// Beschreibung dieses AddIn-Objekts in seinem eigenen
	//  /Description Teilschl�ssel registrieren.
	// ZU ERLEDIGEN:  Wenn Sie diesem Modul weitere AddIns hinzuf�gen, m�ssen Sie
	//  zur Registrierung all Ihrer Beschreibungen jede Beschreibung
	//  im CLSID-Eintrag der Registrierung jedes Add-In-Objekts registrieren:
	// HKEY_CLASSES_ROOT\Clsid\{add-in  HKEY_CLASSES_ROOT\Clsid\{add-in CLSID}\Description="Add-In-Beschreibung"
	_ATL_OBJMAP_ENTRY* pEntry = _Module.m_pObjMap;
	CRegKey key;
	LONG lRes = key.Open(HKEY_CLASSES_ROOT, _T("CLSID"));
	if (lRes == ERROR_SUCCESS)
	{
		USES_CONVERSION;
		LPOLESTR lpOleStr;
		StringFromCLSID(*pEntry->pclsid, &lpOleStr);
		LPTSTR lpsz = OLE2T(lpOleStr);

		lRes = key.Open(key, lpsz);
		if (lRes == ERROR_SUCCESS)
		{
			CString strDescription;
			strDescription.LoadString(IDS_CYCLOCOMPLEXVIEWER_DESCRIPTION);
			key.SetKeyValue(_T("Description"), strDescription);
		}
		CoTaskMemFree(lpOleStr);
	}
	if (lRes != ERROR_SUCCESS)
		hRes = HRESULT_FROM_WIN32(lRes);

	return hRes;
}

/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Entfernt Eintr�ge aus der Systemregistrierung

STDAPI DllUnregisterServer(void)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	HRESULT hRes = S_OK;
	_Module.UnregisterServer();
	return hRes;
}


/////////////////////////////////////////////////////////////////////////////
// Testlauf-Unterst�tzung

// GetLastErrorDescription wird in der Implementierung des Makros VERIFY_OK
//  verwendet, das in stdafx.h definiert ist.

#ifdef _DEBUG

void GetLastErrorDescription(CComBSTR& bstr)
{
	CComPtr<IErrorInfo> pErrorInfo;
	if (GetErrorInfo(0, &pErrorInfo) == S_OK)
		pErrorInfo->GetDescription(&bstr);
}

#endif //_DEBUG

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United Kingdom United Kingdom
I am a qualified Veterinary Surgeon who prefers treating computers with viruses than animals with viruses. I have recently completed a MEng German Informatics degree at the University of Reading with a 2:1. I also have the ISEB Foundation Certificate in Software Testing.

Currently I am umemployed and desparately looking for a job in the IT industry.

Comments and Discussions