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


C++ Ptr::GetParentServices方法代码示例

本文整理汇总了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);
		}
	}
开发者ID:palli,项目名称:icinga2,代码行数:70,代码来源:servicedbobject.cpp


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