Implement basic plugin structure 51/271651/3
authorIlho Kim <ilho159.kim@samsung.com>
Thu, 24 Feb 2022 04:59:10 +0000 (13:59 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Thu, 24 Feb 2022 07:53:03 +0000 (16:53 +0900)
Change-Id: I9f112e443815644af4d95381956a69f0fadaac7d
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
idlc/gen_cion/c_transportable.h [new file with mode: 0644]
idlc/gen_cion/cion_plugin_base.cc [new file with mode: 0644]
idlc/gen_cion/cion_plugin_base.h [new file with mode: 0644]
idlc/gen_cion/cpp_transportable.h [new file with mode: 0644]
idlc/gen_cion/cs_transportable.h [new file with mode: 0644]
idlc/gen_cion/java_transportable.h [new file with mode: 0644]
idlc/gen_cion/plugin_loader.cc [new file with mode: 0644]
idlc/gen_cion/plugin_loader.h [new file with mode: 0644]
idlc/gen_cion/transportable.h [new file with mode: 0644]

diff --git a/idlc/gen_cion/c_transportable.h b/idlc/gen_cion/c_transportable.h
new file mode 100644 (file)
index 0000000..83f9335
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef IDLC_GEN_CION_C_TRANSPORTABLE_H_
+#define IDLC_GEN_CION_C_TRANSPORTABLE_H_
+
+#include <string>
+
+namespace tidl {
+
+class CTransportable {
+ public:
+  virtual ~CTransportable() = default;
+  virtual std::string GenInclude() const = 0;
+  virtual std::string GenClientSendAsync(std::string client,
+      std::string payload, std::string size) const = 0;
+  virtual std::string GenClientSend(std::string client, std::string data,
+      std::string data_size, std::string ret_data,
+      std::string ret_data_size) const = 0;
+  virtual std::string GenServerSendAsync(std::string server, std::string client,
+      std::string payload, std::string size) const = 0;
+  virtual std::string GenServerFileSend(std::string path, std::string server,
+      std::string peer) const = 0;
+  virtual std::string GenClientFileSend(std::string path,
+      std::string client) const = 0;
+  virtual std::string GenPayloadTransferStatusType() const = 0;
+  virtual std::string GenPeerInfoType() const = 0;
+  virtual std::string GenPayloadType() const = 0;
+  virtual std::string GenClientType() const = 0;
+  virtual std::string GenSecurityType() const = 0;
+  virtual std::string GenServerType() const = 0;
+  virtual std::string GenClientTryConnect(std::string client,
+      std::string peer) const = 0;
+  virtual std::string GenClientDisconnect(std::string client) const = 0;
+  virtual std::string GenClientTryDiscovery(std::string client) const = 0;
+  virtual std::string GenClientStopDiscovery(std::string client) const = 0;
+  virtual std::string GenServerRegister() const = 0;
+  virtual std::string GenServerUnregister() const = 0;
+  virtual std::string GenClientExtraHeader() const = 0;
+  virtual std::string GenClientExtraBody() const = 0;
+  virtual std::string GenServerExtraHeader() const = 0;
+  virtual std::string GenServerExtraBody() const = 0;
+  virtual std::string GenServerAccept() const = 0;
+  virtual std::string GenServerReject() const = 0;
+  virtual std::string GenServerSetDisplayName() const = 0;
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_GEN_CION_C_TRANSPORTABLE_H_
diff --git a/idlc/gen_cion/cion_plugin_base.cc b/idlc/gen_cion/cion_plugin_base.cc
new file mode 100644 (file)
index 0000000..091313f
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#include "idlc/gen_cion/cion_plugin_base.h"
+
+#include "idlc/gen_cion/plugin_loader.h"
+
+#include <utility>
+
+namespace tidl {
+
+CionPluginBase::CionPluginBase(std::shared_ptr<Document> doc)
+    : Generator(std::move(doc)) {
+  transportable_.reset(new PluginLoader(""));
+}
+
+Transportable& CionPluginBase::GetTransportable() {
+  return *transportable_;
+}
+
+}  // namespace tidl
diff --git a/idlc/gen_cion/cion_plugin_base.h b/idlc/gen_cion/cion_plugin_base.h
new file mode 100644 (file)
index 0000000..54a8008
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef IDLC_GEN_CION_CION_PLUGIN_BASE_H_
+#define IDLC_GEN_CION_CION_PLUGIN_BASE_H_
+
+#include <memory>
+
+#include "idlc/gen/generator.h"
+#include "idlc/gen_cion/plugin_loader.h"
+
+namespace tidl {
+
+class CionPluginBase : public Generator {
+ public:
+  explicit CionPluginBase(std::shared_ptr<Document> doc);
+  virtual ~CionPluginBase() = default;
+
+  Transportable& GetTransportable();
+
+ private:
+  std::unique_ptr<Transportable> transportable_;
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_GEN_CION_CION_PLUGIN_BASE_H_
diff --git a/idlc/gen_cion/cpp_transportable.h b/idlc/gen_cion/cpp_transportable.h
new file mode 100644 (file)
index 0000000..a602df9
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef IDLC_GEN_CION_CPP_TRANSPORTABLE_H_
+#define IDLC_GEN_CION_CPP_TRANSPORTABLE_H_
+
+#include <string>
+
+namespace tidl {
+
+class CppTransportable {
+ public:
+  virtual ~CppTransportable() = default;
+  virtual std::string GenInclude() const = 0;
+  virtual std::string GenClientSendAsync(std::string client,
+      std::string payload, std::string size) const = 0;
+  virtual std::string GenClientSend(std::string client, std::string data,
+      std::string data_size, std::string ret_data,
+      std::string ret_data_size) const = 0;
+  virtual std::string GenServerSendAsync(std::string server, std::string client,
+      std::string payload, std::string size) const = 0;
+  virtual std::string GenServerFileSend(std::string path, std::string server,
+      std::string peer) const = 0;
+  virtual std::string GenClientFileSend(std::string path,
+      std::string client) const = 0;
+  virtual std::string GenPayloadTransferStatusType() const = 0;
+  virtual std::string GenPeerInfoType() const = 0;
+  virtual std::string GenPayloadType() const = 0;
+  virtual std::string GenClientType() const = 0;
+  virtual std::string GenSecurityType() const = 0;
+  virtual std::string GenServerType() const = 0;
+  virtual std::string GenClientTryConnect(std::string client,
+      std::string peer) const = 0;
+  virtual std::string GenClientDisconnect(std::string client) const = 0;
+  virtual std::string GenClientTryDiscovery(std::string client) const = 0;
+  virtual std::string GenClientStopDiscovery(std::string client) const = 0;
+  virtual std::string GenServerRegister() const = 0;
+  virtual std::string GenServerUnregister() const = 0;
+  virtual std::string GenClientExtraHeader() const = 0;
+  virtual std::string GenClientExtraBody() const = 0;
+  virtual std::string GenServerExtraHeader() const = 0;
+  virtual std::string GenServerExtraBody() const = 0;
+  virtual std::string GenServerAccept() const = 0;
+  virtual std::string GenServerReject() const = 0;
+  virtual std::string GenServerSetDisplayName() const = 0;
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_GEN_CION_CPP_TRANSPORTABLE_H_
diff --git a/idlc/gen_cion/cs_transportable.h b/idlc/gen_cion/cs_transportable.h
new file mode 100644 (file)
index 0000000..0851805
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef IDLC_GEN_CION_CS_TRANSPORTABLE_H_
+#define IDLC_GEN_CION_CS_TRANSPORTABLE_H_
+
+#include <string>
+
+namespace tidl {
+
+class CsTransportable {
+ public:
+  virtual ~CsTransportable() = default;
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_GEN_CION_CS_TRANSPORTABLE_H_
diff --git a/idlc/gen_cion/java_transportable.h b/idlc/gen_cion/java_transportable.h
new file mode 100644 (file)
index 0000000..a46b36e
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef IDLC_GEN_CION_JAVA_TRANSPORTABLE_H_
+#define IDLC_GEN_CION_JAVA_TRANSPORTABLE_H_
+
+#include <string>
+
+namespace tidl {
+
+class JavaTransportable {
+ public:
+  virtual ~JavaTransportable() = default;
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_GEN_CION_JAVA_TRANSPORTABLE_H_
diff --git a/idlc/gen_cion/plugin_loader.cc b/idlc/gen_cion/plugin_loader.cc
new file mode 100644 (file)
index 0000000..e71d783
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#include "idlc/gen_cion/plugin_loader.h"
+
+namespace tidl {
+
+PluginLoader::PluginLoader(const std::string& plugin_path) {
+  if (plugin_path.empty()) {
+    // C_.reset(new DefaultCTransportable());
+    // Cpp_.reset(new DefaultCppTransportable());
+    // Cs_.reset(new DefaultCsTransportable());
+    // Java_.reset(new DefaultJavaTransportable());
+  } else {
+    // TODO
+  }
+}
+
+const CTransportable& PluginLoader::C() {
+  return *C_;
+}
+
+const CppTransportable& PluginLoader::Cpp() {
+  return *Cpp_;
+}
+
+const CsTransportable& PluginLoader::Cs() {
+  return *Cs_;
+}
+
+const JavaTransportable& PluginLoader::Java() {
+  return *Java_;
+}
+
+}  // namespace tidl
diff --git a/idlc/gen_cion/plugin_loader.h b/idlc/gen_cion/plugin_loader.h
new file mode 100644 (file)
index 0000000..8861340
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef IDLC_GEN_CION_PLUGIN_LOADER_H_
+#define IDLC_GEN_CION_PLUGIN_LOADER_H_
+
+#include <memory>
+#include <string>
+
+#include "idlc/gen_cion/transportable.h"
+
+namespace tidl {
+
+class PluginLoader : public Transportable {
+ public:
+  explicit PluginLoader(const std::string& plugin_path);
+
+  const CTransportable& C() override;
+  const CppTransportable& Cpp() override;
+  const CsTransportable& Cs() override;
+  const JavaTransportable& Java() override;
+
+ private:
+  std::unique_ptr<CTransportable> C_;
+  std::unique_ptr<CppTransportable> Cpp_;
+  std::unique_ptr<CsTransportable> Cs_;
+  std::unique_ptr<JavaTransportable> Java_;
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_GEN_CION_PLUGIN_LOADER_H_
diff --git a/idlc/gen_cion/transportable.h b/idlc/gen_cion/transportable.h
new file mode 100644 (file)
index 0000000..5556cf8
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef IDLC_GEN_CION_TRANSPORTABLE_H_
+#define IDLC_GEN_CION_TRANSPORTABLE_H_
+
+#include "idlc/gen_cion/c_transportable.h"
+#include "idlc/gen_cion/cpp_transportable.h"
+#include "idlc/gen_cion/cs_transportable.h"
+#include "idlc/gen_cion/java_transportable.h"
+
+namespace tidl {
+
+class Transportable {
+ public:
+  virtual ~Transportable() = default;
+  virtual const CTransportable& C() = 0;
+  virtual const CppTransportable& Cpp() = 0;
+  virtual const CsTransportable& Cs() = 0;
+  virtual const JavaTransportable& Java() = 0;
+};
+
+}  // namespace tidl
+
+#endif  // IDLC_GEN_CION_TRANSPORTABLE_H_