platform_object.h 988 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2014 The Chromium 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. #ifndef UI_OZONE_PLATFORM_OBJECT_H_
  5. #define UI_OZONE_PLATFORM_OBJECT_H_
  6. #include <memory>
  7. namespace ui {
  8. // Create an instance of platform specific object.
  9. //
  10. // This calls a static constructor function based on the --ozone-platform flag.
  11. //
  12. // For the platform called "foo", PlatformObject<PlatformWidget> will ultimately
  13. // call the function with signature
  14. //
  15. // PlatformWidget* CreatePlatformWidgetFoo();
  16. //
  17. // A definition of this function for each compiled platform must be provided, or
  18. // link errors will result.
  19. //
  20. // To find the right constructor function, this uses static data defined in the
  21. // source file generated by the generate_constructor_list.py.
  22. template <class T>
  23. class PlatformObject {
  24. public:
  25. static std::unique_ptr<T> Create();
  26. };
  27. } // namespace ui
  28. #endif // UI_OZONE_PLATFORM_OBJECT_H_