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_INTERFACE_H_
6 #define CHROMEOS_DBUS_BINDINGS_INTERFACE_H_
7 
8 #include <string>
9 #include <vector>
10 
11 namespace chromeos_dbus_bindings {
12 
13 struct Interface {
14   struct Argument {
ArgumentInterface::Argument15     Argument(const std::string& name_in,
16              const std::string& type_in) : name(name_in), type(type_in) {}
17     std::string name;
18     std::string type;
19   };
20   struct Method {
21     enum class Kind {
22       kSimple,
23       kNormal,
24       kAsync,
25       kRaw
26     };
MethodInterface::Method27     Method(const std::string& name_in,
28            const std::vector<Argument>& input_arguments_in,
29            const std::vector<Argument>& output_arguments_in)
30         : name(name_in),
31           input_arguments(input_arguments_in),
32           output_arguments(output_arguments_in) {}
MethodInterface::Method33     Method(const std::string& name_in,
34            const std::vector<Argument>& input_arguments_in)
35         : name(name_in),
36           input_arguments(input_arguments_in) {}
MethodInterface::Method37     explicit Method(const std::string& name_in) : name(name_in) {}
38     std::string name;
39     std::vector<Argument> input_arguments;
40     std::vector<Argument> output_arguments;
41     std::string doc_string;
42     Kind kind{Kind::kNormal};
43     bool is_const{false};
44     bool include_dbus_message{false};
45   };
46   struct Signal {
SignalInterface::Signal47     Signal(const std::string& name_in,
48            const std::vector<Argument>& arguments_in)
49         : name(name_in), arguments(arguments_in) {}
SignalInterface::Signal50     explicit Signal(const std::string& name_in) : name(name_in) {}
51     std::string name;
52     std::vector<Argument> arguments;
53     std::string doc_string;
54   };
55   struct Property {
PropertyInterface::Property56     Property(const std::string& name_in,
57              const std::string& type_in,
58              const std::string& access_in)
59         : name(name_in), type(type_in), access(access_in) {}
60     std::string name;
61     std::string type;
62     std::string access;
63     std::string doc_string;
64   };
65 
66   Interface() = default;
InterfaceInterface67   Interface(const std::string& name_in,
68             const std::vector<Method>& methods_in,
69             const std::vector<Signal>& signals_in,
70             const std::vector<Property>& properties_in)
71       : name(name_in), methods(methods_in), signals(signals_in),
72         properties(properties_in) {}
73   std::string name;
74   std::string path;
75   std::vector<Method> methods;
76   std::vector<Signal> signals;
77   std::vector<Property> properties;
78   std::string doc_string;
79 };
80 
81 }  // namespace chromeos_dbus_bindings
82 
83 #endif  // CHROMEOS_DBUS_BINDINGS_INTERFACE_H_
84