source: launchers/macosx/obj-cpp/RouterTask.h @ c8490a3

Last change on this file since c8490a3 was c8490a3, checked in by meeh <meeh@…>, 2 years ago

Starting to get stable and usable. Basically everything is based on callbacks.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#pragma once
2
3#include <dispatch/dispatch.h>
4#include <functional>
5#include <memory>
6#include <string>
7#include <vector>
8
9#include <Cocoa/Cocoa.h>
10#import <AppKit/AppKit.h>
11
12#include "optional.hpp"
13#include "subprocess.hpp"
14
15
16@class RTaskOptions;
17
18@interface RTaskOptions : NSObject
19@property (strong) NSString* binPath;
20@property (strong) NSArray<NSString *>* arguments;
21@property (strong) NSString* i2pBaseDir;
22@end
23
24@class RouterTask;
25
26@interface RouterTask : NSObject
27@property (strong) NSTask* routerTask;
28@property (strong) NSUserDefaults *userPreferences;
29@property (strong) NSFileHandle *readLogHandle;
30@property (strong) NSMutableData *totalLogData;
31@property (strong) NSPipe *processPipe;
32@property (strong) NSFileHandle *input;
33@property (atomic) BOOL userRequestedRestart;
34- (instancetype) initWithOptions : (RTaskOptions*) options;
35- (int) execute;
36- (void) requestShutdown;
37- (void) requestRestart;
38- (BOOL) isRunning;
39- (int) getPID;
40@end
41
42
43
44using namespace subprocess;
45
46class JavaRunner;
47
48typedef std::function<void(void)> fp_t;
49typedef std::function<void(JavaRunner *ptr)> fp_proc_t;
50
51/**
52 *
53 * class JavaRunner
54 *
55 **/
56class JavaRunner
57{
58public:
59  // copy fn
60  JavaRunner(std::string& javaBin, std::string& arguments, std::string& i2pBaseDir, const fp_proc_t& executingFn, const fp_t& cb);
61  ~JavaRunner() = default;
62
63  static const std::vector<NSString*> defaultStartupFlags;
64  static const std::vector<std::string> defaultFlagsForExtractorJob;
65
66  void requestRouterShutdown();
67
68  std::experimental::optional<std::future<int> > execute();
69  std::shared_ptr<Popen> javaProcess;
70  std::string javaBinaryPath;
71  std::string javaRouterArgs;
72  std::string execLine;
73  std::string _i2pBaseDir;
74private:
75  const fp_proc_t& executingFn;
76  const fp_t& exitCallbackFn;
77};
78
79
Note: See TracBrowser for help on using the repository browser.