Add header files for code block 18/171918/4
authorJunghoon Park <jh9216.park@samsung.com>
Thu, 8 Mar 2018 06:21:27 +0000 (15:21 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Fri, 9 Mar 2018 00:44:38 +0000 (00:44 +0000)
Change-Id: Ie9047adc7314fa0bcacfce41a0900b3a4d7dc2d6
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
idlc/cpp_gen/cpp_gen_base_cb.h
idlc/cpp_gen/cpp_proxy_body_gen_cb.h
idlc/cpp_gen/cpp_proxy_header_gen.cc
idlc/cpp_gen/cpp_proxy_header_gen.h
idlc/cpp_gen/cpp_proxy_header_gen_cb.h [new file with mode: 0644]
idlc/cpp_gen/cpp_stub_body_gen.cc
idlc/cpp_gen/cpp_stub_body_gen_cb.h [new file with mode: 0644]
idlc/cpp_gen/cpp_stub_header_gen.cc
idlc/cpp_gen/cpp_stub_header_gen_cb.h [new file with mode: 0644]

index 602fa75..995d972 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 const char CB_BUNDLE[] = R"__cls_bundle(class Bundle final {
  public:
   Bundle() {
@@ -71,4 +87,4 @@ rpc_port_parcel_h operator >> (rpc_port_parcel_h h, $$::CallbackBase& cb) {
   return h;
 }
 
-)__cpp_cb";
\ No newline at end of file
+)__cpp_cb";
index f431f5e..4d80427 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 const char CB_PROXY_HELPER_METHODS[] =
 R"__cpp_cb(
 int $$::Connect() {
index 3b30707..2937e7b 100644 (file)
 
 #include "idlc/cpp_gen/cpp_proxy_header_gen.h"
 
+namespace {
+#include "cpp_proxy_header_gen_cb.h"
+}
+
 namespace tidl {
 
 CppProxyHeaderGen::CppProxyHeaderGen(std::shared_ptr<Document> doc)
@@ -53,13 +57,7 @@ void CppProxyHeaderGen::GenNamespace(std::ofstream& stream) {
 }
 
 void CppProxyHeaderGen::GenExceptions(std::ofstream& stream) {
-  const char cb[] =
-R"__cpp_cb(
-class Exception {};
-class NotConnectedSocketException : public Exception {};
-class InvalidProtocolException : public Exception {};
-)__cpp_cb";
-  stream << cb << NLine(1);
+  stream << CB_EXCEPTIONS << NLine(1);
 }
 
 void CppProxyHeaderGen::GenInterfaces(std::ofstream& stream) {
@@ -73,39 +71,11 @@ void CppProxyHeaderGen::GenInterfaces(std::ofstream& stream) {
 
 void CppProxyHeaderGen::GenInterface(std::ofstream& stream,
                                      const Interface& iface) {
-  const char* pub =
-      "class IEventListener {\n" \
-      " public:\n" \
-      "  virtual void OnConnected() = 0;\n" \
-      "  virtual void OnDisconnected() = 0;\n" \
-      "  virtual void OnRejected() = 0;\n" \
-      "};\n"
-      "\n" \
-      "$$(IEventListener* listener, const std::string& target_appid);\n" \
-      "virtual ~$$();\n" \
-      "\n" \
-      "int Connect();\n";
-
-  const char* priv =
-      "static void OnConnectedCB(const char *ep, const char *port_name,\n" \
-      "                          rpc_port_h port, void *data);\n" \
-      "static void OnDisconnectedCB(const char *ep, const char *port_name,\n" \
-      "                             void *data);\n" \
-      "static void OnRejectedCB(const char *ep, const char *port_name, void *data);\n" \
-      "static void OnReceivedCB(const char *ep, const char *port_name, void *data);\n" \
-      "\n" \
-      "rpc_port_h port_;\n" \
-      "rpc_port_proxy_h proxy_;\n" \
-      "IEventListener* listener_;\n" \
-      "std::recursive_mutex mutex_;\n" \
-      "std::list<std::unique_ptr<CallbackBase>> delegate_list_;\n" \
-      "std::string target_appid_;\n";
-
   stream << NLine(1) << "class " << iface.GetID() << " ";
   GenBrace(stream, 0, [&]() {
     stream << " public:" << NLine(1);
     GenHeaderCallbacks(stream, iface, true);
-    GenTemplate(AddIndent(TAB_SIZE, pub), stream,
+    GenTemplate(CB_PUBLIC_MEMBERS, stream,
       [&]()->std::string {
         return iface.GetID();
       },
@@ -117,19 +87,11 @@ void CppProxyHeaderGen::GenInterface(std::ofstream& stream,
     stream << NLine(1) << " private:" << NLine(1);
     GenMethodId(stream, iface);
     GenDelegateId(stream, iface);
-    GenHelperMethods(stream);
-    stream << AddIndent(TAB_SIZE, priv);
+    stream << CB_PRIVATE_MEMBERS;
   }, false, false);
   stream << ";" << NLine(1);
 }
 
-void CppProxyHeaderGen::GenHelperMethods(std::ofstream& stream) {
-  const char* func =
-      "void ProcessReceivedEvent(rpc_port_parcel_h parcel);\n" \
-      "void ConsumeCommand(rpc_port_parcel_h* parcel, rpc_port_h port);\n";
-  stream << AddIndent(TAB_SIZE, func) << NLine(1);
-}
-
 void CppProxyHeaderGen::GenMethods(std::ofstream& stream,
                                    const Interface& iface) {
   auto& decls = iface.GetDeclarations();
index 0e120f8..96cb19c 100644 (file)
@@ -39,7 +39,6 @@ class CppProxyHeaderGen : public CppGeneratorBase {
   void GenInterface(std::ofstream& stream, const Interface& iface);
   void GenMethods(std::ofstream& stream, const Interface& iface);
   void GenDeclaration(std::ofstream& stream, const Declaration& decl);
-  void GenHelperMethods(std::ofstream& stream);
 };
 
 }  // namespace tidl
diff --git a/idlc/cpp_gen/cpp_proxy_header_gen_cb.h b/idlc/cpp_gen/cpp_proxy_header_gen_cb.h
new file mode 100644 (file)
index 0000000..202b072
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const char CB_EXCEPTIONS[] =
+R"__cpp_cb(
+class Exception {};
+class NotConnectedSocketException : public Exception {};
+class InvalidProtocolException : public Exception {};
+)__cpp_cb";
+
+const char CB_PUBLIC_MEMBERS[] =
+R"__cpp_cb(  class IEventListener {
+   public:
+    virtual void OnConnected() = 0;
+    virtual void OnDisconnected() = 0;
+    virtual void OnRejected() = 0;
+  };
+
+  $$(IEventListener* listener, const std::string& target_appid);
+  virtual ~$$();
+
+  int Connect();
+)__cpp_cb";
+
+const char CB_PRIVATE_MEMBERS[] =
+R"__cpp_cb(  void ProcessReceivedEvent(rpc_port_parcel_h parcel);
+  void ConsumeCommand(rpc_port_parcel_h* parcel, rpc_port_h port);
+
+  static void OnConnectedCB(const char *ep, const char *port_name,
+                            rpc_port_h port, void *data);
+  static void OnDisconnectedCB(const char *ep, const char *port_name,
+                               void *data);
+  static void OnRejectedCB(const char *ep, const char *port_name, void *data);
+  static void OnReceivedCB(const char *ep, const char *port_name, void *data);
+
+  rpc_port_h port_;
+  rpc_port_proxy_h proxy_;
+  IEventListener* listener_;
+  std::recursive_mutex mutex_;
+  std::list<std::unique_ptr<CallbackBase>> delegate_list_;
+  std::string target_appid_;
+)__cpp_cb";
index 9c586cf..e86efff 100644 (file)
 
 #include "idlc/cpp_gen/cpp_stub_body_gen.h"
 
+namespace {
+#include "cpp_stub_body_gen_cb.h"
+}
+
 namespace tidl {
 
 CppStubBodyGen::CppStubBodyGen(std::shared_ptr<Document> doc)
@@ -73,12 +77,7 @@ void CppStubBodyGen::GenInterface(std::ofstream& stream,
 
 void CppStubBodyGen::GenServiceBase(std::ofstream& stream,
                                     const Interface& iface) {
-  const char cb[] =
-      "$$::ServiceBase::ServiceBase(std::string sender, std::string instance)\n" \
-      "    : sender_(std::move(sender)), instance_(std::move(instance)) {}\n" \
-      "\n";
-
-  GenTemplate(cb, stream,
+  GenTemplate(CB_CTOR_SERVICE_BASE, stream,
     [&]()->std::string {
       return iface.GetID();
     }
@@ -88,16 +87,7 @@ void CppStubBodyGen::GenServiceBase(std::ofstream& stream,
 
 void CppStubBodyGen::GenConstructor(std::ofstream& stream,
                                     const Interface& iface) {
-  const char cb[] =
-R"__cpp_cb(
-$$::$$() {
-  rpc_port_stub_create(&stub_, "$$");
-  rpc_port_stub_add_connected_event_cb(stub_, OnConnectedCB, this);
-  rpc_port_stub_add_disconnected_event_cb(stub_, OnDisconnectedCB, this);
-  rpc_port_stub_add_received_event_cb(stub_, OnReceivedCB, this);
-)__cpp_cb";
-
-  GenTemplate(cb, stream,
+  GenTemplate(CB_CTOR_FRONT, stream,
     [&]()->std::string { return iface.GetID(); },
     [&]()->std::string { return iface.GetID(); },
     [&]()->std::string { return iface.GetID(); }
@@ -115,42 +105,8 @@ $$::$$() {
 
 void CppStubBodyGen::GenDefaultMethods(std::ofstream& stream,
                                        const Interface& iface) {
-  const char cb[] =
-R"__cpp_cb(
-$$::~$$() {
-  if (stub_) {
-    rpc_port_stub_destroy(stub_);
-  }
-}
-
-void $$::Listen(
-    std::shared_ptr<$$::ServiceBase::Factory> service_factory) {
-  service_factory_ = std::move(service_factory);
-  rpc_port_stub_listen(stub_);
-}
-
-void $$::OnConnectedCB(const char* sender, const char* instance, void *data) {
-  $$* stub = static_cast<$$*>(data);
-  auto s = stub->service_factory_->CreateService(sender, instance);
-  s->OnCreate();
-  stub->services_.emplace_back(std::move(s));
-}
-
-void $$::OnDisconnectedCB(const char* sender, const char* instance, void *data) {
-  $$* stub = static_cast<$$*>(data);
-
-  for (auto& i : stub->services_) {
-    if (i->GetInstance() == instance) {
-      i->OnTerminate();
-      stub->services_.remove(i);
-      return;
-    }
-  }
-}
-)__cpp_cb";
-
   GenConstructor(stream, iface);
-  GenTemplate(cb, stream,
+  GenTemplate(CB_DEFAULT_METHODS, stream,
     [&]()->std::string { return iface.GetID(); },
     [&]()->std::string { return iface.GetID(); },
     [&]()->std::string { return iface.GetID(); },
@@ -167,46 +123,7 @@ void $$::OnDisconnectedCB(const char* sender, const char* instance, void *data)
 
 void CppStubBodyGen::GenReceivedEvent(std::ofstream& stream,
                                       const Interface& iface) {
-  const char method_front[] =
-    "int $$::OnReceivedCB(const char* sender, const char* instance, rpc_port_h port, void *data)\n" \
-    "{\n" \
-    "  auto* cxt = static_cast<$$*>(data);"
-    "  rpc_port_parcel_h p;\n" \
-    "  rpc_port_parcel_h result;\n" \
-    "  int cmd;\n" \
-    "  int ret = rpc_port_parcel_create_from_port(&p, port);\n" \
-    "\n" \
-    "  if (ret != 0)\n" \
-    "    return ret;\n" \
-    "\n" \
-    "  rpc_port_parcel_create(&result);\n" \
-    "  rpc_port_parcel_read_int32(p, &cmd);\n" \
-    "  std::shared_ptr<ServiceBase> b;\n" \
-    "\n" \
-    "  for (auto& i : cxt->services_) {\n" \
-    "    if (i->GetInstance() == instance) {\n" \
-    "      b = i;\n" \
-    "      break;\n" \
-    "    }\n" \
-    "  }\n" \
-    "\n" \
-    "  if (b.get() == nullptr)\n" \
-    "    return -1;\n" \
-    "\n"
-    "  switch (cmd) {\n";
-
-  const char method_back[] =
-    "    default:\n" \
-    "      return -1;\n" \
-    "  }\n" \
-    "\n" \
-    "  rpc_port_parcel_destroy(p);\n" \
-    "  rpc_port_parcel_destroy(result);\n" \
-    "\n" \
-    "  return 0;\n" \
-    "}\n";
-
-  GenTemplate(method_front, stream,
+  GenTemplate(CB_ON_RECEIVED_CB_FRONT, stream,
     [&]()->std::string {
       return iface.GetID();
     },
@@ -224,7 +141,7 @@ void CppStubBodyGen::GenReceivedEvent(std::ofstream& stream,
     }, false);
     stream << NLine(1);
   }
-  stream << method_back << NLine(1);
+  stream << CB_ON_RECEIVED_CB_BACK << NLine(1);
 }
 
 void CppStubBodyGen::GenInvocation(std::ofstream& stream, const Declaration& decl) {
diff --git a/idlc/cpp_gen/cpp_stub_body_gen_cb.h b/idlc/cpp_gen/cpp_stub_body_gen_cb.h
new file mode 100644 (file)
index 0000000..b921ed9
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const char CB_CTOR_FRONT[] =
+R"__cpp_cb(
+$$::$$() {
+  rpc_port_stub_create(&stub_, "$$");
+  rpc_port_stub_add_connected_event_cb(stub_, OnConnectedCB, this);
+  rpc_port_stub_add_disconnected_event_cb(stub_, OnDisconnectedCB, this);
+  rpc_port_stub_add_received_event_cb(stub_, OnReceivedCB, this);
+)__cpp_cb";
+
+const char CB_DEFAULT_METHODS[] =
+R"__cpp_cb(
+$$::~$$() {
+  if (stub_) {
+    rpc_port_stub_destroy(stub_);
+  }
+}
+
+void $$::Listen(
+    std::shared_ptr<$$::ServiceBase::Factory> service_factory) {
+  service_factory_ = std::move(service_factory);
+  rpc_port_stub_listen(stub_);
+}
+
+void $$::OnConnectedCB(const char* sender, const char* instance, void *data) {
+  $$* stub = static_cast<$$*>(data);
+  auto s = stub->service_factory_->CreateService(sender, instance);
+  s->OnCreate();
+  stub->services_.emplace_back(std::move(s));
+}
+
+void $$::OnDisconnectedCB(const char* sender, const char* instance, void *data) {
+  $$* stub = static_cast<$$*>(data);
+
+  for (auto& i : stub->services_) {
+    if (i->GetInstance() == instance) {
+      i->OnTerminate();
+      stub->services_.remove(i);
+      return;
+    }
+  }
+}
+)__cpp_cb";
+
+const char CB_ON_RECEIVED_CB_FRONT[] =
+R"__cpp_cb(int $$::OnReceivedCB(const char* sender, const char* instance, rpc_port_h port, void *data)
+{
+  auto* cxt = static_cast<$$*>(data);
+  rpc_port_parcel_h p;
+  rpc_port_parcel_h result;
+  int cmd;
+  int ret = rpc_port_parcel_create_from_port(&p, port);
+
+  if (ret != 0)
+    return ret;
+
+  rpc_port_parcel_create(&result);
+  rpc_port_parcel_read_int32(p, &cmd);
+  std::shared_ptr<ServiceBase> b;
+
+  for (auto& i : cxt->services_) {
+    if (i->GetInstance() == instance) {
+      b = i;
+      break;
+    }
+  }
+
+  if (b.get() == nullptr)
+    return -1;
+
+  switch (cmd) {
+)__cpp_cb";
+
+const char CB_ON_RECEIVED_CB_BACK[] =
+R"__cpp_cb(    default:
+      return -1;
+  }
+
+  rpc_port_parcel_destroy(p);
+  rpc_port_parcel_destroy(result);
+
+  return 0;
+}
+)__cpp_cb";
+
+const char CB_CTOR_SERVICE_BASE[] =
+R"__cpp_cb($$::ServiceBase::ServiceBase(std::string sender, std::string instance)
+    : sender_(std::move(sender)), instance_(std::move(instance)) {})__cpp_cb";
index 17f8e31..a99a406 100644 (file)
 
 #include "idlc/cpp_gen/cpp_stub_header_gen.h"
 
+namespace {
+#include "cpp_stub_header_gen_cb.h"
+}
+
 namespace tidl {
 
 CppStubHeaderGen::CppStubHeaderGen(std::shared_ptr<Document> doc)
@@ -52,13 +56,7 @@ void CppStubHeaderGen::GenNamespace(std::ofstream& stream) {
 }
 
 void CppStubHeaderGen::GenExceptions(std::ofstream& stream) {
-  const char cb[] =
-R"__cpp_cb(
-class Exception {};
-class NotConnectedSocketException : public Exception {};
-class InvalidProtocolException : public Exception {};
-)__cpp_cb";
-  stream << cb << NLine(1);
+  stream << CB_EXCEPTIONS << NLine(1);
 }
 
 void CppStubHeaderGen::GenInterfaces(std::ofstream& stream) {
@@ -94,52 +92,12 @@ void CppStubHeaderGen::GenPrivate(std::ofstream& stream,
   stream << " private:" << NLine(1);
   GenMethodId(stream, iface);
   GenDelegateId(stream, iface);
-
-  const char cb[] =
-      "static void OnConnectedCB(const char* sender, const char* instance, void* data);\n" \
-      "static void OnDisconnectedCB(const char* sender, const char* instance, void* data);\n" \
-      "static int OnReceivedCB(const char* sender, const char* instance, rpc_port_h port, void* data);\n" \
-      "\n" \
-      "rpc_port_stub_h stub_;\n" \
-      "std::shared_ptr<ServiceBase::Factory> service_factory_;\n" \
-      "std::list<std::shared_ptr<ServiceBase>> services_;\n";
-
-  stream << AddIndent(TAB_SIZE, cb);
+  stream << CB_PRIVATE_MEMBERS;
 }
 
 void CppStubHeaderGen::GenServiceBase(std::ofstream& stream,
                                       const Interface& iface) {
-  const char cb1[] = R"__cpp_cb(  class ServiceBase {
-   public:
-    class Factory {
-     public:
-      virtual std::unique_ptr<ServiceBase> CreateService(std::string sender, std::string instance) = 0;
-    };
-
-    virtual ~ServiceBase() = default;
-
-    const std::string& GetSender() const {
-      return sender_;
-    }
-
-    const std::string& GetInstance() const {
-      return instance_;
-    }
-
-    virtual void OnCreate() = 0;
-    virtual void OnTerminate() = 0;
-)__cpp_cb";
-
-  const char cb2[] = R"__cpp_cb(
-   protected:
-    ServiceBase(std::string sender, std::string instance);
-
-   private:
-    std::string sender_;
-    std::string instance_;
-  };)__cpp_cb";
-
-  stream << cb1;
+  stream << CB_SERVICE_BASE_FRONT;
   auto& decls = iface.GetDeclarations();
 
   for (auto& i : decls.GetDecls()) {
@@ -151,20 +109,12 @@ void CppStubHeaderGen::GenServiceBase(std::ofstream& stream,
     stream << ") = 0;" << NLine(1);
   }
 
-  stream << cb2 << NLine(2);
+  stream << CB_SERVICE_BASE_BACK << NLine(2);
 }
 
 void CppStubHeaderGen::GenPublicMethods(std::ofstream& stream,
                                         const Interface& iface) {
-  const char cb[] =
-      "$$();\n" \
-      "~$$();\n" \
-      "void Listen(std::shared_ptr<ServiceBase::Factory> service_factory);\n" \
-      "const std::list<std::shared_ptr<ServiceBase>>& GetServices() const {\n" \
-      "  return services_;\n" \
-      "}\n";
-
-  GenTemplate(AddIndent(TAB_SIZE, cb), stream,
+  GenTemplate(CB_PUBLIC_METHODS, stream,
     [&]()->std::string {
       return iface.GetID();
     },
@@ -172,7 +122,6 @@ void CppStubHeaderGen::GenPublicMethods(std::ofstream& stream,
       return iface.GetID();
     }
   );
-  stream << NLine(1);
 }
 
 }  // namespace tidl
diff --git a/idlc/cpp_gen/cpp_stub_header_gen_cb.h b/idlc/cpp_gen/cpp_stub_header_gen_cb.h
new file mode 100644 (file)
index 0000000..195667a
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const char CB_EXCEPTIONS[] =
+R"__cpp_cb(
+class Exception {};
+class NotConnectedSocketException : public Exception {};
+class InvalidProtocolException : public Exception {};
+)__cpp_cb";
+
+const char CB_PRIVATE_MEMBERS[] =
+R"__cpp_cb(  static void OnConnectedCB(const char* sender, const char* instance, void* data);
+  static void OnDisconnectedCB(const char* sender, const char* instance, void* data);
+  static int OnReceivedCB(const char* sender, const char* instance, rpc_port_h port, void* data);
+
+  rpc_port_stub_h stub_;
+  std::shared_ptr<ServiceBase::Factory> service_factory_;
+  std::list<std::shared_ptr<ServiceBase>> services_;
+)__cpp_cb";
+
+const char CB_SERVICE_BASE_FRONT[] = R"__cpp_cb(  class ServiceBase {
+   public:
+    class Factory {
+     public:
+      virtual std::unique_ptr<ServiceBase> CreateService(std::string sender, std::string instance) = 0;
+    };
+
+    virtual ~ServiceBase() = default;
+
+    const std::string& GetSender() const {
+      return sender_;
+    }
+
+    const std::string& GetInstance() const {
+      return instance_;
+    }
+
+    virtual void OnCreate() = 0;
+    virtual void OnTerminate() = 0;
+)__cpp_cb";
+
+const char CB_SERVICE_BASE_BACK[] =
+R"__cpp_cb(
+   protected:
+    ServiceBase(std::string sender, std::string instance);
+
+   private:
+    std::string sender_;
+    std::string instance_;
+  };)__cpp_cb";
+
+const char CB_PUBLIC_METHODS[] =
+R"__cpp_cb(  $$();
+  ~$$();
+
+  void Listen(std::shared_ptr<ServiceBase::Factory> service_factory);
+  const std::list<std::shared_ptr<ServiceBase>>& GetServices() const {
+    return services_;
+  }
+
+)__cpp_cb";