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


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

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


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

示例1: OnConfigUpdate

void ServiceDbObject::OnConfigUpdate(void)
{
	Service::Ptr service = static_pointer_cast<Service>(GetObject());

	/* service dependencies */
	Log(LogDebug, "db_ido", "service dependencies for '" + service->GetName() + "'");

	BOOST_FOREACH(const Dependency::Ptr& dep, service->GetDependencies()) {
		Checkable::Ptr parent = dep->GetParent();

		if (!parent)
			continue;

		Log(LogDebug, "db_ido", "service parents: " + parent->GetName());

		int state_filter = dep->GetStateFilter();

		/* service dependencies */
		Dictionary::Ptr fields1 = make_shared<Dictionary>();
		fields1->Set("service_object_id", parent);
		fields1->Set("dependent_service_object_id", service);
		fields1->Set("inherits_parent", 1);
		fields1->Set("timeperiod_object_id", dep->GetPeriod());
		fields1->Set("fail_on_ok", (state_filter & StateFilterOK) ? 1 : 0);
		fields1->Set("fail_on_warning", (state_filter & StateFilterWarning) ? 1 : 0);
		fields1->Set("fail_on_critical", (state_filter & StateFilterCritical) ? 1 : 0);
		fields1->Set("fail_on_unknown", (state_filter & StateFilterUnknown) ? 1 : 0);
		fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */

		DbQuery query1;
		query1.Table = GetType()->GetTable() + "dependencies";
		query1.Type = DbQueryInsert;
		query1.Category = DbCatConfig;
		query1.Fields = fields1;
		OnQuery(query1);
	}

	/* service contacts, contactgroups */
	Log(LogDebug, "db_ido", "service contacts: " + service->GetName());

	BOOST_FOREACH(const User::Ptr& user, CompatUtility::GetCheckableNotificationUsers(service)) {
		Log(LogDebug, "db_ido", "service contacts: " + user->GetName());

		Dictionary::Ptr fields_contact = make_shared<Dictionary>();
		fields_contact->Set("service_id", DbValue::FromObjectInsertID(service));
		fields_contact->Set("contact_object_id", user);
		fields_contact->Set("instance_id", 0); /* DbConnection class fills in real ID */

		DbQuery query_contact;
		query_contact.Table = GetType()->GetTable() + "_contacts";
		query_contact.Type = DbQueryInsert;
		query_contact.Category = DbCatConfig;
		query_contact.Fields = fields_contact;
		OnQuery(query_contact);
	}
开发者ID:nv1r,项目名称:icinga2,代码行数:55,代码来源:servicedbobject.cpp

示例2: CalculateConfigHash

String ServiceDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) const
{
	String hashData = DbObject::CalculateConfigHash(configFields);

	Service::Ptr service = static_pointer_cast<Service>(GetObject());

	Array::Ptr groups = service->GetGroups();

	if (groups)
		hashData += DbObject::HashValue(groups);

	Array::Ptr dependencies = new Array();

	/* dependencies */
	for (const Dependency::Ptr& dep : service->GetDependencies()) {
		Checkable::Ptr parent = dep->GetParent();

		if (!parent)
			continue;

		Array::Ptr depInfo = new Array();
		depInfo->Add(parent->GetName());
		depInfo->Add(dep->GetStateFilter());
		depInfo->Add(dep->GetPeriodRaw());

		dependencies->Add(depInfo);
	}

	dependencies->Sort();

	hashData += DbObject::HashValue(dependencies);

	Array::Ptr users = new Array();

	for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(service)) {
		users->Add(user->GetName());
	}

	users->Sort();

	hashData += DbObject::HashValue(users);

	Array::Ptr userGroups = new Array();

	for (const UserGroup::Ptr& usergroup : CompatUtility::GetCheckableNotificationUserGroups(service)) {
		userGroups->Add(usergroup->GetName());
	}

	userGroups->Sort();

	hashData += DbObject::HashValue(userGroups);

	return SHA256(hashData);
}
开发者ID:TheFlyingCorpse,项目名称:icinga2,代码行数:54,代码来源:servicedbobject.cpp

示例3: OnConfigUpdateHeavy

void ServiceDbObject::OnConfigUpdateHeavy(void)
{
	Service::Ptr service = static_pointer_cast<Service>(GetObject());

	/* groups */
	Array::Ptr groups = service->GetGroups();

	std::vector<DbQuery> queries;

	DbQuery query1;
	query1.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
	query1.Type = DbQueryDelete;
	query1.Category = DbCatConfig;
	query1.WhereCriteria = new Dictionary();
	query1.WhereCriteria->Set("service_object_id", service);

	queries.push_back(query1);

	if (groups) {
		ObjectLock olock(groups);
		for (const String& groupName : groups) {
			ServiceGroup::Ptr group = ServiceGroup::GetByName(groupName);

			DbQuery query2;
			query2.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
			query2.Type = DbQueryInsert;
			query2.Category = DbCatConfig;
			query2.Fields = new Dictionary();
			query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
			query2.Fields->Set("servicegroup_id", DbValue::FromObjectInsertID(group));
			query2.Fields->Set("service_object_id", service);
			query2.WhereCriteria = new Dictionary();
			query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
			query2.WhereCriteria->Set("servicegroup_id", DbValue::FromObjectInsertID(group));
			query2.WhereCriteria->Set("service_object_id", service);

			queries.push_back(query2);
		}
	}

	DbObject::OnMultipleQueries(queries);

	/* service dependencies */
	Log(LogDebug, "ServiceDbObject")
	    << "service dependencies for '" << service->GetName() << "'";

	queries.clear();

	DbQuery query2;
	query2.Table = GetType()->GetTable() + "dependencies";
	query2.Type = DbQueryDelete;
	query2.Category = DbCatConfig;
	query2.WhereCriteria = new Dictionary();
	query2.WhereCriteria->Set("dependent_service_object_id", service);

	queries.push_back(query2);

	for (const Dependency::Ptr& dep : service->GetDependencies()) {
		Checkable::Ptr parent = dep->GetParent();

		if (!parent) {
			Log(LogDebug, "ServiceDbObject")
			    << "Missing parent for dependency '" << dep->GetName() << "'.";
			continue;
		}

		Log(LogDebug, "ServiceDbObject")
		    << "service parents: " << parent->GetName();

		int state_filter = dep->GetStateFilter();

		/* service dependencies */
		Dictionary::Ptr fields1 = new Dictionary();
		fields1->Set("service_object_id", parent);
		fields1->Set("dependent_service_object_id", service);
		fields1->Set("inherits_parent", 1);
		fields1->Set("timeperiod_object_id", dep->GetPeriod());
		fields1->Set("fail_on_ok", (state_filter & StateFilterOK) ? 1 : 0);
		fields1->Set("fail_on_warning", (state_filter & StateFilterWarning) ? 1 : 0);
		fields1->Set("fail_on_critical", (state_filter & StateFilterCritical) ? 1 : 0);
		fields1->Set("fail_on_unknown", (state_filter & StateFilterUnknown) ? 1 : 0);
		fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */

		DbQuery query1;
		query1.Table = GetType()->GetTable() + "dependencies";
		query1.Type = DbQueryInsert;
		query1.Category = DbCatConfig;
		query1.Fields = fields1;

		queries.push_back(query1);
	}

	DbObject::OnMultipleQueries(queries);

	/* service contacts, contactgroups */
	Log(LogDebug, "ServiceDbObject")
	    << "service contacts: " << service->GetName();

	queries.clear();

//.........这里部分代码省略.........
开发者ID:TheFlyingCorpse,项目名称:icinga2,代码行数:101,代码来源:servicedbobject.cpp


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