~ubuntu-branches/ubuntu/trusty/hugin/trusty-proposed

« back to all changes in this revision

Viewing changes to src/hugin_base/makefilelib/Rule.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2011-01-06 14:28:24 UTC
  • mfrom: (1.1.9 upstream) (0.1.21 experimental)
  • Revision ID: james.westby@ubuntu.com-20110106142824-zn9lxylg5z44dynn
* Drop Cyril Brulebois from Uploaders. Thank you very much for your work.
* Bump package version. (rc3 was re-released as 2010.4.0).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
This file is part of hugin.
 
3
 
 
4
hugin 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
hugin 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
 
15
along with hugin.  If not, see <http://www.gnu.org/licenses/>.
 
16
*/
 
17
 
 
18
/**
 
19
 * @file Rule.h
 
20
 * @brief
 
21
 *  Created on: May 25, 2010
 
22
 * @author Florian Achleitner <florian.achleitner.2.6.31@gmail.com>
 
23
 */
 
24
 
 
25
#ifndef RULE_H_
 
26
#define RULE_H_
 
27
 
 
28
#include "MakefileItem.h"
 
29
#include "Variable.h"
 
30
#include "VariableRef.h"
 
31
 
 
32
#include <vector>
 
33
 
 
34
namespace makefile
 
35
{
 
36
 
 
37
/**
 
38
 * Represents a makefile rule, including Prerequisite and Command.
 
39
 *
 
40
 */
 
41
class MAKEIMPEX Rule : public PrimaryMakefileItem
 
42
{
 
43
        std::vector<string> targets;
 
44
        std::vector<string> prerequisites;
 
45
        std::vector<string> commands;
 
46
 
 
47
public:
 
48
        Rule()
 
49
        {}
 
50
        virtual ~Rule()
 
51
        {}
 
52
 
 
53
        virtual string toString();
 
54
 
 
55
        /**
 
56
         * Adds a target string.
 
57
         * @param t
 
58
         */
 
59
        void addTarget(const string& t)
 
60
        {
 
61
                targets.push_back(t);
 
62
        }
 
63
        /**
 
64
         * Adds a Variable as a Target. A VariableRef is taken from the Variable and added.
 
65
         * @param t
 
66
         */
 
67
        void addTarget(Variable& t)
 
68
        {
 
69
                addTarget(t.getRef().toString());
 
70
        }
 
71
        void addTarget(Variable* t)
 
72
        {
 
73
                addTarget(t->getRef().toString());
 
74
        }
 
75
        /**
 
76
         * Adds a string as a prerequisite.
 
77
         * @param p
 
78
         */
 
79
        void addPrereq(string p)
 
80
        {
 
81
                prerequisites.push_back(p);
 
82
        }
 
83
        /**
 
84
         * Adds a Variable as a prerequisite. A VariableRef is taken from the Variable and added.
 
85
         * @param p
 
86
         */
 
87
        void addPrereq(Variable& p)
 
88
        {
 
89
                addPrereq(p.getRef().toString());
 
90
        }
 
91
        void addPrereq(Variable* p)
 
92
        {
 
93
                addPrereq(p->getRef().toString());
 
94
        }
 
95
    /** Adds an other rule as a prerequisite for this rule */
 
96
    void addPrereq(Rule& r)
 
97
    {
 
98
        for(std::vector<string>::iterator i = r.targets.begin(); i != r.targets.end(); i++)
 
99
        {
 
100
            addPrereq(*i);
 
101
        }
 
102
    };
 
103
    void addPrereq(Rule* r)
 
104
    {
 
105
        addPrereq(*r);
 
106
    };
 
107
        /**
 
108
         * Adds a string as a command to the Rule.
 
109
         * @param c
 
110
         */
 
111
        void addCommand(string c,bool doEcho=true,bool ignoreErrors=false)
 
112
        {
 
113
        string command;
 
114
        if(!doEcho)
 
115
        {
 
116
            command="@";
 
117
        };
 
118
        if(ignoreErrors)
 
119
        {
 
120
            command.append("-");
 
121
        };
 
122
        command.append(c);
 
123
        commands.push_back(command);
 
124
        }
 
125
};
 
126
 
 
127
}
 
128
 
 
129
#endif /* RULE_H_ */