namespace {
+std::string ParamsToString(std::vector<std::string> params) {
+ std::string res;
+ for (auto it = params.begin(); it != params.end(); it++) {
+ res += *it;
+ if ((it + 1) != params.end())
+ res += ", ";
+ }
+
+ return res;
+}
+
constexpr const char __CLIENT_BASE_CONSTRUCTOR[] =
R"__java_cb(
/**
}
)__java_cb";
+constexpr const char __INHERITED_CLASS_CONSTRUCTOR[] =
+R"__java_cb(
+public $$(<PARAMETERS>, String brokerIp) {
+ super(<BASE_CLASS_PARAMETERS>, brokerIp);
+ <EXTRA_OPERATION>
+}
+)__java_cb";
+
} // namespace
namespace tidl {
return __ON_JOINED_EVENT_METHOD;
}
+std::string AittPluginJavaTransportable::GenInheritedClassConstructor(
+ std::vector<std::string> params, std::vector<std::string> base_class_params,
+ std::string extra_operation) const {
+ return std::string(ReplaceAll(__INHERITED_CLASS_CONSTRUCTOR, {
+ { "<PARAMETERS>", ParamsToString(params) },
+ { "<BASE_CLASS_PARAMETERS>", ParamsToString(base_class_params) },
+ { "<EXTRA_OPERATION>", extra_operation }
+ }));
+}
+
} // namespace tidl
std::string GenGroupBaseConstructor() const override;
std::string GenOnLeftEventMethod() const override;
std::string GenOnJoinedEventMethod() const override;
+ std::string GenInheritedClassConstructor(std::vector<std::string> params,
+ std::vector<std::string> base_class_params,
+ std::string extra_operation) const override;
};
} // namespace tidl
namespace {
+std::string ParamsToString(std::vector<std::string> params) {
+ std::string res;
+ for (auto it = params.begin(); it != params.end(); it++) {
+ res += *it;
+ if ((it + 1) != params.end())
+ res += ", ";
+ }
+
+ return res;
+}
+
constexpr const char __SERVER_ACCEPT[] = "<SERVER>.acceptRequest(peerInfo);";
constexpr const char __SERVER_STOP[] = "<SERVER>.stop();";
}
)__java_cb";
+constexpr const char __INHERITED_CLASS_CONSTRUCTOR[] =
+R"__java_cb(
+public $$(<PARAMETERS>) {
+ super(<BASE_CLASS_PARAMETERS>);
+ <EXTRA_OPERATION>
+}
+)__java_cb";
+
} // namespace
return __ON_JOINED_EVENT_METHOD;
}
+std::string DefaultJavaTransportable::GenInheritedClassConstructor(
+ std::vector<std::string> params, std::vector<std::string> base_class_params,
+ std::string extra_operation) const {
+ return std::string(ReplaceAll(__INHERITED_CLASS_CONSTRUCTOR, {
+ { "<PARAMETERS>", ParamsToString(params) },
+ { "<BASE_CLASS_PARAMETERS>", ParamsToString(base_class_params) },
+ { "<EXTRA_OPERATION>", extra_operation }
+ }));
+}
+
} // namespace tidl
std::string GenGroupBaseConstructor() const override;
std::string GenOnLeftEventMethod() const override;
std::string GenOnJoinedEventMethod() const override;
+ std::string GenInheritedClassConstructor(std::vector<std::string> params,
+ std::vector<std::string> base_class_params,
+ std::string extra_operation) const override;
};
} // namespace tidl
void JavaCionGroupGen::GenCtor(std::ofstream& stream, const Interface& iface) {
bool securityCheck = false;
- std::string m = "public $$(Context context, String topicName) {\n";
-
- m += Tab(1) + "super(context, topicName, new "
- + GetTransportable().Java().GenSecurityType() + "(";
+ std::string security_inst = "new " +
+ GetTransportable().Java().GenSecurityType() + "(";
for (const auto& attr : iface.GetAttributes()) {
if (attr->GetKey() == "ca_path") {
- m += "\"" + attr->GetValue() + "\", ";
+ security_inst += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
} else if (attr->GetKey() == "cert_path") {
- m += "\"" + attr->GetValue() + "\", ";
+ security_inst += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
} else if (attr->GetKey() == "private_key") {
- m += "\"" + attr->GetValue() + "\", ";
+ security_inst += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
}
}
- auto const pos = m.find_last_of(',');
- m = m.substr(0, pos);
-
- if (securityCheck)
- m += "));"; /* super(topicName, new SecurityInfo(ca, cert, private_key) */
- else
- m += ");"; /* super(topicName) */
+ if (securityCheck) {
+ security_inst = security_inst.substr(0, security_inst.find_last_of(','));
+ security_inst += ")";
+ }
- m += NLine(1);
- m += " this.topicName = topicName;\n";
- m += "}";
- m += NLine(1);
+ std::string m = GetTransportable().Java().GenInheritedClassConstructor(
+ { "Context context", "String topicName"},
+ (securityCheck ?
+ std::vector<std::string>{ "context", "topicName", security_inst } :
+ std::vector<std::string>{ "context", "topicName" }),
+ { "this.topicName = topicName;" });
GenTemplate(AddIndent(TAB_SIZE, m), stream,
[&]()->std::string {
void JavaCionProxyGen::GenCtor(std::ofstream& stream, const Interface& iface) {
bool securityCheck = false;
- std::string m = "public $$(Context context, String serviceName) {\n";
-
- m += Tab(1) + "super(context, serviceName, new "
- + GetTransportable().Java().GenSecurityType() + "(";
+ std::string security_inst = "new " +
+ GetTransportable().Java().GenSecurityType() + "(";
for (const auto& attr : iface.GetAttributes()) {
if (attr->GetKey() == "ca_path") {
- m += "\"" + attr->GetValue() + "\", ";
+ security_inst += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
} else if (attr->GetKey() == "cert_path") {
- m += "\"" + attr->GetValue() + "\", ";
+ security_inst += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
} else if (attr->GetKey() == "private_key") {
- m += "\"" + attr->GetValue() + "\", ";
+ security_inst += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
}
}
- auto const pos = m.find_last_of(',');
- m = m.substr(0, pos);
-
- if (securityCheck)
- m += "));"; /* super(serviceName, new SecurityInfo(ca, cert, private_key) */
- else
- m += ");"; /* super(serviceName) */
+ if (securityCheck) {
+ security_inst = security_inst.substr(0, security_inst.find_last_of(','));
+ security_inst += ")";
+ }
- m += NLine(1);
- m += " this.serviceName = serviceName;\n";
- m += "}";
+ std::string m = GetTransportable().Java().GenInheritedClassConstructor(
+ { "Context context", "String serviceName" },
+ (securityCheck ?
+ std::vector<std::string>{ "context", "serviceName", security_inst } :
+ std::vector<std::string>{ "context", "serviceName"}),
+ { "this.serviceName = serviceName;" });
GenTemplate(AddIndent(TAB_SIZE, m), stream,
[&]()->std::string {
void JavaCionStubGen::GenCtor(std::ofstream& stream, const Interface& iface) {
bool securityCheck = false;
- std::string m = "public $$(Context context, String serviceName, String displayName) {\n";
- m += Tab(1) + "super(context, serviceName, displayName, new "
- + GetTransportable().Java().GenSecurityType() + "(";
+ std::string security_inst = "new " +
+ GetTransportable().Java().GenSecurityType() + "(";
for (const auto& attr : iface.GetAttributes()) {
if (attr->GetKey() == "ca_path") {
- m += "\"" + attr->GetValue() + "\", ";
+ security_inst += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
} else if (attr->GetKey() == "cert_path") {
- m += "\"" + attr->GetValue() + "\", ";
+ security_inst += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
} else if (attr->GetKey() == "private_key") {
- m += "\"" + attr->GetValue() + "\", ";
+ security_inst += "\"" + attr->GetValue() + "\", ";
securityCheck = true;
}
}
- auto const pos = m.find_last_of(',');
- m = m.substr(0, pos);
-
- if (securityCheck)
- m += "));"; /* super(serviceName, displayName, new SecurityInfo(a,b,c)); */
- else
- m += ");"; /* super(serviceName, displayName); */
+ if (securityCheck) {
+ security_inst = security_inst.substr(0, security_inst.find_last_of(','));
+ security_inst += ")";
+ }
- m += NLine(1);
- m += "}";
+ std::string m = GetTransportable().Java().GenInheritedClassConstructor(
+ { "Context context", "String serviceName", "String displayName" },
+ (securityCheck ?
+ std::vector<std::string>{ "context", "serviceName",
+ "displayName", security_inst } :
+ std::vector<std::string>{ "context", "serviceName", "displayName"}),
+ {});
GenTemplate(AddIndent(TAB_SIZE * 1, m), stream,
[&]()->std::string {
#define IDLC_GEN_CION_JAVA_TRANSPORTABLE_H_
#include <string>
+#include <vector>
namespace tidl {
virtual std::string GenGroupBaseConstructor() const = 0;
virtual std::string GenOnLeftEventMethod() const = 0;
virtual std::string GenOnJoinedEventMethod() const = 0;
+ virtual std::string GenInheritedClassConstructor(
+ std::vector<std::string> params,
+ std::vector<std::string> base_class_params,
+ std::string extra_operation) const = 0;
};
} // namespace tidl