本文整理汇总了C++中ActionSet::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionSet::contains方法的具体用法?C++ ActionSet::contains怎么用?C++ ActionSet::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionSet
的用法示例。
在下文中一共展示了ActionSet::contains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _modifyPrivilegeForSpecialCases
Privilege AuthorizationSession::_modifyPrivilegeForSpecialCases(const Privilege& privilege) {
ActionSet newActions;
newActions.addAllActionsFromSet(privilege.getActions());
NamespaceString ns( privilege.getResource() );
if (ns.coll() == "system.users") {
if (newActions.contains(ActionType::insert) ||
newActions.contains(ActionType::update) ||
newActions.contains(ActionType::remove)) {
// End users can't modify system.users directly, only the system can.
newActions.addAction(ActionType::userAdminV1);
} else {
newActions.addAction(ActionType::userAdmin);
}
newActions.removeAction(ActionType::find);
newActions.removeAction(ActionType::insert);
newActions.removeAction(ActionType::update);
newActions.removeAction(ActionType::remove);
} else if (ns.coll() == "system.profile") {
newActions.removeAction(ActionType::find);
newActions.addAction(ActionType::profileRead);
} else if (ns.coll() == "system.indexes" && newActions.contains(ActionType::find)) {
newActions.removeAction(ActionType::find);
newActions.addAction(ActionType::indexRead);
}
return Privilege(privilege.getResource(), newActions);
}
示例2: addAllActionsFromSet
void ActionSet::addAllActionsFromSet(const ActionSet& actions) {
if (actions.contains(ActionType::anyAction)) {
addAllActions();
return;
}
_actions |= actions._actions;
}
示例3: isAuthorizedToChangeOwnCustomDataAsUser
bool AuthorizationSession::isAuthorizedToChangeOwnCustomDataAsUser(const UserName& userName) {
User* user = lookupUser(userName);
if (!user) {
return false;
}
ResourcePattern resourceSearchList[resourceSearchListCapacity];
const int resourceSearchListLength =
buildResourceSearchList(ResourcePattern::forClusterResource(), resourceSearchList);
ActionSet actions;
for (int i = 0; i < resourceSearchListLength; ++i) {
actions.addAllActionsFromSet(user->getActionsForResource(resourceSearchList[i]));
}
return actions.contains(ActionType::changeOwnCustomData);
}
示例4: _modifyPrivilegeForSpecialCases
Privilege AuthorizationManager::_modifyPrivilegeForSpecialCases(const Privilege& privilege) {
ActionSet newActions;
newActions.addAllActionsFromSet(privilege.getActions());
std::string collectionName = NamespaceString(privilege.getResource()).coll;
if (collectionName == "system.users") {
newActions.removeAction(ActionType::find);
newActions.removeAction(ActionType::insert);
newActions.removeAction(ActionType::update);
newActions.removeAction(ActionType::remove);
newActions.addAction(ActionType::userAdmin);
} else if (collectionName == "system.profle" && newActions.contains(ActionType::find)) {
newActions.removeAction(ActionType::find);
newActions.addAction(ActionType::profileRead);
}
return Privilege(privilege.getResource(), newActions);
}
示例5: generateLegalActions
void DFBB_BuildOrderStackSearch::generateLegalActions(const GameState & state, ActionSet & legalActions)
{
legalActions.clear();
DFBB_BuildOrderSearchGoal & goal = _params.goal;
const ActionType & worker = ActionTypes::GetWorker(state.getRace());
// add all legal relevant actions that are in the goal
for (size_t a(0); a < _params.relevantActions.size(); ++a)
{
const ActionType & actionType = _params.relevantActions[a];
if (state.isLegal(actionType))
{
// if there's none of this action in the goal it's not legal
if (!goal.getGoal(actionType) && !goal.getGoalMax(actionType))
{
continue;
}
// if we alread have more than the goal it's not legal
if (goal.getGoal(actionType) && (state.getUnitData().getNumTotal(actionType) >= goal.getGoal(actionType)))
{
continue;
}
// if we already have more than the goal max it's not legal
if (goal.getGoalMax(actionType) && (state.getUnitData().getNumTotal(actionType) >= goal.getGoalMax(actionType)))
{
continue;
}
legalActions.add(_params.relevantActions[a]);
}
}
// don't make anything until we have 8 workers
if (state.getUnitData().getNumTotal(worker) < 8)
{
legalActions.clear();
legalActions.add(worker);
return;
}
// if we enabled the supply bounding flag
if (_params.useSupplyBounding)
{
UnitCountType supplySurplus = state.getUnitData().getMaxSupply() + state.getUnitData().getSupplyInProgress() - state.getUnitData().getCurrentSupply();
UnitCountType threshold = (UnitCountType)(ActionTypes::GetSupplyProvider(state.getRace()).supplyProvided() * _params.supplyBoundingThreshold);
if (supplySurplus >= threshold)
{
legalActions.remove(ActionTypes::GetSupplyProvider(state.getRace()));
}
}
// if we enabled the always make workers flag, and workers are legal
if (_params.useAlwaysMakeWorkers && legalActions.contains(worker))
{
bool actionLegalBeforeWorker = false;
ActionSet legalEqualWorker;
FrameCountType workerReady = state.whenCanPerform(worker);
for (size_t a(0); a < legalActions.size(); ++a)
{
const ActionType & actionType = legalActions[a];
const FrameCountType whenCanPerformAction = state.whenCanPerform(actionType);
if (whenCanPerformAction < workerReady)
{
actionLegalBeforeWorker = true;
break;
}
if ((whenCanPerformAction == workerReady) && (actionType.mineralPrice() == worker.mineralPrice()))
{
legalEqualWorker.add(actionType);
}
}
if (actionLegalBeforeWorker)
{
legalActions.remove(worker);
}
else
{
legalActions = legalEqualWorker;
}
}
}