summaryrefslogtreecommitdiffabout
path: root/include/sitecing/component_factory.h
blob: 9ddf70db2f92f7229700cdbea7b7a6465477a468 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef __SITECING_COMPONENT_FACTORY_H
#define __SITECING_COMPONENT_FACTORY_H

#include <string>
#include <list>
#include <stdexcept>
#include "sitecing/file_factory.h"
#include "sitecing/configuration.h"

/**
 * @file
 * @brief The component_factory class declaration.
 */

namespace sitecing {
    using namespace std;

    /**
     * @brief The components builder.
     */
    class component_factory : public file_factory {
	public:
	    /**
	     * Path to the source files root.
	     */
	    string root_source;
	    /**
	     * Path to the root of the intermediate files storage.
	     */
	    string root_intermediate;
	    /**
	     * Output path for .so components.
	     */
	    string root_so;
	    /**
	     * Reference to the configuration container.
	     */
	    configuration& config;

	    /**
	     * @param c reference to the configuration container.
	     */
	    component_factory(configuration& c);

	    /**
	     * @overload file_factory::get_dependencies()
	     */
	    virtual void get_dependencies(const string& dst,file_list_t& deps);
	    /**
	     * @overload file_factory::is_uptodate()
	     */
	    virtual bool is_uptodate(const string& dst,file_list_t *deps=NULL);
	    /**
	     * @overload file_factory::build()
	     */
	    virtual void build(const string& dst);
	    /**
	     * @overload file_factory::make()
	     */
	    virtual void make(const string& dst);

	    /**
	     * Helper function for executing external command.
	     * @param cmd the command to execute.
	     * @param args the command line arguments.
	     * @param stdo stdout for the child process.
	     * @param stde stderr for the child process.
	     * @return exit code.
	     */
	    int execute(const string& cmd,const list<string>& args,int stdo,int stde);
	    /**
	     * Fetch the class name of the component.
	     * @param component the component.
	     * @return the class name.
	     */
	    string get_classname(const string& component);
	    /**
	     * Get the components from which the target component has been
	     * derived.
	     * @param component the target component
	     * @param rv where to store the list of ancestors.
	     */
	    void get_ancestors(const string& component,file_list_t &rv);
    };

}

#endif /* __SITECING_COMPONENT_FACTORY_H */