Click here to Skip to main content
16,005,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Question about assign a reference to an object? Pin
Joaquín M López Muñoz25-Apr-03 3:12
Joaquín M López Muñoz25-Apr-03 3:12 
GeneralRe: Question about assign a reference to an object? Pin
George225-Apr-03 3:28
George225-Apr-03 3:28 
GeneralRe: Question about assign a reference to an object? Pin
Joaquín M López Muñoz25-Apr-03 3:37
Joaquín M López Muñoz25-Apr-03 3:37 
GeneralRe: Question about assign a reference to an object? Pin
George225-Apr-03 4:18
George225-Apr-03 4:18 
QuestionInsert CPropertySheet in SplitterWnd? How? Pin
jensreichert25-Apr-03 2:54
jensreichert25-Apr-03 2:54 
AnswerRe: Insert CPropertySheet in SplitterWnd? How? Pin
Joan M25-Apr-03 3:22
professionalJoan M25-Apr-03 3:22 
AnswerRe: Insert CPropertySheet in SplitterWnd? How? Pin
Joan M25-Apr-03 3:31
professionalJoan M25-Apr-03 3:31 
GeneralAdd-in dll Pin
Cedric Moonen25-Apr-03 1:55
Cedric Moonen25-Apr-03 1:55 
Hello,

I have an applilcation wich requires several tools (but without knowing the existence of them). So, all of these tools are defined in a add-in dll and they all inherit from a common class (say CGenericTool).

This works fine but what I want to do now is that I want to produce several different dll depending of what tools the client require. So, in the dll I will have a function that 'tells' to the main application wich tools are available in it.

I have a "ToolFactory" class that produces the tools (based on the COM technology) and I want to ask this class wich tools it can produce. I want it to be very easy to add or remove tools. I though of something like this: in the file where the factory is define, I just have to add or remove the header file from the specified tool and the class would automatically knows about that!

Something like:
//ToolFactory.cpp: implementation of the CToolFactory class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ToolFactory.h"
#include "GenericTool.h"

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


/* Header files from the tools to be available from the dll:
#include "Tool1.h"
#include "Tool2.h"
...
...
*/


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CToolFactory::CToolFactory()
{

}

CToolFactory::~CToolFactory()
{

}

HRESULT CToolFactory::CreateTool(CGenericTool** ppObject, int ToolType)
{
	switch (ToolType)
	{
#ifdef TOOL1_H
	case TOOL1:
		*ppObject = new CTool1;
		return NO_ERROR;
#endif

#ifdef TOOL2_H
	case TOOL2:
		*ppObject = new CTool2;
		return NO_ERROR;
#endif

	default:
		return -1;
	}
	return NO_ERROR;
}

int GetToolAvailable()
{
	int Count = 0;

#ifdef TOOL1_H
	Count++;
#endif

#ifdef TOOL2_H
	Count++;
#endif

	return Count;
}


Do you think it's a good way to do this ?? Or do you know any better idea??
I'm waiting for all your suggestion and ideas Smile | :)

Moonen Cédric
GeneralBox and lines Pin
Rage25-Apr-03 1:47
professionalRage25-Apr-03 1:47 
GeneralRe: Box and lines Pin
Ravi Bhavnani25-Apr-03 11:01
professionalRavi Bhavnani25-Apr-03 11:01 
GeneralAccessign the document object in a CWebBrowser2 Pin
John Oliver25-Apr-03 1:26
John Oliver25-Apr-03 1:26 
Generalhelp peeking messages Pin
sandrineV25-Apr-03 0:12
sandrineV25-Apr-03 0:12 
GeneralRe: help peeking messages Pin
Rage25-Apr-03 3:49
professionalRage25-Apr-03 3:49 
QuestionHow to set WS_EX_TOPMOST style at runtime? Pin
julych24-Apr-03 23:27
julych24-Apr-03 23:27 
AnswerRe: How to set WS_EX_TOPMOST style at runtime? Pin
User 665825-Apr-03 1:02
User 665825-Apr-03 1:02 
GeneralChanging Menu at runtime Pin
JensB24-Apr-03 22:33
JensB24-Apr-03 22:33 
GeneralLong Template Declarations Pin
Makover24-Apr-03 21:49
Makover24-Apr-03 21:49 
GeneralRe: Long Template Declarations Pin
Joaquín M López Muñoz25-Apr-03 3:20
Joaquín M López Muñoz25-Apr-03 3:20 
GeneralRe: Long Template Declarations Pin
Makover25-Apr-03 4:20
Makover25-Apr-03 4:20 
GeneralRe: Long Template Declarations Pin
Joaquín M López Muñoz25-Apr-03 4:38
Joaquín M López Muñoz25-Apr-03 4:38 
QuestionHow to use vector.push_back correctly and efficiently? Pin
George224-Apr-03 19:04
George224-Apr-03 19:04 
AnswerRe: How to use vector.push_back correctly and efficiently? Pin
jhwurmbach24-Apr-03 20:28
jhwurmbach24-Apr-03 20:28 
GeneralRe: How to use vector.push_back correctly and efficiently? Pin
George224-Apr-03 20:55
George224-Apr-03 20:55 
GeneralRe: How to use vector.push_back correctly and efficiently? Pin
jhwurmbach24-Apr-03 21:25
jhwurmbach24-Apr-03 21:25 
GeneralRe: How to use vector.push_back correctly and efficiently? Pin
George224-Apr-03 22:02
George224-Apr-03 22:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.