本文整理汇总了C++中service::Ptr::GetParentServices方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::GetParentServices方法的具体用法?C++ Ptr::GetParentServices怎么用?C++ Ptr::GetParentServices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类service::Ptr
的用法示例。
在下文中一共展示了Ptr::GetParentServices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnConfigUpdate
void ServiceDbObject::OnConfigUpdate(void)
{
Service::Ptr service = static_pointer_cast<Service>(GetObject());
/* service dependencies */
Log(LogDebug, "ido", "service dependencies for '" + service->GetName() + "'");
DbQuery query_del1;
query_del1.Table = GetType()->GetTable() + "dependencies";
query_del1.Type = DbQueryDelete;
query_del1.WhereCriteria = boost::make_shared<Dictionary>();
query_del1.WhereCriteria->Set("dependent_service_object_id", service);
OnQuery(query_del1);
BOOST_FOREACH(const Service::Ptr& parent, service->GetParentServices()) {
Log(LogDebug, "ido", "service parents: " + parent->GetName());
/* service dependencies */
Dictionary::Ptr fields1 = boost::make_shared<Dictionary>();
fields1->Set("service_object_id", parent);
fields1->Set("dependent_service_object_id", service);
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
DbQuery query1;
query1.Table = GetType()->GetTable() + "dependencies";
query1.Type = DbQueryInsert;
query1.Fields = fields1;
OnQuery(query1);
}
/* custom variables */
Log(LogDebug, "ido", "service customvars for '" + service->GetName() + "'");
DbQuery query_del2;
query_del2.Table = "customvariables";
query_del2.Type = DbQueryDelete;
query_del2.WhereCriteria = boost::make_shared<Dictionary>();
query_del2.WhereCriteria->Set("object_id", service);
OnQuery(query_del2);
Dictionary::Ptr customvars;
{
ObjectLock olock(service);
customvars = CompatUtility::GetCustomVariableConfig(service);
}
if (customvars) {
ObjectLock olock (customvars);
String key;
Value value;
BOOST_FOREACH(boost::tie(key, value), customvars) {
Log(LogDebug, "ido", "service customvar key: '" + key + "' value: '" + Convert::ToString(value) + "'");
Dictionary::Ptr fields2 = boost::make_shared<Dictionary>();
fields2->Set("varname", Convert::ToString(key));
fields2->Set("varvalue", Convert::ToString(value));
fields2->Set("config_type", 1);
fields2->Set("has_been_modified", 0);
fields2->Set("object_id", service);
fields2->Set("instance_id", 0); /* DbConnection class fills in real ID */
DbQuery query2;
query2.Table = "customvariables";
query2.Type = DbQueryInsert;
query2.Fields = fields2;
OnQuery(query2);
}
}