Factories for Backend creation
[reactos.git] / reactos / tools / rbuild / backend / backend.cpp
1
2 #include "../pch.h"
3
4 #include "../Rbuild.h"
5 #include "backend.h"
6
7 #include "mingw/mingw.h"
8
9 using std::string;
10 using std::vector;
11
12 vector<Backend::Factory*> Backend::factories;
13
14 /*static*/ void
15 Backend::InitFactories()
16 {
17 factories.push_back ( new Factory ( "mingw", MingwBackend::Factory ) );
18 }
19
20 /*static*/ Backend*
21 Backend::Create ( const std::string& name, Project& project )
22 {
23 string sname ( name );
24 strlwr ( &sname[0] );
25 if ( !factories.size() )
26 throw Exception ( "internal tool error: no registered factories" );
27 for ( size_t i = 0; i < factories.size(); i++ )
28 {
29 if ( sname == factories[i]->name )
30 return (factories[i]->factory) ( project );
31 }
32 throw UnknownBackendException ( sname );
33 return NULL;
34 }
35
36 Backend::Backend ( Project& project )
37 : ProjectNode ( project )
38 {
39 }