xref: /haiku/src/servers/launch/BaseJob.h (revision 8a6724a0ee3803f1e9f487d8111bb3f6cb8d16db)
1 /*
2  * Copyright 2015, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef BASE_JOB_H
6 #define BASE_JOB_H
7 
8 
9 #include <Job.h>
10 #include <StringList.h>
11 
12 
13 using namespace BSupportKit;
14 
15 class BMessage;
16 class Condition;
17 class ConditionContext;
18 class Event;
19 
20 
21 class BaseJob : public BJob {
22 public:
23 								BaseJob(const char* name);
24 								~BaseJob();
25 
26 			const char*			Name() const;
27 
28 			const ::Condition*	Condition() const;
29 			::Condition*		Condition();
30 			void				SetCondition(::Condition* condition);
31 	virtual	bool				CheckCondition(ConditionContext& context) const;
32 
33 			const ::Event*		Event() const;
34 			::Event*			Event();
35 			void				SetEvent(::Event* event);
36 			bool				EventHasTriggered() const;
37 
38 			const BStringList&	Environment() const;
39 			BStringList&		Environment();
40 			const BStringList&	EnvironmentSourceFiles() const;
41 			BStringList&		EnvironmentSourceFiles();
42 			void				SetEnvironment(const BMessage& message);
43 
44 			void				GetSourceFilesEnvironment(
45 									BStringList& environment);
46 			void				ResolveSourceFiles();
47 
48 private:
49 			void				_GetSourceFileEnvironment(const char* script,
50 									BStringList& environment);
51 			void				_ParseExportVariable(BStringList& environment,
52 									const BString& line);
53 
54 protected:
55 			::Condition*		fCondition;
56 			::Event*			fEvent;
57 			BStringList			fEnvironment;
58 			BStringList			fSourceFiles;
59 };
60 
61 
62 #endif // BASE_JOB_H
63