blob: 57e2bf502be14eb9de4a01701e1d819df26d7ad7 [file] [log] [blame]
Paul Stewartb9b3f9d2014-09-10 15:12:39 -07001// Copyright 2014 The Chromium OS 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 CHROMEOS_DBUS_BINDINGS_ADAPTOR_GENERATOR_H_
6#define CHROMEOS_DBUS_BINDINGS_ADAPTOR_GENERATOR_H_
7
8#include <string>
9#include <vector>
10
11#include <base/macros.h>
12
Paul Stewart1dce1ae2014-10-01 05:30:18 -070013#include "chromeos-dbus-bindings/header_generator.h"
Paul Stewartb9b3f9d2014-09-10 15:12:39 -070014#include "chromeos-dbus-bindings/indented_text.h"
15
16namespace base {
17
18class FilePath;
19
20} // namespace base
21
22namespace chromeos_dbus_bindings {
23
24class IndentedText;
25struct Interface;
26
Paul Stewart1dce1ae2014-10-01 05:30:18 -070027class AdaptorGenerator : public HeaderGenerator {
Paul Stewartb9b3f9d2014-09-10 15:12:39 -070028 public:
Alex Vakulenkofafef132014-11-03 14:52:09 -080029 static bool GenerateAdaptors(const std::vector<Interface>& interfaces,
30 const base::FilePath& output_file);
Paul Stewartb9b3f9d2014-09-10 15:12:39 -070031
32 private:
33 friend class AdaptorGeneratorTest;
34
Alex Vakulenkofafef132014-11-03 14:52:09 -080035 // Generates one interface adaptor.
36 static void GenerateInterfaceAdaptor(const Interface& interface,
37 IndentedText *text);
38
39 // Generates the method prototypes for an interface declaration.
40 static void AddInterfaceMethods(const Interface& interface,
41 IndentedText *text);
42
Paul Stewartb9b3f9d2014-09-10 15:12:39 -070043 // Generates the constructor for the adaptor.
Alex Vakulenkofafef132014-11-03 14:52:09 -080044 static void AddConstructor(const std::string& class_name,
45 const std::string& itf_name,
Paul Stewartb9b3f9d2014-09-10 15:12:39 -070046 IndentedText *text);
47
Alex Vakulenkofafef132014-11-03 14:52:09 -080048 // Generates RegisterWithDBusObject() method.
49 static void AddRegisterWithDBusObject(const std::string& itf_name,
50 const Interface& interface,
51 IndentedText *text);
52
53 // Generates the code to register the interface with a D-Bus object.
54 static void RegisterInterface(const std::string& itf_name,
55 const Interface& interface,
56 IndentedText *text);
Paul Stewartb9b3f9d2014-09-10 15:12:39 -070057
Alex Deymob19e92f2014-10-23 23:04:11 -070058 // Generates adaptor methods to send the signals.
59 static void AddSendSignalMethods(const Interface& interface,
60 IndentedText *text);
61
62 // Generates DBusSignal data members for the signals.
63 static void AddSignalDataMembers(const Interface& interface,
64 IndentedText *text);
65
Peter Qiudd885752014-11-02 16:00:46 -080066 // Generates adaptor accessor methods for the properties.
Alex Vakulenkofafef132014-11-03 14:52:09 -080067 static void AddPropertyMethodImplementation(const Interface& interface,
68 IndentedText *text);
Peter Qiudd885752014-11-02 16:00:46 -080069
70 // Generate ExportProperty data members for the properties.
71 static void AddPropertyDataMembers(const Interface& interface,
72 IndentedText *text);
73
Paul Stewartb9b3f9d2014-09-10 15:12:39 -070074 DISALLOW_COPY_AND_ASSIGN(AdaptorGenerator);
75};
76
77} // namespace chromeos_dbus_bindings
78
79#endif // CHROMEOS_DBUS_BINDINGS_ADAPTOR_GENERATOR_H_