2.2.4.38.11 Project::CreateClass

Description

Create an object of a registered type class [in the specified file and compile and link it as needed] [and can optionally compile and link dependent file] Consecutive calls made to FindClass returns a reference to a new instance of the same type

Syntax

ClassObject CreateClass( LPCSTR lpcszName, LPCSTR lpcszPath = NULL, BOOL bCompileDependents = TRUE, BOOL bAutoDelete = TRUE )

Parameters

lpcszName
[input]Name of the registered class type
lpcszPath
[input]Optional input of file path, if NULL no files are loaded
bCompileDependents
[input]Optional input causes dependent files (intelligently composed from include directives in the main .c[pp] file)
to be compiled and linked
bAutoDelete
[input, optional] When True, the created object will get deleted when all reference to it goes out of scope, hence not safe to keep a pointer to it. Should be FALSE if the intent is to hold a pointer to it and then should later destroy the object by calling delete on the pointer.

Return

Returns a ClassObject if successfull (can use NULL comparison) can be casted to a refrence to the desired type.

Examples

void Project_CreateClass_Ex1()
{
	string strFilename = GetAppPath(true) + "OriginC\\Originlab\\FitNL.cpp";
	
 	OperationBase& op = (OperationBase&) Project.CreateClass("FitNL", strFilename);
	if( NULL == op)
		printf("Fail to create class object of FitNL");
	
	op.CreateInternal();
	bool bInitOK = op.Init();
	if ( bInitOK )
		printf("Operation init successfully");
	else
		printf("Fail to init operation");
	return;
}

Remark

See Also

Project::FindClass

Header to Include

origin.h