OpenShot Library | libopenshot 0.3.3
Loading...
Searching...
No Matches
ProcessingController.h
Go to the documentation of this file.
1
10// Copyright (c) 2008-2019 OpenShot Studios, LLC
11//
12// SPDX-License-Identifier: LGPL-3.0-or-later
13
14#ifndef OPENSHOT_PROCESSINGCONTROLLER_H
15#define OPENSHOT_PROCESSINGCONTROLLER_H
16
17#include <mutex>
18#include <string>
19
21 private:
22 uint processingProgress;
23 bool processingFinished;
24 bool stopProcessing;
25 bool error = true;
26 std::string error_message;
27
28 std::mutex mtxProgress;
29 std::mutex mtxFinished;
30 std::mutex mtxStop;
31 std::mutex mtxerror;
32
33 public:
34
36 processingProgress = 0;
37 stopProcessing = false;
38 processingFinished = false;
39 }
40
42 std::lock_guard<std::mutex> lck (mtxFinished);
43 bool f = processingFinished;
44 return f;
45 }
46
47 void SetFinished(bool f){
48 std::lock_guard<std::mutex> lck (mtxFinished);
49 processingFinished = f;
50 }
51
52 void SetProgress(uint p){
53 std::lock_guard<std::mutex> lck (mtxProgress);
54 processingProgress = p;
55 }
56
58 std::lock_guard<std::mutex> lck (mtxProgress);
59 uint p = processingProgress;
60 return p;
61 }
62
64 std::lock_guard<std::mutex> lck (mtxStop);
65 stopProcessing = true;
66 }
67
68 bool ShouldStop(){
69 std::lock_guard<std::mutex> lck (mtxStop);
70 bool s = stopProcessing;
71 return s;
72 }
73
74 void SetError(bool err, std::string message){
75 std::lock_guard<std::mutex> lck (mtxerror);
76 error = err;
77 error_message = message;
78 }
79
80 bool GetError(){
81 std::lock_guard<std::mutex> lck (mtxerror);
82 bool e = error;
83 return e;
84 }
85
86 std::string GetErrorMessage(){
87 std::lock_guard<std::mutex> lck (mtxerror);
88 std::string message = error_message;
89 return message;
90 }
91
92};
93
94#endif
void SetError(bool err, std::string message)