| 1 | /* |
| 2 | * %injeqt copyright begin% |
| 3 | * Copyright 2014 Rafał Malinowski ([email protected]) |
| 4 | * %injeqt copyright end% |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include <injeqt/injector.h>cxx . . $ `<file>/include/injeqt/injector.h`/ |
| 22 | #include <injeqt/module.h>cxx . . $ `<file>/include/injeqt/module.h`/ |
| 23 | |
| 24 | #include <QtCore/QObject> |
| 25 | #include <iostream> |
| 26 | #include <memory> |
| 27 | #include <string> |
| 28 | |
| 29 | class hello_servicecxx . . $ hello_service# : public QObjectcxx . . $ QObject# |
| 30 | { |
| 31 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 32 | |
| 33 | public: |
| 34 | hello_servicecxx . . $ hello_service#hello_service(49f6e7a06ebc5aa8).() {} |
| 35 | virtual ~cxx . . $ hello_service#`~hello_service`(49f6e7a06ebc5aa8).hello_servicecxx . . $ hello_service#() {} |
| 36 | |
| 37 | stdcxx . . $ std/::stringcxx . . $ std/string# say_hellocxx . . $ hello_service#say_hello(219584694fe2b248).() const |
| 38 | { |
| 39 | return {cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)."Hello"}; |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | class world_servicecxx . . $ world_service# : public QObjectcxx . . $ QObject# |
| 44 | { |
| 45 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 46 | |
| 47 | public: |
| 48 | world_servicecxx . . $ world_service#world_service(49f6e7a06ebc5aa8).() {} |
| 49 | virtual ~cxx . . $ world_service#`~world_service`(49f6e7a06ebc5aa8).world_servicecxx . . $ world_service#() {} |
| 50 | |
| 51 | stdcxx . . $ std/::stringcxx . . $ std/string# say_worldcxx . . $ world_service#say_world(219584694fe2b248).() const |
| 52 | { |
| 53 | return {cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)."World"}; |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | class hello_factorycxx . . $ hello_factory# : public QObjectcxx . . $ QObject# |
| 58 | { |
| 59 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 60 | |
| 61 | public: |
| 62 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! hello_factorycxx . . $ hello_factory#hello_factory(49f6e7a06ebc5aa8).() {} |
| 63 | virtual ~cxx . . $ hello_factory#`~hello_factory`(49f6e7a06ebc5aa8).hello_factorycxx . . $ hello_factory#() {} |
| 64 | |
| 65 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! hello_servicecxx . . $ hello_service# * create_servicecxx . . $ hello_factory#create_service(2bc74cb21464e315).() |
| 66 | { |
| 67 | return new hello_servicecxx . . $ hello_service#{}; |
| 68 | } |
| 69 | }; |
| 70 | |
| 71 | class hello_clientcxx . . $ hello_client# : public QObjectcxx . . $ QObject# |
| 72 | { |
| 73 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 74 | |
| 75 | public: |
| 76 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! hello_clientcxx . . $ hello_client#hello_client(49f6e7a06ebc5aa8).() : _scxx . . $ hello_client#_s.{nullptr}, _wcxx . . $ hello_client#_w.{nullptr} {} |
| 77 | virtual ~cxx . . $ hello_client#`~hello_client`(49f6e7a06ebc5aa8).hello_clientcxx . . $ hello_client#() {} |
| 78 | |
| 79 | stdcxx . . $ std/::stringcxx . . $ std/string# saycxx . . $ hello_client#say(219584694fe2b248).() const |
| 80 | { |
| 81 | return _scxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).->say_hellocxx . . $ hello_service#say_hello(219584694fe2b248).() +cxx . . $ std/operator+(900ec9581c410ad9). " " +cxx . . $ std/operator+(aa1c00e85b87da6b). _wcxx . . $ hello_client#_w.->say_worldcxx . . $ world_service#say_world(219584694fe2b248).() +cxx . . $ std/operator+(900ec9581c410ad9). "!"; |
| 82 | } |
| 83 | |
| 84 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 85 | INJEQT_INITcxx . . $ `include/injeqt/injeqt.h:32:11`! void initcxx . . $ hello_client#init(49f6e7a06ebc5aa8).() |
| 86 | { |
| 87 | stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "all services set" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 88 | } |
| 89 | |
| 90 | INJEQT_DONEcxx . . $ `include/injeqt/injeqt.h:33:11`! void donecxx . . $ hello_client#done(49f6e7a06ebc5aa8).() |
| 91 | { |
| 92 | stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "ready for destruction" <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 93 | } |
| 94 | |
| 95 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void set_hello_servicecxx . . $ hello_client#set_hello_service(dba7ac8aa242c796).(hello_servicecxx . . $ hello_service# *s) |
| 96 | { |
| 97 | _scxx . . $ hello_client#_s. = s; |
| 98 | } |
| 99 | |
| 100 | INJEQT_SETcxx . . $ `include/injeqt/injeqt.h:34:11`! void set_world_servicecxx . . $ hello_client#set_world_service(85c528e619fa6575).(world_servicecxx . . $ world_service# *w) |
| 101 | { |
| 102 | _wcxx . . $ hello_client#_w. = w; |
| 103 | } |
| 104 | |
| 105 | private: |
| 106 | hello_servicecxx . . $ hello_service# *_scxx . . $ hello_client#_s.; |
| 107 | world_servicecxx . . $ world_service# *_wcxx . . $ hello_client#_w.; |
| 108 | |
| 109 | }; |
| 110 | |
| 111 | class modulecxx . . $ module# : public injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module# |
| 112 | { |
| 113 | public: |
| 114 | explicit modulecxx . . $ module#module(49f6e7a06ebc5aa8).() |
| 115 | { |
| 116 | _wcxx . . $ module#_w. =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). stdcxx . . $ std/unique_ptr#unique_ptr(57bc6b0441bf5294).::unique_ptrcxx . . $ std/unique_ptr#<world_servicecxx . . $ world_service#>{new world_servicecxx . . $ world_service#{}}; |
| 117 | |
| 118 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<hello_clientcxx . . $ hello_client#>(); |
| 119 | add_typecxx . . $ injeqt/v1/module#add_type(49f6e7a06ebc5aa8).<hello_factorycxx . . $ hello_factory#>(); |
| 120 | add_factorycxx . . $ injeqt/v1/module#add_factory(49f6e7a06ebc5aa8).<hello_servicecxx . . $ hello_service#, hello_factorycxx . . $ hello_factory#>(); |
| 121 | add_ready_objectcxx . . $ injeqt/v1/module#add_ready_object(749de1b6ae65bddd).<world_servicecxx . . $ world_service#>(_wcxx . . $ module#_w..getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 122 | } |
| 123 | |
| 124 | virtual ~cxx . . $ module#`~module`(49f6e7a06ebc5aa8).modulecxx . . $ module#() {} |
| 125 | |
| 126 | private: |
| 127 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<world_servicecxx . . $ world_service#> _wcxx . . $ module#_w.; |
| 128 | |
| 129 | }; |
| 130 | |
| 131 | int maincxx . . $ main(b126dc7c1de90089).() |
| 132 | { |
| 133 | auto modules = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module#>>{}; |
| 134 | modules.emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(stdcxx . . $ std/unique_ptr#unique_ptr(57bc6b0441bf5294).::unique_ptrcxx . . $ std/unique_ptr#<injeqtcxx . . $ injeqt/::modulecxx . . $ injeqt/v1/module#>{new modulecxx . . $ module#{}}); |
| 135 | |
| 136 | auto injector = injeqtcxx . . $ injeqt/v1/injector#injector(2c113f511709706a).::injectorcxx . . $ injeqt/v1/injector#{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::movecxx . . $ std/move(e7c6c0c8363dcc46).(modules)}; |
| 137 | auto client = injector.getcxx . . $ injeqt/v1/injector#get(155dc7f103cdb9db).<hello_clientcxx . . $ hello_client#>(); |
| 138 | auto hello = clientcxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).->saycxx . . $ hello_client#say(219584694fe2b248).(); |
| 139 | |
| 140 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(88df5bef833f7f83). hello <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 141 | } |
| 142 | |
| 143 | #include "hello-world.moc"cxx . . $ `<file>/build/examples/hello-world-example_autogen/include/hello-world.moc`/ |