• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ user::Ptr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中user::Ptr的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: OnConfigUpdate

void UserDbObject::OnConfigUpdate(void)
{
	Dictionary::Ptr fields = make_shared<Dictionary>();
	User::Ptr user = static_pointer_cast<User>(GetObject());

	/* contact addresses */
	Log(LogDebug, "UserDbObject", "contact addresses for '" + user->GetName() + "'");

	Dictionary::Ptr vars = user->GetVars();

	if (vars) { /* This is sparta. */
		for (int i = 1; i <= 6; i++) {
			String key = "address" + Convert::ToString(i);
			String val = vars->Get(key);

			if (val.IsEmpty())
				continue;

			fields->Set("contact_id", DbValue::FromObjectInsertID(user));
			fields->Set("address_number", i);
			fields->Set("address", val);
			fields->Set("instance_id", 0); /* DbConnection class fills in real ID */

			DbQuery query;
			query.Type = DbQueryInsert;
			query.Table = "contact_addresses";
			query.Fields = fields;
			OnQuery(query);
		}
	}
}
开发者ID:3v,项目名称:icinga2,代码行数:31,代码来源:userdbobject.cpp


示例2: GetConfigFields

Dictionary::Ptr UserDbObject::GetConfigFields(void) const
{
	Dictionary::Ptr fields = new Dictionary();
	User::Ptr user = static_pointer_cast<User>(GetObject());

	fields->Set("alias", user->GetDisplayName());
	fields->Set("email_address", user->GetEmail());
	fields->Set("pager_address", user->GetPager());
	fields->Set("host_timeperiod_object_id", user->GetPeriod());
	fields->Set("service_timeperiod_object_id", user->GetPeriod());
	fields->Set("host_notifications_enabled", user->GetEnableNotifications());
	fields->Set("service_notifications_enabled", user->GetEnableNotifications());
	fields->Set("can_submit_commands", 1);

	int typeFilter = user->GetTypeFilter();
	int stateFilter = user->GetStateFilter();

	fields->Set("notify_service_recovery", (typeFilter & NotificationRecovery) != 0);
	fields->Set("notify_service_warning", (stateFilter & StateFilterWarning) != 0);
	fields->Set("notify_service_unknown", (stateFilter & StateFilterUnknown) != 0);
	fields->Set("notify_service_critical", (stateFilter & StateFilterCritical) != 0);
	fields->Set("notify_service_flapping", (typeFilter & (NotificationFlappingStart | NotificationFlappingEnd)) != 0);
	fields->Set("notify_service_downtime", (typeFilter & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) != 0);
	fields->Set("notify_host_recovery", (typeFilter & NotificationRecovery) != 0);
	fields->Set("notify_host_down", (stateFilter & StateFilterDown) != 0);
	fields->Set("notify_host_flapping", (typeFilter & (NotificationFlappingStart | NotificationFlappingEnd)) != 0);
	fields->Set("notify_host_downtime", (typeFilter & (NotificationDowntimeStart | NotificationDowntimeEnd | NotificationDowntimeRemoved)) != 0);

	return fields;
}
开发者ID:LMNetworks,项目名称:icinga2,代码行数:30,代码来源:userdbobject.cpp


示例3: NotificationSentHandler

/**
 * @threadsafety Always.
 */
void CompatLogger::NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
	const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr,
	const String& author, const String& comment_text, const String& command_name)
{
	Host::Ptr host;
	Service::Ptr service;
	tie(host, service) = GetHostService(checkable);

	String notification_type_str = Notification::NotificationTypeToString(notification_type);

	/* override problem notifications with their current state string */
	if (notification_type == NotificationProblem) {
		if (service)
			notification_type_str = Service::StateToString(service->GetState());
		else
			notification_type_str = GetHostStateString(host);
	}

	String author_comment = "";
	if (notification_type == NotificationCustom || notification_type == NotificationAcknowledgement) {
		author_comment = author + ";" + comment_text;
	}

	if (!cr)
		return;

	String output;
	if (cr)
		output = CompatUtility::GetCheckResultOutput(cr);

	std::ostringstream msgbuf;

	if (service) {
		msgbuf << "SERVICE NOTIFICATION: "
			<< user->GetName() << ";"
			<< host->GetName() << ";"
			<< service->GetShortName() << ";"
			<< notification_type_str << ";"
			<< command_name << ";"
			<< output << ";"
			<< author_comment
			<< "";
	} else {
		msgbuf << "HOST NOTIFICATION: "
			<< user->GetName() << ";"
			<< host->GetName() << ";"
			<< notification_type_str << " "
			<< "(" << GetHostStateString(host) << ");"
			<< command_name << ";"
			<< output << ";"
			<< author_comment
			<< "";
	}

	{
		ObjectLock oLock(this);
		WriteLine(msgbuf.str());
		Flush();
	}
}
开发者ID:bebehei,项目名称:icinga2,代码行数:63,代码来源:compatlogger.cpp


示例4: EvaluateObjectRuleOne

bool UserGroup::EvaluateObjectRuleOne(const User::Ptr user, const ObjectRule& rule)
{
	DebugInfo di = rule.GetDebugInfo();

	std::ostringstream msgbuf;
	msgbuf << "Evaluating 'object' rule (" << di << ")";
	CONTEXT(msgbuf.str());

	Dictionary::Ptr locals = make_shared<Dictionary>();
	locals->Set("user", user);

	if (!rule.EvaluateFilter(locals))
		return false;

	std::ostringstream msgbuf2;
	msgbuf2 << "Assigning membership for group '" << rule.GetName() << "' to user '" << user->GetName() << "' for rule " << di;
	Log(LogDebug, "UserGroup", msgbuf2.str());

	String group_name = rule.GetName();
	UserGroup::Ptr group = UserGroup::GetByName(group_name);

	if (!group) {
		Log(LogCritical, "UserGroup", "Invalid membership assignment. Group '" + group_name + "' does not exist.");
		return false;
	}

	/* assign user group membership */
	group->ResolveGroupMembership(user, true);

	/* update groups attribute for apply */
	user->AddGroup(group_name);

	return true;
}
开发者ID:carroarmato0,项目名称:icinga2,代码行数:34,代码来源:usergroup.cpp


示例5: EmailAccessor

Value ContactsTable::EmailAccessor(const Value& row)
{
    User::Ptr user = static_cast<User::Ptr>(row);

    if (!user)
        return Empty;

    return user->GetEmail();
}
开发者ID:hudayou,项目名称:icinga2,代码行数:9,代码来源:contactstable.cpp


示例6: AliasAccessor

Value ContactsTable::AliasAccessor(const Value& row)
{
    User::Ptr user = static_cast<User::Ptr>(row);

    if (!user)
        return Empty;

    return user->GetDisplayName();
}
开发者ID:hudayou,项目名称:icinga2,代码行数:9,代码来源:contactstable.cpp


示例7: ServiceNotificationsEnabledAccessor

Value ContactsTable::ServiceNotificationsEnabledAccessor(const Value& row)
{
    User::Ptr user = static_cast<User::Ptr>(row);

    if (!user)
        return Empty;

    return (user->GetEnableNotifications() ? 1 : 0);
}
开发者ID:hudayou,项目名称:icinga2,代码行数:9,代码来源:contactstable.cpp


示例8: GetStatusFields

Dictionary::Ptr UserDbObject::GetStatusFields(void) const
{
	Dictionary::Ptr fields = new Dictionary();
	User::Ptr user = static_pointer_cast<User>(GetObject());

	fields->Set("host_notifications_enabled", user->GetEnableNotifications());
	fields->Set("service_notifications_enabled", user->GetEnableNotifications());
	fields->Set("last_host_notification", DbValue::FromTimestamp(user->GetLastNotification()));
	fields->Set("last_service_notification", DbValue::FromTimestamp(user->GetLastNotification()));

	return fields;
}
开发者ID:hannesbe,项目名称:icinga2,代码行数:12,代码来源:userdbobject.cpp


示例9: CalculateConfigHash

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

	User::Ptr user = static_pointer_cast<User>(GetObject());

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

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

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


示例10: InServiceNotificationPeriodAccessor

Value ContactsTable::InServiceNotificationPeriodAccessor(const Value& row)
{
    User::Ptr user = static_cast<User::Ptr>(row);

    if (!user)
        return Empty;

    TimePeriod::Ptr timeperiod = user->GetPeriod();

    if (!timeperiod)
        return Empty;

    return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
}
开发者ID:hudayou,项目名称:icinga2,代码行数:14,代码来源:contactstable.cpp


示例11: ServiceNotificationPeriodAccessor

Value ContactsTable::ServiceNotificationPeriodAccessor(const Value& row)
{
    User::Ptr user = static_cast<User::Ptr>(row);

    if (!user)
        return Empty;

    TimePeriod::Ptr timeperiod = user->GetPeriod();

    if (!timeperiod)
        return Empty;

    return timeperiod->GetName();
}
开发者ID:hudayou,项目名称:icinga2,代码行数:14,代码来源:contactstable.cpp


示例12: ExecuteNotificationHelper

void Notification::ExecuteNotificationHelper(NotificationType type, const User::Ptr& user, const CheckResult::Ptr& cr, bool force, const String& author, const String& text)
{
	try {
		NotificationCommand::Ptr command = GetCommand();

		if (!command) {
			Log(LogDebug, "Notification")
			    << "No command found for notification '" << GetName() << "'. Skipping execution.";
			return;
		}

		command->Execute(this, user, cr, type, author, text);

		/* required by compatlogger */
		Service::OnNotificationSentToUser(this, GetCheckable(), user, type, cr, author, text, command->GetName(), MessageOrigin::Ptr());

		Log(LogInformation, "Notification")
		    << "Completed sending '" << NotificationTypeToStringInternal(type)
		    << "' notification '" << GetName()
		    << "' for checkable '" << GetCheckable()->GetName()
		    << "' and user '" << user->GetName() << "'.";
	} catch (const std::exception& ex) {
		Log(LogWarning, "Notification")
		    << "Exception occured during notification for checkable '"
		    << GetCheckable()->GetName() << "': " << DiagnosticInformation(ex);
	}
}
开发者ID:TheFlyingCorpse,项目名称:icinga2,代码行数:27,代码来源:notification.cpp


示例13: NotificationSentUserHandler

void ClusterEvents::NotificationSentUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable, const User::Ptr& user,
	NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr, const String& author, const String& commentText, const String& command,
	const MessageOrigin::Ptr& origin)
{
	ApiListener::Ptr listener = ApiListener::GetInstance();

	if (!listener)
		return;

	Host::Ptr host;
	Service::Ptr service;
	tie(host, service) = GetHostService(checkable);

	Dictionary::Ptr params = new Dictionary();
	params->Set("host", host->GetName());
	if (service)
		params->Set("service", service->GetShortName());
	params->Set("notification", notification->GetName());
	params->Set("user", user->GetName());
	params->Set("type", notificationType);
	params->Set("cr", Serialize(cr));
	params->Set("nr", Serialize(nr));
	params->Set("author", author);
	params->Set("text", commentText);
	params->Set("command", command);

	Dictionary::Ptr message = new Dictionary();
	message->Set("jsonrpc", "2.0");
	message->Set("method", "event::NotificationSentUser");
	message->Set("params", params);

	listener->RelayMessage(origin, nullptr, message, true);
}
开发者ID:Icinga,项目名称:icinga2,代码行数:33,代码来源:clusterevents.cpp


示例14: AddMember

void UserGroup::AddMember(const User::Ptr& user)
{
	user->AddGroup(GetName());

	boost::mutex::scoped_lock lock(m_UserGroupMutex);
	m_Members.insert(user);
}
开发者ID:TheFlyingCorpse,项目名称:icinga2,代码行数:7,代码来源:usergroup.cpp


示例15: ResolveGroupMembership

bool UserGroup::ResolveGroupMembership(const User::Ptr& user, bool add, int rstack) {

	if (add && rstack > 20) {
		Log(LogWarning, "UserGroup")
		    << "Too many nested groups for group '" << GetName() << "': User '"
		    << user->GetName() << "' membership assignment failed.";

		return false;
	}

	Array::Ptr groups = GetGroups();

	if (groups && groups->GetLength() > 0) {
		ObjectLock olock(groups);

		for (const String& name : groups) {
			UserGroup::Ptr group = UserGroup::GetByName(name);

			if (group && !group->ResolveGroupMembership(user, add, rstack + 1))
				return false;
		}
	}

	if (add)
		AddMember(user);
	else
		RemoveMember(user);

	return true;
}
开发者ID:TheFlyingCorpse,项目名称:icinga2,代码行数:30,代码来源:usergroup.cpp


示例16: connect

void ClientManager::connect(const User::Ptr& p) {
	Lock l(cs);
	OnlineIter i = onlineUsers.find(p->getCID());
	if(i != onlineUsers.end()) {
		OnlineUser* u = i->second;
		u->getClient().connect(*u);
	}
}
开发者ID:andor44,项目名称:nanodc2,代码行数:8,代码来源:ClientManager.cpp


示例17: reserveSlot

void UploadManager::reserveSlot(const User::Ptr& aUser) {
	{
		Lock l(cs);
		reservedSlots.insert(aUser);
	}
	if(aUser->isOnline())
		ClientManager::getInstance()->connect(aUser);
}
开发者ID:BackupTheBerlios,项目名称:linuxdcpp,代码行数:8,代码来源:UploadManager.cpp


示例18: privateMessage

void ClientManager::privateMessage(const User::Ptr& p, const string& msg) {
	Lock l(cs);
	OnlineIter i = onlineUsers.find(p->getCID());
	if(i != onlineUsers.end()) {
		OnlineUser* u = i->second;
		u->getClient().privateMessage(*u, msg);
	}
}
开发者ID:andor44,项目名称:nanodc2,代码行数:8,代码来源:ClientManager.cpp


示例19: reserveSlot

void UploadManager::reserveSlot(const User::Ptr& aUser) {
	{
		Lock l(cs);
		reservedSlots.insert(aUser);
	}
	if(aUser->isOnline())
		const_cast<User::Ptr&>(aUser)->connect();
}
开发者ID:BackupTheBerlios,项目名称:fuldc-svn,代码行数:8,代码来源:UploadManager.cpp


示例20: updateUser

void UsersFrame::updateUser(const User::Ptr& aUser) {
	for(int i = 0; i < ctrlUsers.GetItemCount(); ++i) {
		UserInfo *ui = ctrlUsers.getItemData(i);
		if(ui->user == aUser) {
			ui->columns[COLUMN_SEEN] = aUser->isOnline() ? TSTRING(ONLINE) : Text::toT(Util::formatTime("%Y-%m-%d %H:%M", FavoriteManager::getInstance()->getLastSeen(aUser)));
			ctrlUsers.updateItem(i);
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:ldcpp-svn,代码行数:9,代码来源:UsersFrame.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ item::ItemInfoI类代码示例发布时间:2022-05-31
下一篇:
C++ uscriptstruct::ICppStructOps类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap