mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-24 02:07:53 +02:00
IDO: Use move/swap semantics where applicable
This commit is contained in:
parent
9dda06b188
commit
f1c2c0bcb9
@ -53,7 +53,7 @@ void ScriptGlobal::Set(const String& name, const Value& value)
|
|||||||
if (!parent->Get(token, &vparent)) {
|
if (!parent->Get(token, &vparent)) {
|
||||||
Namespace::Ptr dict = new Namespace();
|
Namespace::Ptr dict = new Namespace();
|
||||||
parent->Set(token, dict);
|
parent->Set(token, dict);
|
||||||
parent = dict;
|
parent = std::move(dict);
|
||||||
} else {
|
} else {
|
||||||
parent = vparent;
|
parent = vparent;
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ void DbConnection::UpdateObject(const ConfigObject::Ptr& object)
|
|||||||
} else {
|
} else {
|
||||||
dbobj->SendConfigUpdateLight();
|
dbobj->SendConfigUpdateLight();
|
||||||
}
|
}
|
||||||
} else if (!active) {
|
} else {
|
||||||
/* This may happen on reload/restart actions too
|
/* This may happen on reload/restart actions too
|
||||||
* and is blocked above already.
|
* and is blocked above already.
|
||||||
*
|
*
|
||||||
|
@ -401,7 +401,7 @@ void DbEvents::AddCommentInternal(std::vector<DbQuery>& queries, const Comment::
|
|||||||
}
|
}
|
||||||
|
|
||||||
query1.Category = DbCatComment;
|
query1.Category = DbCatComment;
|
||||||
query1.Fields = fields1;
|
query1.Fields = std::move(fields1);
|
||||||
queries.emplace_back(std::move(query1));
|
queries.emplace_back(std::move(query1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,7 +548,7 @@ void DbEvents::AddDowntimeInternal(std::vector<DbQuery>& queries, const Downtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
query1.Category = DbCatDowntime;
|
query1.Category = DbCatDowntime;
|
||||||
query1.Fields = fields1;
|
query1.Fields = std::move(fields1);
|
||||||
queries.emplace_back(std::move(query1));
|
queries.emplace_back(std::move(query1));
|
||||||
|
|
||||||
/* host/service status */
|
/* host/service status */
|
||||||
@ -576,7 +576,7 @@ void DbEvents::AddDowntimeInternal(std::vector<DbQuery>& queries, const Downtime
|
|||||||
Dictionary::Ptr fields2 = new Dictionary();
|
Dictionary::Ptr fields2 = new Dictionary();
|
||||||
fields2->Set("scheduled_downtime_depth", checkable->GetDowntimeDepth());
|
fields2->Set("scheduled_downtime_depth", checkable->GetDowntimeDepth());
|
||||||
|
|
||||||
query2.Fields = fields2;
|
query2.Fields = std::move(fields2);
|
||||||
query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||||
|
|
||||||
queries.emplace_back(std::move(query2));
|
queries.emplace_back(std::move(query2));
|
||||||
@ -609,9 +609,6 @@ void DbEvents::RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downt
|
|||||||
query1.WhereCriteria->Set("name", downtime->GetName());
|
query1.WhereCriteria->Set("name", downtime->GetName());
|
||||||
queries.emplace_back(std::move(query1));
|
queries.emplace_back(std::move(query1));
|
||||||
|
|
||||||
/* History - update actual_end_time, was_cancelled for service (and host in case) */
|
|
||||||
std::pair<unsigned long, unsigned long> timeBag = ConvertTimestamp(Utility::GetTime());
|
|
||||||
|
|
||||||
DbQuery query3;
|
DbQuery query3;
|
||||||
query3.Table = "downtimehistory";
|
query3.Table = "downtimehistory";
|
||||||
query3.Type = DbQueryUpdate;
|
query3.Type = DbQueryUpdate;
|
||||||
@ -621,12 +618,15 @@ void DbEvents::RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downt
|
|||||||
fields3->Set("was_cancelled", downtime->GetWasCancelled() ? 1 : 0);
|
fields3->Set("was_cancelled", downtime->GetWasCancelled() ? 1 : 0);
|
||||||
|
|
||||||
if (downtime->GetFixed() || (!downtime->GetFixed() && downtime->GetTriggerTime() > 0)) {
|
if (downtime->GetFixed() || (!downtime->GetFixed() && downtime->GetTriggerTime() > 0)) {
|
||||||
|
/* History - update actual_end_time, was_cancelled for service (and host in case) */
|
||||||
|
std::pair<unsigned long, unsigned long> timeBag = ConvertTimestamp(Utility::GetTime());
|
||||||
|
|
||||||
fields3->Set("actual_end_time", DbValue::FromTimestamp(timeBag.first));
|
fields3->Set("actual_end_time", DbValue::FromTimestamp(timeBag.first));
|
||||||
fields3->Set("actual_end_time_usec", timeBag.second);
|
fields3->Set("actual_end_time_usec", timeBag.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
fields3->Set("is_in_effect", 0);
|
fields3->Set("is_in_effect", 0);
|
||||||
query3.Fields = fields3;
|
query3.Fields = std::move(fields3);
|
||||||
|
|
||||||
query3.WhereCriteria = new Dictionary({
|
query3.WhereCriteria = new Dictionary({
|
||||||
{ "object_id", checkable },
|
{ "object_id", checkable },
|
||||||
@ -663,7 +663,7 @@ void DbEvents::RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downt
|
|||||||
Dictionary::Ptr fields4 = new Dictionary();
|
Dictionary::Ptr fields4 = new Dictionary();
|
||||||
fields4->Set("scheduled_downtime_depth", checkable->GetDowntimeDepth());
|
fields4->Set("scheduled_downtime_depth", checkable->GetDowntimeDepth());
|
||||||
|
|
||||||
query4.Fields = fields4;
|
query4.Fields = std::move(fields4);
|
||||||
query4.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
query4.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||||
|
|
||||||
queries.emplace_back(std::move(query4));
|
queries.emplace_back(std::move(query4));
|
||||||
@ -787,7 +787,7 @@ void DbEvents::AddAcknowledgementHistory(const Checkable::Ptr& checkable, const
|
|||||||
if (endpoint)
|
if (endpoint)
|
||||||
fields1->Set("endpoint_object_id", endpoint);
|
fields1->Set("endpoint_object_id", endpoint);
|
||||||
|
|
||||||
query1.Fields = fields1;
|
query1.Fields = std::move(fields1);
|
||||||
DbObject::OnQuery(query1);
|
DbObject::OnQuery(query1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -959,7 +959,7 @@ void DbEvents::AddStateChangeHistory(const Checkable::Ptr& checkable, const Chec
|
|||||||
if (endpoint)
|
if (endpoint)
|
||||||
fields1->Set("endpoint_object_id", endpoint);
|
fields1->Set("endpoint_object_id", endpoint);
|
||||||
|
|
||||||
query1.Fields = fields1;
|
query1.Fields = std::move(fields1);
|
||||||
DbObject::OnQuery(query1);
|
DbObject::OnQuery(query1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1260,7 +1260,7 @@ void DbEvents::AddLogHistory(const Checkable::Ptr& checkable, const String& buff
|
|||||||
if (endpoint)
|
if (endpoint)
|
||||||
fields1->Set("endpoint_object_id", endpoint);
|
fields1->Set("endpoint_object_id", endpoint);
|
||||||
|
|
||||||
query1.Fields = fields1;
|
query1.Fields = std::move(fields1);
|
||||||
DbObject::OnQuery(query1);
|
DbObject::OnQuery(query1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1303,7 +1303,7 @@ void DbEvents::AddFlappingChangedHistory(const Checkable::Ptr& checkable)
|
|||||||
if (endpoint)
|
if (endpoint)
|
||||||
fields1->Set("endpoint_object_id", endpoint);
|
fields1->Set("endpoint_object_id", endpoint);
|
||||||
|
|
||||||
query1.Fields = fields1;
|
query1.Fields = std::move(fields1);
|
||||||
DbObject::OnQuery(query1);
|
DbObject::OnQuery(query1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1343,7 +1343,7 @@ void DbEvents::AddEnableFlappingChangedHistory(const Checkable::Ptr& checkable)
|
|||||||
if (endpoint)
|
if (endpoint)
|
||||||
fields1->Set("endpoint_object_id", endpoint);
|
fields1->Set("endpoint_object_id", endpoint);
|
||||||
|
|
||||||
query1.Fields = fields1;
|
query1.Fields = std::move(fields1);
|
||||||
DbObject::OnQuery(query1);
|
DbObject::OnQuery(query1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1403,7 +1403,7 @@ void DbEvents::AddCheckableCheckHistory(const Checkable::Ptr& checkable, const C
|
|||||||
if (endpoint)
|
if (endpoint)
|
||||||
fields1->Set("endpoint_object_id", endpoint);
|
fields1->Set("endpoint_object_id", endpoint);
|
||||||
|
|
||||||
query1.Fields = fields1;
|
query1.Fields = std::move(fields1);
|
||||||
DbObject::OnQuery(query1);
|
DbObject::OnQuery(query1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1446,7 +1446,7 @@ void DbEvents::AddEventHandlerHistory(const Checkable::Ptr& checkable)
|
|||||||
if (endpoint)
|
if (endpoint)
|
||||||
fields1->Set("endpoint_object_id", endpoint);
|
fields1->Set("endpoint_object_id", endpoint);
|
||||||
|
|
||||||
query1.Fields = fields1;
|
query1.Fields = std::move(fields1);
|
||||||
DbObject::OnQuery(query1);
|
DbObject::OnQuery(query1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1471,7 +1471,7 @@ void DbEvents::AddExternalCommandHistory(double time, const String& command, con
|
|||||||
if (endpoint)
|
if (endpoint)
|
||||||
fields1->Set("endpoint_object_id", endpoint);
|
fields1->Set("endpoint_object_id", endpoint);
|
||||||
|
|
||||||
query1.Fields = fields1;
|
query1.Fields = std::move(fields1);
|
||||||
DbObject::OnQuery(query1);
|
DbObject::OnQuery(query1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ void DbObject::SendStatusUpdate()
|
|||||||
query.Table = GetType()->GetTable() + "status";
|
query.Table = GetType()->GetTable() + "status";
|
||||||
query.Type = DbQueryInsert | DbQueryUpdate;
|
query.Type = DbQueryInsert | DbQueryUpdate;
|
||||||
query.Category = DbCatState;
|
query.Category = DbCatState;
|
||||||
query.Fields = fields;
|
query.Fields = std::move(fields);
|
||||||
query.Fields->Set(GetType()->GetIDColumn(), GetObject());
|
query.Fields->Set(GetType()->GetIDColumn(), GetObject());
|
||||||
|
|
||||||
/* do not override endpoint_object_id for endpoints & zones */
|
/* do not override endpoint_object_id for endpoints & zones */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user