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


C++ ArrayData::push_back方法代码示例

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


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

示例1: CustomVariablesAccessor

Value ServicesTable::CustomVariablesAccessor(const Value& row)
{
    Service::Ptr service = static_cast<Service::Ptr>(row);

    if (!service)
        return Empty;

    Dictionary::Ptr vars = service->GetVars();

    ArrayData result;

    if (vars) {
        ObjectLock olock(vars);
        for (const Dictionary::Pair& kv : vars) {
            Value val;

            if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
                val = JsonEncode(kv.second);
            else
                val = kv.second;

            result.push_back(new Array({
                kv.first,
                val
            }));
        }
    }

    return new Array(std::move(result));
}
开发者ID:Icinga,项目名称:icinga2,代码行数:30,代码来源:servicestable.cpp

示例2: NotificationSentToAllUsersHandlerInternal

void ElasticsearchWriter::NotificationSentToAllUsersHandlerInternal(const Notification::Ptr& notification,
    const Checkable::Ptr& checkable, const std::set<User::Ptr>& users, NotificationType type,
    const CheckResult::Ptr& cr, const String& author, const String& text)
{
    AssertOnWorkQueue();

    CONTEXT("Elasticwriter processing notification to all users '" + checkable->GetName() + "'");

    Log(LogDebug, "ElasticsearchWriter")
        << "Processing notification for '" << checkable->GetName() << "'";

    Host::Ptr host;
    Service::Ptr service;
    tie(host, service) = GetHostService(checkable);

    String notificationTypeString = Notification::NotificationTypeToString(type);

    Dictionary::Ptr fields = new Dictionary();

    if (service) {
        fields->Set("service", service->GetShortName());
        fields->Set("state", service->GetState());
        fields->Set("last_state", service->GetLastState());
        fields->Set("last_hard_state", service->GetLastHardState());
    } else {
        fields->Set("state", host->GetState());
        fields->Set("last_state", host->GetLastState());
        fields->Set("last_hard_state", host->GetLastHardState());
    }

    fields->Set("host", host->GetName());

    ArrayData userNames;

    for (const User::Ptr& user : users) {
        userNames.push_back(user->GetName());
    }

    fields->Set("users", new Array(std::move(userNames)));
    fields->Set("notification_type", notificationTypeString);
    fields->Set("author", author);
    fields->Set("text", text);

    CheckCommand::Ptr commandObj = checkable->GetCheckCommand();

    if (commandObj)
        fields->Set("check_command", commandObj->GetName());

    double ts = Utility::GetTime();

    if (cr) {
        AddCheckResult(fields, checkable, cr);
        ts = cr->GetExecutionEnd();
    }

    Enqueue(checkable, "notification", fields, ts);
}
开发者ID:Icinga,项目名称:icinga2,代码行数:57,代码来源:elasticsearchwriter.cpp

示例3: ContactsAccessor

Value ServicesTable::ContactsAccessor(const Value& row)
{
    Service::Ptr service = static_cast<Service::Ptr>(row);

    if (!service)
        return Empty;

    ArrayData result;

    for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(service)) {
        result.push_back(user->GetName());
    }

    return new Array(std::move(result));
}
开发者ID:Icinga,项目名称:icinga2,代码行数:15,代码来源:servicestable.cpp

示例4: MembersAccessor

Value ServiceGroupsTable::MembersAccessor(const Value& row)
{
    ServiceGroup::Ptr sg = static_cast<ServiceGroup::Ptr>(row);

    if (!sg)
        return Empty;

    ArrayData result;

    for (const Service::Ptr& service : sg->GetMembers()) {
        result.push_back(new Array({
            service->GetHost()->GetName(),
            service->GetShortName()
        }));
    }

    return new Array(std::move(result));
}
开发者ID:dupondje,项目名称:icinga2,代码行数:18,代码来源:servicegroupstable.cpp

示例5: CommentsAccessor

Value ServicesTable::CommentsAccessor(const Value& row)
{
    Service::Ptr service = static_cast<Service::Ptr>(row);

    if (!service)
        return Empty;

    ArrayData result;

    for (const Comment::Ptr& comment : service->GetComments()) {
        if (comment->IsExpired())
            continue;

        result.push_back(comment->GetLegacyId());
    }

    return new Array(std::move(result));
}
开发者ID:Icinga,项目名称:icinga2,代码行数:18,代码来源:servicestable.cpp

示例6: NotificationSentToAllUsersHandler

void ClusterEvents::NotificationSentToAllUsersHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const std::set<User::Ptr>& users,
    NotificationType notificationType, const CheckResult::Ptr& cr, const String& author, const String& commentText, const MessageOrigin::Ptr& origin)
{
    ApiListener::Ptr listener = ApiListener::GetInstance();

    if (!listener)
        return;

    Host::Ptr host;
    Service::Ptr service;
    tie(host, service) = GetHostService(checkable);

    Dictionary::Ptr params = new Dictionary();
    params->Set("host", host->GetName());
    if (service)
        params->Set("service", service->GetShortName());
    params->Set("notification", notification->GetName());

    ArrayData ausers;
    for (const User::Ptr& user : users) {
        ausers.push_back(user->GetName());
    }
    params->Set("users", new Array(std::move(ausers)));

    params->Set("type", notificationType);
    params->Set("cr", Serialize(cr));
    params->Set("author", author);
    params->Set("text", commentText);

    params->Set("last_notification", notification->GetLastNotification());
    params->Set("next_notification", notification->GetNextNotification());
    params->Set("notification_number", notification->GetNotificationNumber());
    params->Set("last_problem_notification", notification->GetLastProblemNotification());
    params->Set("no_more_notifications", notification->GetNoMoreNotifications());

    Dictionary::Ptr message = new Dictionary();
    message->Set("jsonrpc", "2.0");
    message->Set("method", "event::NotificationSentToAllUsers");
    message->Set("params", params);

    listener->RelayMessage(origin, nullptr, message, true);
}
开发者ID:Icinga,项目名称:icinga2,代码行数:42,代码来源:clusterevents.cpp

示例7: CustomVariableNamesAccessor

Value ServicesTable::CustomVariableNamesAccessor(const Value& row)
{
    Service::Ptr service = static_cast<Service::Ptr>(row);

    if (!service)
        return Empty;

    Dictionary::Ptr vars = service->GetVars();

    ArrayData result;

    if (vars) {
        ObjectLock olock(vars);
        for (const Dictionary::Pair& kv : vars) {
            result.push_back(kv.first);
        }
    }

    return new Array(std::move(result));
}
开发者ID:Icinga,项目名称:icinga2,代码行数:20,代码来源:servicestable.cpp

示例8: CustomVariableValuesAccessor

Value CommandsTable::CustomVariableValuesAccessor(const Value& row)
{
    Command::Ptr command = static_cast<Command::Ptr>(row);

    if (!command)
        return Empty;

    Dictionary::Ptr vars = command->GetVars();

    ArrayData keys;

    if (vars) {
        ObjectLock xlock(vars);
        for (const auto& kv : vars) {
            keys.push_back(kv.second);
        }
    }

    return new Array(std::move(keys));
}
开发者ID:Icinga,项目名称:icinga2,代码行数:20,代码来源:commandstable.cpp

示例9: DowntimesWithInfoAccessor

Value ServicesTable::DowntimesWithInfoAccessor(const Value& row)
{
    Service::Ptr service = static_cast<Service::Ptr>(row);

    if (!service)
        return Empty;

    ArrayData result;

    for (const Downtime::Ptr& downtime : service->GetDowntimes()) {
        if (downtime->IsExpired())
            continue;

        result.push_back(new Array({
            downtime->GetLegacyId(),
            downtime->GetAuthor(),
            downtime->GetComment()
        }));
    }

    return new Array(std::move(result));
}
开发者ID:Icinga,项目名称:icinga2,代码行数:22,代码来源:servicestable.cpp

示例10: CustomVariablesAccessor

Value CommandsTable::CustomVariablesAccessor(const Value& row)
{
    Command::Ptr command = static_cast<Command::Ptr>(row);

    if (!command)
        return Empty;

    Dictionary::Ptr vars = command->GetVars();

    ArrayData result;

    if (vars) {
        ObjectLock xlock(vars);
        for (const auto& kv : vars) {
            result.push_back(new Array({
                kv.first,
                kv.second
            }));
        }
    }

    return new Array(std::move(result));
}
开发者ID:Icinga,项目名称:icinga2,代码行数:23,代码来源:commandstable.cpp

示例11: CommentsWithExtraInfoAccessor

Value ServicesTable::CommentsWithExtraInfoAccessor(const Value& row)
{
    Service::Ptr service = static_cast<Service::Ptr>(row);

    if (!service)
        return Empty;

    ArrayData result;

    for (const Comment::Ptr& comment : service->GetComments()) {
        if (comment->IsExpired())
            continue;

        result.push_back(new Array({
            comment->GetLegacyId(),
            comment->GetAuthor(),
            comment->GetText(),
            comment->GetEntryType(),
            static_cast<int>(comment->GetEntryTime())
        }));
    }

    return new Array(std::move(result));
}
开发者ID:Icinga,项目名称:icinga2,代码行数:24,代码来源:servicestable.cpp

示例12: HandleRequest


//.........这里部分代码省略.........
            continue;

        if (!allJoins && userJoinAttrs.find(field.NavigationName) == userJoinAttrs.end())
            continue;

        joinAttrs.insert(field.Name);
    }

    for (const ConfigObject::Ptr& obj : objs) {
        DictionaryData result1{
            { "name", obj->GetName() },
            { "type", obj->GetReflectionType()->GetName() }
        };

        DictionaryData metaAttrs;

        if (umetas) {
            ObjectLock olock(umetas);
            for (const String& meta : umetas) {
                if (meta == "used_by") {
                    Array::Ptr used_by = new Array();
                    metaAttrs.emplace_back("used_by", used_by);

                    for (const Object::Ptr& pobj : DependencyGraph::GetParents((obj)))
                    {
                        ConfigObject::Ptr configObj = dynamic_pointer_cast<ConfigObject>(pobj);

                        if (!configObj)
                            continue;

                        used_by->Add(new Dictionary({
                            { "type", configObj->GetReflectionType()->GetName() },
                            { "name", configObj->GetName() }
                        }));
                    }
                } else if (meta == "location") {
                    metaAttrs.emplace_back("location", obj->GetSourceLocation());
                } else {
                    HttpUtility::SendJsonError(response, params, 400, "Invalid field specified for meta: " + meta);
                    return true;
                }
            }
        }

        result1.emplace_back("meta", new Dictionary(std::move(metaAttrs)));

        try {
            result1.emplace_back("attrs", SerializeObjectAttrs(obj, String(), uattrs, false, false));
        } catch (const ScriptError& ex) {
            HttpUtility::SendJsonError(response, params, 400, ex.what());
            return true;
        }

        DictionaryData joins;

        for (const String& joinAttr : joinAttrs) {
            Object::Ptr joinedObj;
            int fid = type->GetFieldId(joinAttr);

            if (fid < 0) {
                HttpUtility::SendJsonError(response, params, 400, "Invalid field specified for join: " + joinAttr);
                return true;
            }

            Field field = type->GetFieldInfo(fid);

            if (!(field.Attributes & FANavigation)) {
                HttpUtility::SendJsonError(response, params, 400, "Not a joinable field: " + joinAttr);
                return true;
            }

            joinedObj = obj->NavigateField(fid);

            if (!joinedObj)
                continue;

            String prefix = field.NavigationName;

            try {
                joins.emplace_back(prefix, SerializeObjectAttrs(joinedObj, prefix, ujoins, true, allJoins));
            } catch (const ScriptError& ex) {
                HttpUtility::SendJsonError(response, params, 400, ex.what());
                return true;
            }
        }

        result1.emplace_back("joins", new Dictionary(std::move(joins)));

        results.push_back(new Dictionary(std::move(result1)));
    }

    Dictionary::Ptr result = new Dictionary({
        { "results", new Array(std::move(results)) }
    });

    response.SetStatus(200, "OK");
    HttpUtility::SendJsonBody(response, params, result);

    return true;
}
开发者ID:bebehei,项目名称:icinga2,代码行数:101,代码来源:objectqueryhandler.cpp

示例13: CheckResultAPIHandler

Value ClusterEvents::CheckResultAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
{
    Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();

    if (!endpoint) {
        Log(LogNotice, "ClusterEvents")
            << "Discarding 'check result' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
        return Empty;
    }

    CheckResult::Ptr cr;
    Array::Ptr vperf;

    if (params->Contains("cr")) {
        cr = new CheckResult();
        Dictionary::Ptr vcr = params->Get("cr");

        if (vcr && vcr->Contains("performance_data")) {
            vperf = vcr->Get("performance_data");

            if (vperf)
                vcr->Remove("performance_data");

            Deserialize(cr, vcr, true);
        }
    }

    if (!cr)
        return Empty;

    ArrayData rperf;

    if (vperf) {
        ObjectLock olock(vperf);
        for (const Value& vp : vperf) {
            Value p;

            if (vp.IsObjectType<Dictionary>()) {
                PerfdataValue::Ptr val = new PerfdataValue();
                Deserialize(val, vp, true);
                rperf.push_back(val);
            } else
                rperf.push_back(vp);
        }
    }

    cr->SetPerformanceData(new Array(std::move(rperf)));

    Host::Ptr host = Host::GetByName(params->Get("host"));

    if (!host)
        return Empty;

    Checkable::Ptr checkable;

    if (params->Contains("service"))
        checkable = host->GetServiceByShortName(params->Get("service"));
    else
        checkable = host;

    if (!checkable)
        return Empty;

    if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable) && endpoint != checkable->GetCommandEndpoint()) {
        Log(LogNotice, "ClusterEvents")
            << "Discarding 'check result' message for checkable '" << checkable->GetName()
            << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
        return Empty;
    }

    if (!checkable->IsPaused() && Zone::GetLocalZone() == checkable->GetZone() && endpoint == checkable->GetCommandEndpoint())
        checkable->ProcessCheckResult(cr);
    else
        checkable->ProcessCheckResult(cr, origin);

    return Empty;
}
开发者ID:Icinga,项目名称:icinga2,代码行数:77,代码来源:clusterevents.cpp

示例14: NotificationSentToAllUsersAPIHandler

Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
{
    Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();

    if (!endpoint) {
        Log(LogNotice, "ClusterEvents")
            << "Discarding 'sent notification to all users' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
        return Empty;
    }

    Host::Ptr host = Host::GetByName(params->Get("host"));

    if (!host)
        return Empty;

    Checkable::Ptr checkable;

    if (params->Contains("service"))
        checkable = host->GetServiceByShortName(params->Get("service"));
    else
        checkable = host;

    if (!checkable)
        return Empty;

    if (origin->FromZone && origin->FromZone != Zone::GetLocalZone()) {
        Log(LogNotice, "ClusterEvents")
            << "Discarding 'sent notification to all users' message for checkable '" << checkable->GetName()
            << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
        return Empty;
    }

    CheckResult::Ptr cr;
    Array::Ptr vperf;

    if (params->Contains("cr")) {
        cr = new CheckResult();
        Dictionary::Ptr vcr = params->Get("cr");

        if (vcr && vcr->Contains("performance_data")) {
            vperf = vcr->Get("performance_data");

            if (vperf)
                vcr->Remove("performance_data");

            Deserialize(cr, vcr, true);
        }
    }

    NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
    String author = params->Get("author");
    String text = params->Get("text");

    Notification::Ptr notification = Notification::GetByName(params->Get("notification"));

    if (!notification)
        return Empty;

    Array::Ptr ausers = params->Get("users");

    if (!ausers)
        return Empty;

    std::set<User::Ptr> users;

    {
        ObjectLock olock(ausers);
        for (const String& auser : ausers) {
            User::Ptr user = User::GetByName(auser);

            if (!user)
                continue;

            users.insert(user);
        }
    }

    notification->SetLastNotification(params->Get("last_notification"));
    notification->SetNextNotification(params->Get("next_notification"));
    notification->SetNotificationNumber(params->Get("notification_number"));
    notification->SetLastProblemNotification(params->Get("last_problem_notification"));
    notification->SetNoMoreNotifications(params->Get("no_more_notifications"));

    ArrayData notifiedProblemUsers;
    for (const User::Ptr& user : users) {
        notifiedProblemUsers.push_back(user->GetName());
    }

    notification->SetNotifiedProblemUsers(new Array(std::move(notifiedProblemUsers)));

    Checkable::OnNotificationSentToAllUsers(notification, checkable, users, type, cr, author, text, origin);

    return Empty;
}
开发者ID:Icinga,项目名称:icinga2,代码行数:94,代码来源:clusterevents.cpp


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