summaryrefslogtreecommitdiffabout
path: root/include/sitecing/file_factory.h
blob: f23682fd66853755492fe009efee1917bc2f72e2 (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
#ifndef __SITECING_FILE_FACTORY_H
#define __SITECING_FILE_FACTORY_H

#include <string>
#include <list>

/**
 * @file
 * @brief the file_factory class declaration.
 */

namespace sitecing {
    using namespace std;

    /**
     * The factory class. Does the job similar to that which is done by make
     * utility.
     */
    class file_factory {
	public:
	    /**
	     * The recursion depth.
	     */
	    int depth;
	    /**
	     * The list of files type. The list of strings, in fact.
	     */
	    typedef list<string> file_list_t;

	    file_factory()
		: depth(0) { }

	    /**
	     * Fetch dependencies for the given file.
	     * @param dst the destination file.
	     * @param deps where to put dependencies to.
	     */
	    virtual void get_dependencies(const string& dst,file_list_t& deps) = 0;
	    /**
	     * Check if the destination is up to day.
	     * @param dst the destination file.
	     * @param deps if the deps pointer is non there, the dependencies
	     * retrieved will be stored there.
	     * @return true if yes.
	     * @see get_dependencies()
	     */
	    virtual bool is_uptodate(const string& dst,file_list_t* deps=0);
	    /**
	     * Build the file requested.
	     * @param dst the file requested.
	     */
	    virtual void build(const string& dst) = 0;
	    /**
	     * Make the file requested, which means: build it, unless it's
	     * uptodate.
	     * @see is_uptodate()
	     * @see build()
	     */
	    virtual void make(const string& dst);
    };

}

#endif /* __SITECING_FILE_FACTORY_H */