当前位置: 首页>>代码示例>>C++>>正文


C++ EventData::get_parent方法代码示例

本文整理汇总了C++中EventData::get_parent方法的典型用法代码示例。如果您正苦于以下问题:C++ EventData::get_parent方法的具体用法?C++ EventData::get_parent怎么用?C++ EventData::get_parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventData的用法示例。


在下文中一共展示了EventData::get_parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

bool GenericHandler<Request, Model, IdPolicy>
    ::handle(JsonAgentSPtr agent, const EventData& event) {
    assert(is_event_for_me(event));

    Context ctx;
    ctx.agent = agent.get();
    ctx.mode = Context::Mode::EVENT ;

    log_info(GET_LOGGER("rest"), ctx.indent << ctx.indent << "[" << static_cast<char>(ctx.mode) << "] "
                                 << "Agent event received: " << event.get_notification().to_string()
                                 << " " << component_s() << " uuid=" << event.get_component() << ", "
                                 << "parent uuid=" << event.get_parent() << ", agent_id=" << agent->get_gami_id());
    try {
        using agent_framework::eventing::Notification;
        switch (event.get_notification()) {
            case Notification::Add: {
                try {
                    if (agent_framework::module::get_manager<Model>().entry_exists(event.get_component())) {
                        log_info(GET_LOGGER("rest"),ctx.indent << ctx.indent << "[" << static_cast<char>(ctx.mode) << "] "
                                 << "Duplicated or late event. Ignoring.");
                        return true;
                    }
                    // add may throw
                    add(ctx, event.get_parent(), event.get_component(), true);
                    SubscriptionManager::get_instance()->notify(ctx.events);
                    return true;
                }
                catch (const psme::core::agent::AgentUnreachable&) {
                    // in case of connection error, added element plus all his descendants will be removed from
                    // local "database"
                    do_remove(event.get_component());
                    log_error(GET_LOGGER("rest"), ctx.indent
                                                  << "Exception while handling Agent Event. Removing non-complete data" )
                    return false;
                }
            }
            case Notification::Remove: {
                try {
                    auto uuid_to_remove = event.get_component();
                    remove(uuid_to_remove);
                    SubscriptionManager::get_instance()->notify(ctx.events);
                }
                catch (::agent_framework::exceptions::InvalidParameters e) {
                    log_info(GET_LOGGER("rest"), "Got notification about removal"
                            "of a component, but component is not present in the model");
                }
                return true;
            }
            case Notification::Update: {
                // update may throw
                if (!agent_framework::module::get_manager<Model>().entry_exists(event.get_component())) {
                    log_error(GET_LOGGER("rest"), "Update event for unknown entry. Ignoring");
                    return true;
                }
                update(ctx, event.get_parent(), event.get_component());
                SubscriptionManager::get_instance()->notify(ctx.events);

                return true;
            }
            default:
                log_error(GET_LOGGER("rest"), "Unknown agent event received: " << event.get_notification().to_string());
                break;
        }
    }
    catch (const core::agent::AgentUnreachable& e) {
        log_error(GET_LOGGER("rest"), ctx.indent << "[" << static_cast<char>(ctx.mode) << "] "
                                      << "AgentEvent Handling failed due to agent connection error: "
                                      << e.what());
    }
    catch (const jsonrpc::JsonRpcException& e) {
        log_error(GET_LOGGER("rest"), ctx.indent << "[" << static_cast<char>(ctx.mode) << "] "
                                      << "AgentEvent Handling failed due to JsonRpcException: "
                                      << e.what());
    }
    catch (...) {
        log_error(GET_LOGGER("rest"), ctx.indent << "Exception while handling Agent Event. Data may not be complete" )
        return false;
    }

    return false;
}
开发者ID:iamyaw,项目名称:intelRSD,代码行数:81,代码来源:generic_handler.hpp


注:本文中的EventData::get_parent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。