1 /** 2 * (C) 2016 - 2017 KISTLER INSTRUMENTE AG, Winterthur, Switzerland 3 * (C) 2016 - 2019 Stanislav Angelovic <angelovic.s@gmail.com> 4 * 5 * @file AdaptorGenerator.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_ADAPTOR_GENERATOR_H 28 #define __SDBUSCPP_TOOLS_ADAPTOR_GENERATOR_H 29 30 // Own headers 31 #include "xml.h" 32 #include "BaseGenerator.h" 33 34 // STL 35 #include <tuple> 36 #include <set> 37 38 class AdaptorGenerator : public BaseGenerator 39 { 40 protected: 41 /** 42 * Transform xml to adaptor code 43 * @param doc 44 * @param filename 45 * @return 0 if ok 46 */ 47 int transformXmlToFileImpl(const sdbuscpp::xml::Document& doc, const char* filename) const override; 48 49 private: 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 source code for methods 59 * @param methods 60 * @return tuple: registration of methods, declaration of abstract methods 61 */ 62 std::tuple<std::string, std::string> processMethods(const sdbuscpp::xml::Nodes& methods) const; 63 64 /** 65 * Generate source code for signals 66 * @param signals 67 * @return tuple: registration of signals, definition of signal methods 68 */ 69 std::tuple<std::string, std::string> processSignals(const sdbuscpp::xml::Nodes& signals) const; 70 71 /** 72 * Generate source code for properties 73 * @param properties 74 * @return tuple: registration of properties, declaration of property accessor virtual methods 75 */ 76 std::tuple<std::string, std::string> processProperties(const sdbuscpp::xml::Nodes& properties) const; 77 78 /** 79 * Get annotations listed for a given node 80 * @param node 81 * @return map of annotation names to their values 82 */ 83 std::map<std::string, std::string> getAnnotations(sdbuscpp::xml::Node& node) const; 84 85 /** 86 * Get flag for property update behavior annotation value 87 * @param annotationValue 88 * @return flag 89 */ 90 std::string propertyAnnotationToFlag(const std::string& annotationValue) const; 91 }; 92 93 94 95 #endif //__SDBUSCPP_TOOLS_ADAPTOR_GENERATOR_H 96