Flutter Engine
flutter_engine.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_ENGINE_H_
6 #define FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_ENGINE_H_
7 
8 #include <flutter_glfw.h>
9 
10 #include <chrono>
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include "plugin_registrar.h"
16 #include "plugin_registry.h"
17 
18 namespace flutter {
19 
20 // An engine for running a headless Flutter application.
21 class FlutterEngine : public PluginRegistry {
22  public:
23  explicit FlutterEngine();
24 
25  virtual ~FlutterEngine();
26 
27  // Prevent copying.
28  FlutterEngine(FlutterEngine const&) = delete;
29  FlutterEngine& operator=(FlutterEngine const&) = delete;
30 
31  // Starts running the engine with the given parameters, returning true if
32  // successful.
33  bool Start(const std::string& icu_data_path,
34  const std::string& assets_path,
35  const std::vector<std::string>& arguments,
36  const std::string& aot_library_path = "");
37 
38  // Terminates the running engine.
39  void ShutDown();
40 
41  // Processes the next event for the engine, or returns early if |timeout| is
42  // reached before the next event.
44  std::chrono::milliseconds timeout = std::chrono::milliseconds::max());
45 
46  // flutter::PluginRegistry:
48  const std::string& plugin_name) override;
49 
50  private:
51  using UniqueEnginePtr = std::unique_ptr<FlutterDesktopEngineState,
52  bool (*)(FlutterDesktopEngineState*)>;
53 
54  // Handle for interacting with the C API's engine reference.
55  UniqueEnginePtr engine_ =
56  UniqueEnginePtr(nullptr, FlutterDesktopShutDownEngine);
57 };
58 
59 } // namespace flutter
60 
61 #endif // FLUTTER_SHELL_PLATFORM_GLFW_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_ENGINE_H_
FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin(const std::string &plugin_name) override
bool FlutterDesktopShutDownEngine(FlutterDesktopEngineRef engine_ref)
FlutterEngine & operator=(FlutterEngine const &)=delete
bool Start(const std::string &icu_data_path, const std::string &assets_path, const std::vector< std::string > &arguments, const std::string &aot_library_path="")
void RunEventLoopWithTimeout(std::chrono::milliseconds timeout=std::chrono::milliseconds::max())