本文整理汇总了C++中user::Ptr::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::GetName方法的具体用法?C++ Ptr::GetName怎么用?C++ Ptr::GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user::Ptr
的用法示例。
在下文中一共展示了Ptr::GetName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
示例2: 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);
}
}
}
示例3: 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;
}
示例4: 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);
}
}
示例5: 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;
}
示例6: 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);
}
示例7: NameAccessor
Value ContactsTable::NameAccessor(const Value& row)
{
User::Ptr user = static_cast<User::Ptr>(row);
if (!user)
return Empty;
return user->GetName();
}
示例8: EvaluateObjectRules
void UserGroup::EvaluateObjectRules(const User::Ptr& user)
{
CONTEXT("Evaluating group membership for user '" + user->GetName() + "'");
for (const ConfigItem::Ptr& group : ConfigItem::GetItems("UserGroup"))
{
if (!group->GetFilter())
continue;
EvaluateObjectRule(user, group);
}
}
示例9: EvaluateObjectRule
bool UserGroup::EvaluateObjectRule(const User::Ptr& user, const ConfigItem::Ptr& group)
{
String group_name = group->GetName();
CONTEXT("Evaluating rule for group '" + group_name + "'");
ScriptFrame frame;
if (group->GetScope())
group->GetScope()->CopyTo(frame.Locals);
frame.Locals->Set("user", user);
if (!group->GetFilter()->Evaluate(frame).GetValue().ToBool())
return false;
Log(LogDebug, "UserGroup")
<< "Assigning membership for group '" << group_name << "' to user '" << user->GetName() << "'";
Array::Ptr groups = user->GetGroups();
groups->Add(group_name);
return true;
}
示例10: CheckNotificationUserFilters
bool Notification::CheckNotificationUserFilters(NotificationType type, const User::Ptr& user, bool force, bool reminder)
{
if (!force) {
TimePeriod::Ptr tp = user->GetPeriod();
if (tp && !tp->IsInside(Utility::GetTime())) {
Log(LogNotice, "Notification")
<< "Not sending " << (reminder ? "reminder " : " ") << "notifications for notification object '"
<< GetName() << " and user '" << user->GetName()
<< "': user period not in timeperiod '" << tp->GetName() << "'";
return false;
}
unsigned long ftype = type;
Log(LogDebug, "Notification")
<< "User notification, Type '" << NotificationTypeToStringInternal(type)
<< "', TypeFilter: " << NotificationFilterToString(user->GetTypeFilter(), GetTypeFilterMap())
<< " (FType=" << ftype << ", TypeFilter=" << GetTypeFilter() << ")";
if (!(ftype & user->GetTypeFilter())) {
Log(LogNotice, "Notification")
<< "Not sending " << (reminder ? "reminder " : " ") << "notifications for notification object '"
<< GetName() << " and user '" << user->GetName() << "': type '"
<< NotificationTypeToStringInternal(type) << "' does not match type filter: "
<< NotificationFilterToString(user->GetTypeFilter(), GetTypeFilterMap()) << ".";
return false;
}
/* check state filters it this is not a recovery notification */
if (type != NotificationRecovery) {
Checkable::Ptr checkable = GetCheckable();
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
unsigned long fstate;
String stateStr;
if (service) {
fstate = ServiceStateToFilter(service->GetState());
stateStr = NotificationServiceStateToString(service->GetState());
} else {
fstate = HostStateToFilter(host->GetState());
stateStr = NotificationHostStateToString(host->GetState());
}
Log(LogDebug, "Notification")
<< "User notification, State '" << stateStr << "', StateFilter: "
<< NotificationFilterToString(user->GetStateFilter(), GetStateFilterMap())
<< " (FState=" << fstate << ", StateFilter=" << user->GetStateFilter() << ")";
if (!(fstate & user->GetStateFilter())) {
Log(LogNotice, "Notification")
<< "Not " << (reminder ? "reminder " : " ") << "sending notifications for notification object '"
<< GetName() << " and user '" << user->GetName() << "': state '" << stateStr
<< "' does not match state filter: " << NotificationFilterToString(user->GetStateFilter(), GetStateFilterMap()) << ".";
return false;
}
}
} else {
Log(LogNotice, "Notification")
<< "Not checking " << (reminder ? "reminder " : " ") << "notification filters for notification object '"
<< GetName() << "' and user '" << user->GetName() << "': Notification was forced.";
}
return true;
}