Job.h revision a1ead48a4e9961c7eb22592310c7e9c30cb56794
1//===--- Job.h - Commands to Execute ----------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef CLANG_DRIVER_JOB_H_ 11#define CLANG_DRIVER_JOB_H_ 12 13#include "clang/Driver/Util.h" 14#include "llvm/ADT/SmallVector.h" 15 16#include "llvm/Support/Casting.h" 17using llvm::isa; 18using llvm::cast; 19using llvm::cast_or_null; 20using llvm::dyn_cast; 21using llvm::dyn_cast_or_null; 22 23namespace clang { 24namespace driver { 25 26class Job { 27public: 28 enum JobClass { 29 CommandClass, 30 PipedJobClass, 31 JobListClass 32 }; 33 34private: 35 JobClass Kind; 36 37protected: 38 Job(JobClass _Kind) : Kind(_Kind) {} 39public: 40 virtual ~Job(); 41 42 JobClass getKind() const { return Kind; } 43 44 static bool classof(const Job *) { return true; } 45}; 46 47 /// Command - An executable path/name and argument vector to 48 /// execute. 49class Command : public Job { 50 const char *Executable; 51 ArgStringList Argv; 52 53public: 54 Command(const char *_Executable, const ArgStringList &_Argv); 55 56 const char *getExecutable() const { return Executable; } 57 const ArgStringList &getArgv() const { return Argv; } 58 59 static bool classof(const Job *J) { 60 return J->getKind() == CommandClass; 61 } 62 static bool classof(const Command *) { return true; } 63}; 64 65 /// PipedJob - A list of Commands which should be executed together 66 /// with their standard inputs and outputs connected. 67class PipedJob : public Job { 68public: 69 typedef llvm::SmallVector<Command*, 4> list_type; 70 71private: 72 list_type Commands; 73 74public: 75 PipedJob(); 76 77 void addCommand(Command *C) { Commands.push_back(C); } 78 79 const list_type &getCommands() const { return Commands; } 80 81 static bool classof(const Job *J) { 82 return J->getKind() == PipedJobClass; 83 } 84 static bool classof(const PipedJob *) { return true; } 85}; 86 87 /// JobList - A sequence of jobs to perform. 88class JobList : public Job { 89public: 90 typedef llvm::SmallVector<Job*, 4> list_type; 91 92private: 93 list_type Jobs; 94 95public: 96 JobList(); 97 98 void addJob(Job *J) { Jobs.push_back(J); } 99 100 const list_type &getJobs() const { return Jobs; } 101 102 static bool classof(const Job *J) { 103 return J->getKind() == JobListClass; 104 } 105 static bool classof(const JobList *) { return true; } 106}; 107 108} // end namespace driver 109} // end namespace clang 110 111#endif 112