#include "wire_Watchdog.hpp"
#include "../obapi_runtime.hpp"
#include <type_traits>
static_assert(std::is_same<decltype(::M_Watchdog::WatchdogSettingsType::WatchableOperations), std::vector<std::string>>::value, "M_Watchdog::WatchdogSettingsType field WatchableOperations differs from the data model");
static_assert(std::is_same<decltype(::M_Watchdog::WatchStatusType::WatchedOperations), std::vector<std::string>>::value, "M_Watchdog::WatchStatusType field WatchedOperations differs from the data model");
namespace M_Watchdog {
void obapi_put(::obapi::Writer& w, WatchdogSettingsType const& v) {
::obapi::put(w, v.WatchableOperations);
}
void obapi_get(::obapi::Reader& r, WatchdogSettingsType& v) {
::obapi::get(r, v.WatchableOperations);
}
void obapi_put(::obapi::Writer& w, WatchStatusType const& v) {
::obapi::put(w, v.WatchedOperations);
}
void obapi_get(::obapi::Reader& r, WatchStatusType& v) {
::obapi::get(r, v.WatchedOperations);
}
}
namespace {
struct ServiceCallbacks final : ::M_Watchdog::IService {
::obapi::Dispatcher dispatcher;
void ConfigWatch(std::string const& KeyWatchedClientId, std::string const& KeyAssociatedServiceName, ::M_Common::StringListType const& WatchedOperations, bool IsRemoved) override {
::obapi::Writer w;
::obapi::put(w, KeyWatchedClientId);
::obapi::put(w, KeyAssociatedServiceName);
::obapi::put(w, WatchedOperations);
::obapi::put(w, IsRemoved);
dispatcher.dispatch(0u, w);
}
};
struct ClientCallbacks final : ::M_Watchdog::IClient {
::obapi::Dispatcher dispatcher;
void ReportWatchdogSettings(::M_Watchdog::WatchdogSettingsType const& Settings) override {
::obapi::Writer w;
::obapi::put(w, Settings);
dispatcher.dispatch(0u, w);
}
void ReportWatchStatus(std::string const& KeyWatchedClientId, std::string const& KeyAssociatedServiceName, ::M_Watchdog::WatchStatusType const& Status, bool IsRemoved) override {
::obapi::Writer w;
::obapi::put(w, KeyWatchedClientId);
::obapi::put(w, KeyAssociatedServiceName);
::obapi::put(w, Status);
::obapi::put(w, IsRemoved);
dispatcher.dispatch(1u, w);
}
};
void service_send(::obapi::Holder<::M_Watchdog::Service, ServiceCallbacks>& h, uint32_t op, ::obapi::Reader& r) {
switch (op) {
case 0u: {
::M_Watchdog::WatchdogSettingsType Settings{};
::obapi::get(r, Settings);
r.finish();
h.endpoint->ReportWatchdogSettings(Settings);
return;
}
case 1u: {
std::string KeyWatchedClientId{};
::obapi::get(r, KeyWatchedClientId);
std::string KeyAssociatedServiceName{};
::obapi::get(r, KeyAssociatedServiceName);
::M_Watchdog::WatchStatusType Status{};
::obapi::get(r, Status);
bool IsRemoved{};
::obapi::get(r, IsRemoved);
r.finish();
h.endpoint->ReportWatchStatus(KeyWatchedClientId, KeyAssociatedServiceName, Status, IsRemoved);
return;
}
default: throw ::obapi::UnknownOp(op);
}
}
void client_send(::obapi::Holder<::M_Watchdog::Client, ClientCallbacks>& h, uint32_t op, ::obapi::Reader& r) {
switch (op) {
case 0u: {
std::string KeyWatchedClientId{};
::obapi::get(r, KeyWatchedClientId);
std::string KeyAssociatedServiceName{};
::obapi::get(r, KeyAssociatedServiceName);
::M_Common::StringListType WatchedOperations{};
::obapi::get(r, WatchedOperations);
bool IsRemoved{};
::obapi::get(r, IsRemoved);
r.finish();
h.endpoint->ConfigWatch(KeyWatchedClientId, KeyAssociatedServiceName, WatchedOperations, IsRemoved);
return;
}
default: throw ::obapi::UnknownOp(op);
}
}
}
extern "C" const obapi_vtable obapi_Watchdog_service_vtable = ::obapi::Endpoint<::M_Watchdog::Service, ServiceCallbacks, &service_send, false>::vtable("M_Watchdog", "Service");
extern "C" const obapi_vtable obapi_Watchdog_client_vtable = ::obapi::Endpoint<::M_Watchdog::Client, ClientCallbacks, &client_send, true>::vtable("M_Watchdog", "Client");