From de33fbd09acab4be8836335d608963aeccd02d5d Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Thu, 24 Feb 2022 13:59:10 +0900 Subject: [PATCH] Implement basic plugin structure Change-Id: I9f112e443815644af4d95381956a69f0fadaac7d Signed-off-by: Ilho Kim --- idlc/gen_cion/c_transportable.h | 63 ++++++++++++++++++++++++++++++++++++++ idlc/gen_cion/cion_plugin_base.cc | 34 ++++++++++++++++++++ idlc/gen_cion/cion_plugin_base.h | 40 ++++++++++++++++++++++++ idlc/gen_cion/cpp_transportable.h | 63 ++++++++++++++++++++++++++++++++++++++ idlc/gen_cion/cs_transportable.h | 31 +++++++++++++++++++ idlc/gen_cion/java_transportable.h | 31 +++++++++++++++++++ idlc/gen_cion/plugin_loader.cc | 48 +++++++++++++++++++++++++++++ idlc/gen_cion/plugin_loader.h | 45 +++++++++++++++++++++++++++ idlc/gen_cion/transportable.h | 38 +++++++++++++++++++++++ 9 files changed, 393 insertions(+) create mode 100644 idlc/gen_cion/c_transportable.h create mode 100644 idlc/gen_cion/cion_plugin_base.cc create mode 100644 idlc/gen_cion/cion_plugin_base.h create mode 100644 idlc/gen_cion/cpp_transportable.h create mode 100644 idlc/gen_cion/cs_transportable.h create mode 100644 idlc/gen_cion/java_transportable.h create mode 100644 idlc/gen_cion/plugin_loader.cc create mode 100644 idlc/gen_cion/plugin_loader.h create mode 100644 idlc/gen_cion/transportable.h diff --git a/idlc/gen_cion/c_transportable.h b/idlc/gen_cion/c_transportable.h new file mode 100644 index 0000000..83f9335 --- /dev/null +++ b/idlc/gen_cion/c_transportable.h @@ -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 + +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 index 0000000..091313f --- /dev/null +++ b/idlc/gen_cion/cion_plugin_base.cc @@ -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 + +namespace tidl { + +CionPluginBase::CionPluginBase(std::shared_ptr 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 index 0000000..54a8008 --- /dev/null +++ b/idlc/gen_cion/cion_plugin_base.h @@ -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 + +#include "idlc/gen/generator.h" +#include "idlc/gen_cion/plugin_loader.h" + +namespace tidl { + +class CionPluginBase : public Generator { + public: + explicit CionPluginBase(std::shared_ptr doc); + virtual ~CionPluginBase() = default; + + Transportable& GetTransportable(); + + private: + std::unique_ptr 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 index 0000000..a602df9 --- /dev/null +++ b/idlc/gen_cion/cpp_transportable.h @@ -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 + +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 index 0000000..0851805 --- /dev/null +++ b/idlc/gen_cion/cs_transportable.h @@ -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 + +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 index 0000000..a46b36e --- /dev/null +++ b/idlc/gen_cion/java_transportable.h @@ -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 + +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 index 0000000..e71d783 --- /dev/null +++ b/idlc/gen_cion/plugin_loader.cc @@ -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 index 0000000..8861340 --- /dev/null +++ b/idlc/gen_cion/plugin_loader.h @@ -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 +#include + +#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 C_; + std::unique_ptr Cpp_; + std::unique_ptr Cs_; + std::unique_ptr 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 index 0000000..5556cf8 --- /dev/null +++ b/idlc/gen_cion/transportable.h @@ -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_ -- 2.7.4