File: AsyncPluginValidator.h

package info (click to toggle)
audacity 3.7.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 125,252 kB
  • sloc: cpp: 358,238; ansic: 75,458; lisp: 7,761; sh: 3,410; python: 1,503; xml: 1,385; perl: 854; makefile: 122
file content (73 lines) | stat: -rw-r--r-- 2,366 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
/**********************************************************************

  Audacity: A Digital Audio Editor

  @file AsyncPluginValidator.h

  @author Vitaly Sverchinsky

  Part of lib-module-manager library

**********************************************************************/

#pragma once

#include <chrono>
#include <memory>

#include <wx/string.h>

class PluginDescriptor;


/**
 * \brief Starts and communicates with a dedicated process to perform
 * plugin validation. Once instantiated, client should call
 * AsyncPluginValidation::Validate for plugin that needs to be validated.
 * When done, AsyncPluginValidation will notify caller via Delegate on the
 * UI thread (requires event loop). After Delegate::OnValidationFinished
 * is called procedure can be repeated with another plugin id.
 */
class MODULE_MANAGER_API AsyncPluginValidator final
{
   class Impl;
   std::shared_ptr<Impl> mImpl;
public:
   /**
    * \brief Used to talk back to calling side
    */
   class MODULE_MANAGER_API Delegate
   {
   public:
      virtual ~Delegate();

      ///Called for each plugin instance found inside module
      virtual void OnPluginFound(const PluginDescriptor& plugin) = 0;
      virtual void OnPluginValidationFailed(const wxString& providerId, const wxString& path) = 0;
      ///Called when module processing finished
      virtual void OnValidationFinished() = 0;
      ///Called on error, further processing is not possible.
      virtual void OnInternalError(const wxString& msg) = 0;
   };

   AsyncPluginValidator(AsyncPluginValidator&) = delete;
   AsyncPluginValidator(AsyncPluginValidator&&) = delete;
   AsyncPluginValidator& operator=(AsyncPluginValidator&) = delete;
   AsyncPluginValidator& operator=(AsyncPluginValidator&&) = delete;

   explicit AsyncPluginValidator(Delegate& delegate);
   ~AsyncPluginValidator();

   void SetDelegate(Delegate* delegate);

   std::chrono::system_clock::time_point InactiveSince() const noexcept;

   /**
    * \brief Each call to Validate should result in appropriate call
    * OnValidationFinished, until then it's not allowed to call this
    * method again. May fail with exception.
    * \param providerId ID of the provider that should be used for validation
    * \param pluginPath path to the plugin module
    */
   void Validate(const wxString& providerId, const wxString& pluginPath);
};