mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 07:12:59 +00:00
62 lines
1.3 KiB
C++
62 lines
1.3 KiB
C++
|
|
#include "../pch.h"
|
|
|
|
#include "../rbuild.h"
|
|
#include "backend.h"
|
|
|
|
using std::string;
|
|
using std::vector;
|
|
using std::map;
|
|
|
|
map<string,Backend::Factory*>*
|
|
Backend::Factory::factories = NULL;
|
|
int
|
|
Backend::Factory::ref = 0;
|
|
|
|
Backend::Factory::Factory ( const std::string& name_ )
|
|
{
|
|
string name(name_);
|
|
strlwr ( &name[0] );
|
|
if ( !ref++ )
|
|
factories = new map<string,Factory*>;
|
|
(*factories)[name] = this;
|
|
}
|
|
|
|
Backend::Factory::~Factory ()
|
|
{
|
|
if ( !--ref )
|
|
{
|
|
delete factories;
|
|
factories = NULL;
|
|
}
|
|
}
|
|
|
|
/*static*/ Backend*
|
|
Backend::Factory::Create ( const string& name,
|
|
Project& project,
|
|
bool verbose,
|
|
bool cleanAsYouGo )
|
|
{
|
|
string sname ( name );
|
|
strlwr ( &sname[0] );
|
|
if ( !factories || !factories->size () )
|
|
throw InvalidOperationException ( __FILE__,
|
|
__LINE__,
|
|
"No registered factories" );
|
|
Backend::Factory* f = (*factories)[sname];
|
|
if ( !f )
|
|
{
|
|
throw UnknownBackendException ( sname );
|
|
return NULL;
|
|
}
|
|
return (*f) ( project, verbose, cleanAsYouGo );
|
|
}
|
|
|
|
Backend::Backend ( Project& project,
|
|
bool verbose,
|
|
bool cleanAsYouGo )
|
|
: ProjectNode ( project ),
|
|
verbose ( verbose ),
|
|
cleanAsYouGo ( cleanAsYouGo )
|
|
{
|
|
}
|