本文整理汇总了C++中array::Ptr::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::Add方法的具体用法?C++ Ptr::Add怎么用?C++ Ptr::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array::Ptr
的用法示例。
在下文中一共展示了Ptr::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: olock
static Array::Ptr DictionaryKeys(void)
{
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
Array::Ptr keys = new Array();
ObjectLock olock(self);
for (const Dictionary::Pair& kv : self) {
keys->Add(kv.first);
}
return keys;
}
示例2: DeleteObject
bool ConfigObjectUtility::DeleteObject(const ConfigObject::Ptr& object, bool cascade, const Array::Ptr& errors)
{
if (object->GetPackage() != "_api") {
if (errors)
errors->Add("Object cannot be deleted because it was not created using the API.");
return false;
}
return DeleteObjectHelper(object, cascade, errors);
}
示例3: StatsFunc
void CheckerComponent::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
{
Dictionary::Ptr nodes = new Dictionary();
for (const CheckerComponent::Ptr& checker : ConfigType::GetObjectsByType<CheckerComponent>()) {
unsigned long idle = checker->GetIdleCheckables();
unsigned long pending = checker->GetPendingCheckables();
Dictionary::Ptr stats = new Dictionary();
stats->Set("idle", idle);
stats->Set("pending", pending);
nodes->Set(checker->GetName(), stats);
String perfdata_prefix = "checkercomponent_" + checker->GetName() + "_";
perfdata->Add(new PerfdataValue(perfdata_prefix + "idle", Convert::ToDouble(idle)));
perfdata->Add(new PerfdataValue(perfdata_prefix + "pending", Convert::ToDouble(pending)));
}
status->Set("checkercomponent", nodes);
}
示例4: FromJson
/**
* Converts a JSON object to an array.
*
* @param json The JSON object.
* @returns An array that is equivalent to the JSON object.
*/
Array::Ptr Array::FromJson(cJSON *json)
{
Array::Ptr array = make_shared<Array>();
ASSERT(json->type == cJSON_Array);
for (cJSON *i = json->child; i != NULL; i = i->next) {
array->Add(Value::FromJson(i));
}
return array;
}
示例5: StatsFunc
void IdoPgsqlConnection::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
{
Dictionary::Ptr nodes = new Dictionary();
BOOST_FOREACH(const IdoPgsqlConnection::Ptr& idopgsqlconnection, ConfigType::GetObjectsByType<IdoPgsqlConnection>()) {
size_t items = idopgsqlconnection->m_QueryQueue.GetLength();
Dictionary::Ptr stats = new Dictionary();
stats->Set("version", idopgsqlconnection->GetSchemaVersion());
stats->Set("connected", idopgsqlconnection->GetConnected());
stats->Set("instance_name", idopgsqlconnection->GetInstanceName());
stats->Set("query_queue_items", items);
nodes->Set(idopgsqlconnection->GetName(), stats);
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_queries_rate", idopgsqlconnection->GetQueryCount(60) / 60.0));
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_queries_1min", idopgsqlconnection->GetQueryCount(60)));
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_queries_5mins", idopgsqlconnection->GetQueryCount(5 * 60)));
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_queries_15mins", idopgsqlconnection->GetQueryCount(15 * 60)));
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_query_queue_items", items));
}
示例6: StatsFunc
void IdoPgsqlConnection::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
{
DictionaryData nodes;
for (const IdoPgsqlConnection::Ptr& idopgsqlconnection : ConfigType::GetObjectsByType<IdoPgsqlConnection>()) {
size_t queryQueueItems = idopgsqlconnection->m_QueryQueue.GetLength();
double queryQueueItemRate = idopgsqlconnection->m_QueryQueue.GetTaskCount(60) / 60.0;
nodes.emplace_back(idopgsqlconnection->GetName(), new Dictionary({
{ "version", idopgsqlconnection->GetSchemaVersion() },
{ "instance_name", idopgsqlconnection->GetInstanceName() },
{ "connected", idopgsqlconnection->GetConnected() },
{ "query_queue_items", queryQueueItems },
{ "query_queue_item_rate", queryQueueItemRate }
}));
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_queries_rate", idopgsqlconnection->GetQueryCount(60) / 60.0));
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_queries_1min", idopgsqlconnection->GetQueryCount(60)));
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_queries_5mins", idopgsqlconnection->GetQueryCount(5 * 60)));
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_queries_15mins", idopgsqlconnection->GetQueryCount(15 * 60)));
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_query_queue_items", queryQueueItems));
perfdata->Add(new PerfdataValue("idopgsqlconnection_" + idopgsqlconnection->GetName() + "_query_queue_item_rate", queryQueueItemRate));
}
status->Set("idopgsqlconnection", new Dictionary(std::move(nodes)));
}
示例7: AddImport
void ScriptFrame::AddImport(const Object::Ptr& import)
{
Array::Ptr imports;
if (!m_Imports)
imports = new Array();
else
imports = m_Imports->ShallowClone();
imports->Add(import);
m_Imports = imports;
}
示例8: StatsFunc
void InfluxdbWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
{
DictionaryData nodes;
for (const InfluxdbWriter::Ptr& influxdbwriter : ConfigType::GetObjectsByType<InfluxdbWriter>()) {
size_t workQueueItems = influxdbwriter->m_WorkQueue.GetLength();
double workQueueItemRate = influxdbwriter->m_WorkQueue.GetTaskCount(60) / 60.0;
size_t dataBufferItems = influxdbwriter->m_DataBuffer.size();
nodes.emplace_back(influxdbwriter->GetName(), new Dictionary({
{ "work_queue_items", workQueueItems },
{ "work_queue_item_rate", workQueueItemRate },
{ "data_buffer_items", dataBufferItems }
}));
perfdata->Add(new PerfdataValue("influxdbwriter_" + influxdbwriter->GetName() + "_work_queue_items", workQueueItems));
perfdata->Add(new PerfdataValue("influxdbwriter_" + influxdbwriter->GetName() + "_work_queue_item_rate", workQueueItemRate));
perfdata->Add(new PerfdataValue("influxdbwriter_" + influxdbwriter->GetName() + "_data_queue_items", dataBufferItems));
}
status->Set("influxdbwriter", new Dictionary(std::move(nodes)));
}
示例9: Keys
Array::Ptr ScriptUtils::Keys(const Dictionary::Ptr& dict)
{
Array::Ptr result = new Array();
if (dict) {
ObjectLock olock(dict);
for (const Dictionary::Pair& kv : dict) {
result->Add(kv.first);
}
}
return result;
}
示例10: EvaluateApplyRule
bool Service::EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule)
{
DebugInfo di = rule.GetDebugInfo();
std::ostringstream msgbuf;
msgbuf << "Evaluating 'apply' rule (" << di << ")";
CONTEXT(msgbuf.str());
ScriptFrame frame;
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);
Value vinstances;
if (rule.GetFTerm()) {
try {
vinstances = rule.GetFTerm()->Evaluate(frame);
} catch (const std::exception&) {
/* Silently ignore errors here and assume there are no instances. */
return false;
}
} else {
Array::Ptr instances = new Array();
instances->Add("");
vinstances = instances;
}
bool match = false;
if (vinstances.IsObjectType<Array>()) {
if (!rule.GetFVVar().IsEmpty())
BOOST_THROW_EXCEPTION(ScriptError("Dictionary iterator requires value to be a dictionary.", di));
Array::Ptr arr = vinstances;
Array::Ptr arrclone = arr->ShallowClone();
ObjectLock olock(arrclone);
BOOST_FOREACH(const Value& instance, arrclone) {
String name = rule.GetName();
if (!rule.GetFKVar().IsEmpty()) {
frame.Locals->Set(rule.GetFKVar(), instance);
name += instance;
}
if (EvaluateApplyRuleInstance(host, name, frame, rule))
match = true;
}
} else if (vinstances.IsObjectType<Dictionary>()) {
示例11: DoEvaluate
ExpressionResult ArrayExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
Array::Ptr result = new Array();
result->Reserve(m_Expressions.size());
for (Expression *aexpr : m_Expressions) {
ExpressionResult element = aexpr->Evaluate(frame);
CHECK_RESULT(element);
result->Add(element.GetValue());
}
return result;
}
示例12: EvaluateApplyRule
bool ScheduledDowntime::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule)
{
DebugInfo di = rule.GetDebugInfo();
std::ostringstream msgbuf;
msgbuf << "Evaluating 'apply' rule (" << di << ")";
CONTEXT(msgbuf.str());
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
VMFrame frame;
if (rule.GetScope())
rule.GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("host", host);
if (service)
frame.Locals->Set("service", service);
if (!rule.EvaluateFilter(frame))
return false;
Value vinstances;
if (rule.GetFTerm()) {
vinstances = rule.GetFTerm()->Evaluate(frame);
} else {
Array::Ptr instances = new Array();
instances->Add("");
vinstances = instances;
}
if (vinstances.IsObjectType<Array>()) {
if (!rule.GetFVVar().IsEmpty())
BOOST_THROW_EXCEPTION(ConfigError("Array iterator requires value to be an array.") << errinfo_debuginfo(di));
Array::Ptr arr = vinstances;
ObjectLock olock(arr);
BOOST_FOREACH(const String& instance, arr) {
String name = rule.GetName();
if (!rule.GetFKVar().IsEmpty()) {
frame.Locals->Set(rule.GetFKVar(), instance);
name += instance;
}
EvaluateApplyRuleInstance(checkable, name, frame, rule);
}
} else if (vinstances.IsObjectType<Dictionary>()) {
示例13: AddGroup
void User::AddGroup(const String& name)
{
boost::mutex::scoped_lock lock(m_UserMutex);
Array::Ptr groups = GetGroups();
if (groups && groups->Contains(name))
return;
if (!groups)
groups = new Array();
groups->Add(name);
}
示例14: StartReloadProcess
pid_t Application::StartReloadProcess(void)
{
Log(LogInformation, "Application", "Got reload command: Starting new instance.");
// prepare arguments
Array::Ptr args = new Array();
args->Add(GetExePath(m_ArgV[0]));
for (int i=1; i < Application::GetArgC(); i++) {
if (std::string(Application::GetArgV()[i]) != "--reload-internal")
args->Add(Application::GetArgV()[i]);
else
i++; // the next parameter after --reload-internal is the pid, remove that too
}
args->Add("--reload-internal");
args->Add(Convert::ToString(Utility::GetPid()));
Process::Ptr process = new Process(Process::PrepareCommand(args));
process->SetTimeout(300);
process->Run(&ReloadProcessCallback);
return process->GetPID();
}
示例15: CustomVariableNamesAccessor
Value StatusTable::CustomVariableNamesAccessor(const Value&)
{
Dictionary::Ptr vars = IcingaApplication::GetInstance()->GetVars();
if (!vars)
return Empty;
Array::Ptr cv = new Array();
String key;
Value value;
BOOST_FOREACH(tie(key, value), vars) {
cv->Add(key);
}