1// 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 13#include "chromeos-dbus-bindings/header_generator.h" 14#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 27class AdaptorGenerator : public HeaderGenerator { 28 public: 29 static bool GenerateAdaptors(const std::vector<Interface>& interfaces, 30 const base::FilePath& output_file); 31 32 private: 33 friend class AdaptorGeneratorTest; 34 35 // 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 43 // Generates the constructor for the adaptor. 44 static void AddConstructor(const std::string& class_name, 45 const std::string& itf_name, 46 IndentedText *text); 47 48 // 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); 57 58 // 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 66 // Generates adaptor accessor methods for the properties. 67 static void AddPropertyMethodImplementation(const Interface& interface, 68 IndentedText *text); 69 70 // Generate ExportProperty data members for the properties. 71 static void AddPropertyDataMembers(const Interface& interface, 72 IndentedText *text); 73 74 DISALLOW_COPY_AND_ASSIGN(AdaptorGenerator); 75}; 76 77} // namespace chromeos_dbus_bindings 78 79#endif // CHROMEOS_DBUS_BINDINGS_ADAPTOR_GENERATOR_H_ 80