File: ProcessingController.h

package info (click to toggle)
libopenshot 0.5.0%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,228 kB
  • sloc: cpp: 32,692; python: 92; sh: 67; makefile: 21; ruby: 5
file content (94 lines) | stat: -rw-r--r-- 2,171 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
 * @file
 * @brief This is a message class for thread safe comunication between ClipProcessingJobs and OpenCV classes
 * @author Jonathan Thomas <jonathan@openshot.org>
 * @author Brenno Caldato <brenno.caldato@outlook.com>
 *
 * @ref License
 */

// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#ifndef OPENSHOT_PROCESSINGCONTROLLER_H
#define OPENSHOT_PROCESSINGCONTROLLER_H

#include <mutex>
#include <string>

class ProcessingController{
    private:
        uint processingProgress;
        bool processingFinished;
        bool stopProcessing;
        bool error = true;
        std::string error_message;

        std::mutex mtxProgress;
        std::mutex mtxFinished;
        std::mutex mtxStop;
        std::mutex mtxerror;

	public:

    ProcessingController(){
        processingProgress = 0;
        stopProcessing = false;
        processingFinished = false;
    }

    int GetFinished(){
        std::lock_guard<std::mutex> lck (mtxFinished);
        bool f = processingFinished;
        return f;
    }

    void SetFinished(bool f){
        std::lock_guard<std::mutex> lck (mtxFinished);
        processingFinished = f;
    }

    void SetProgress(uint p){
        std::lock_guard<std::mutex> lck (mtxProgress);
        processingProgress = p;
    }

    int GetProgress(){
        std::lock_guard<std::mutex> lck (mtxProgress);
        uint p = processingProgress;
        return p;
    }

    void CancelProcessing(){
        std::lock_guard<std::mutex> lck (mtxStop);
        stopProcessing = true;
    }

    bool ShouldStop(){
        std::lock_guard<std::mutex> lck (mtxStop);
        bool s = stopProcessing;
        return s;
    }

    void SetError(bool err, std::string message){
        std::lock_guard<std::mutex> lck (mtxerror);
        error = err;
        error_message = message;
    }

    bool GetError(){
        std::lock_guard<std::mutex> lck (mtxerror);
        bool e = error;
        return e;
    }

    std::string GetErrorMessage(){
        std::lock_guard<std::mutex> lck (mtxerror);
        std::string message = error_message;
        return message;
    }

};

#endif