1 /**
2  * (C) 2016 - 2017 KISTLER INSTRUMENTE AG, Winterthur, Switzerland
3  * (C) 2016 - 2019 Stanislav Angelovic <angelovic.s@gmail.com>
4  *
5  * @file ProxyGenerator.h
6  *
7  * Created on: Feb 1, 2017
8  * Project: sdbus-c++
9  * Description: High-level D-Bus IPC C++ library based on sd-bus
10  *
11  * This file is part of sdbus-c++.
12  *
13  * sdbus-c++ is free software; you can redistribute it and/or modify it
14  * under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, either version 2.1 of the License, or
16  * (at your option) any later version.
17  *
18  * sdbus-c++ is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with sdbus-c++. If not, see <http://www.gnu.org/licenses/>.
25  */
26 
27 #ifndef __SDBUSCPP_TOOLS_PROXY_GENERATOR_H
28 #define __SDBUSCPP_TOOLS_PROXY_GENERATOR_H
29 
30 // Own headers
31 #include "xml.h"
32 #include "BaseGenerator.h"
33 
34 // STL
35 #include <tuple>
36 
37 class ProxyGenerator : public BaseGenerator
38 {
39 protected:
40     /**
41      * Transform xml to proxy code
42      * @param doc
43      * @param filename
44      * @return 0 if ok
45      */
46     int transformXmlToFileImpl(const sdbuscpp::xml::Document& doc, const char* filename) const override;
47 
48 private:
49 
50     /**
51      * Generate source code for interface
52      * @param interface
53      * @return source code
54      */
55     std::string processInterface(sdbuscpp::xml::Node& interface) const;
56 
57     /**
58      * Generate method calls
59      * @param methods
60      * @return tuple: definition of methods, declaration of virtual async reply handlers
61      */
62     std::tuple<std::string, std::string> processMethods(const sdbuscpp::xml::Nodes& methods) const;
63 
64     /**
65      * Generate code for handling signals
66      * @param signals
67      * @return tuple: registration, declaration of virtual methods
68      */
69     std::tuple<std::string, std::string> processSignals(const sdbuscpp::xml::Nodes& signals) const;
70 
71     /**
72      * Generate calls for properties
73      * @param properties
74      * @return source code
75      */
76     std::string processProperties(const sdbuscpp::xml::Nodes& properties) const;
77 
78 };
79 
80 
81 
82 #endif //__SDBUSCPP_TOOLS_PROXY_GENERATOR_H
83