7e9da13ed1d88d18b664b6a405243732a7c4122e
[reactos.git] / reactos / tools / rbuild / backend / backend.h
1 /*
2 * Copyright (C) 2005 Casper S. Hornstrup
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #pragma once
20
21 #include "../rbuild.h"
22
23 class Backend;
24
25 typedef Backend* BackendFactory ( Project& project,
26 Configuration& configuration );
27
28 class Backend
29 {
30 public:
31 class Factory
32 {
33 static std::map<std::string,Factory*>* factories;
34 static int ref;
35 std::string m_name;
36 std::string m_description;
37
38 protected:
39
40 Factory ( const std::string& name_, const std::string& description_ );
41 virtual ~Factory();
42
43 virtual Backend* operator() ( Project&,
44 Configuration& configuration ) = 0;
45
46 public:
47 static Backend* Create ( const std::string& name,
48 Project& project,
49 Configuration& configuration );
50
51 static std::map<std::string,Factory*>::iterator map_begin(void)
52 {
53 return factories->begin();
54 }
55
56 static std::map<std::string,Factory*>::iterator map_end(void)
57 {
58 return factories->end();
59 }
60
61 const char *Name(void) { return m_name.c_str(); }
62 const char *Description(void) { return m_description.c_str(); }
63 };
64
65 protected:
66 Backend ( Project& project,
67 Configuration& configuration );
68
69 public:
70 virtual ~Backend();
71
72 virtual std::string GetFullName ( const FileLocation& file ) const;
73 virtual std::string GetFullPath ( const FileLocation& file ) const;
74 virtual void Process () = 0;
75 Project& ProjectNode;
76 Configuration& configuration;
77 };