本文整理汇总了C++中user::Ptr::AddGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::AddGroup方法的具体用法?C++ Ptr::AddGroup怎么用?C++ Ptr::AddGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user::Ptr
的用法示例。
在下文中一共展示了Ptr::AddGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddMember
void UserGroup::AddMember(const User::Ptr& user)
{
user->AddGroup(GetName());
boost::mutex::scoped_lock lock(m_UserGroupMutex);
m_Members.insert(user);
}
示例2: 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;
}