Rule.h

Go to the documentation of this file.
00001 /*
00002 This file is part of hugin.
00003 
00004 hugin is free software: you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation, either version 2 of the License, or
00007 (at your option) any later version.
00008 
00009 hugin is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with hugin.  If not, see <http://www.gnu.org/licenses/>.
00016 */
00017 
00025 #ifndef RULE_H_
00026 #define RULE_H_
00027 
00028 #include "MakefileItem.h"
00029 #include "Variable.h"
00030 #include "VariableRef.h"
00031 
00032 #include <vector>
00033 
00034 namespace makefile
00035 {
00036 
00041 class MAKEIMPEX Rule : public PrimaryMakefileItem
00042 {
00043         std::vector<string> targets;
00044         std::vector<string> prerequisites;
00045         std::vector<string> commands;
00046 
00047 public:
00048         Rule()
00049         {}
00050         virtual ~Rule()
00051         {}
00052 
00053         virtual string toString();
00054 
00059         void addTarget(const string& t)
00060         {
00061                 targets.push_back(t);
00062         }
00067         void addTarget(Variable& t)
00068         {
00069                 addTarget(t.getRef().toString());
00070         }
00071         void addTarget(Variable* t)
00072         {
00073                 addTarget(t->getRef().toString());
00074         }
00079         void addPrereq(string p)
00080         {
00081                 prerequisites.push_back(p);
00082         }
00087         void addPrereq(Variable& p)
00088         {
00089                 addPrereq(p.getRef().toString());
00090         }
00091         void addPrereq(Variable* p)
00092         {
00093                 addPrereq(p->getRef().toString());
00094         }
00096     void addPrereq(Rule& r)
00097     {
00098         for(std::vector<string>::iterator i = r.targets.begin(); i != r.targets.end(); i++)
00099         {
00100             addPrereq(*i);
00101         }
00102     };
00103     void addPrereq(Rule* r)
00104     {
00105         addPrereq(*r);
00106     };
00111         void addCommand(string c,bool doEcho=true,bool ignoreErrors=false)
00112         {
00113         string command;
00114         if(!doEcho)
00115         {
00116             command="@";
00117         };
00118         if(ignoreErrors)
00119         {
00120             command.append("-");
00121         };
00122         command.append(c);
00123         commands.push_back(command);
00124         }
00125 };
00126 
00127 }
00128 
00129 #endif /* RULE_H_ */

Generated on 5 Dec 2014 for Hugintrunk by  doxygen 1.4.7