reactos/reactos/tools/rbuild/backend/backend.cpp
Casper Hornstrup ae18ba571a Set svn:eol-style=native
svn path=/branches/xmlbuildsystem/; revision=15035
2005-05-06 10:38:30 +00:00

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 )
{
}