MCPcopy Create free account
hub / github.com/Kistler-Group/sdbus-cpp / processInterface

Method processInterface

tools/xml2cpp-codegen/ProxyGenerator.cpp:70–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68
69
70std::string ProxyGenerator::processInterface(Node& interface) const
71{
72 std::string ifaceName = interface.get("name");
73 std::cout << "Generating proxy code for interface " << ifaceName << endl;
74
75 unsigned int namespacesCount = 0;
76 std::string namespacesStr;
77 std::tie(namespacesCount, namespacesStr) = generateNamespaces(ifaceName);
78
79 std::ostringstream body;
80 body << namespacesStr;
81
82 std::string className = ifaceName.substr(ifaceName.find_last_of(".") + 1)
83 + "_proxy";
84
85 body << "class " << className << endl
86 << "{" << endl
87 << "public:" << endl
88 << tab << "static constexpr const char* INTERFACE_NAME = \"" << ifaceName << "\";" << endl << endl
89 << "protected:" << endl
90 << tab << className << "(sdbus::IProxy& proxy)" << endl
91 << tab << tab << ": m_proxy(proxy)" << endl
92 << tab << "{" << endl
93 << tab << "}" << endl << endl;
94
95 // Rule of Five
96 body << tab << className << "(const " << className << "&) = delete;" << endl;
97 body << tab << className << "& operator=(const " << className << "&) = delete;" << endl;
98 body << tab << className << "(" << className << "&&) = delete;" << endl;
99 body << tab << className << "& operator=(" << className << "&&) = delete;" << endl << endl;
100
101 body << tab << "~" << className << "() = default;" << endl << endl;
102
103 Nodes methods = interface["method"];
104 Nodes signals = interface["signal"];
105 Nodes properties = interface["property"];
106
107 std::string registration, declaration;
108 std::tie(registration, declaration) = processSignals(signals);
109
110 body << tab << "void registerProxy()" << endl
111 << tab << "{" << endl
112 << registration
113 << tab << "}" << endl << endl;
114
115 if (!declaration.empty())
116 body << declaration << endl;
117
118 std::string methodDefinitions, asyncDeclarationsMethods;
119 std::tie(methodDefinitions, asyncDeclarationsMethods) = processMethods(methods);
120 std::string propertyDefinitions, asyncDeclarationsProperties;
121 std::tie(propertyDefinitions, asyncDeclarationsProperties) = processProperties(properties);
122
123 if (!asyncDeclarationsMethods.empty())
124 {
125 body << asyncDeclarationsMethods << endl;
126 }
127 if (!asyncDeclarationsProperties.empty())

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected