本文整理汇总了C++中ActionSet类的典型用法代码示例。如果您正苦于以下问题:C++ ActionSet类的具体用法?C++ ActionSet怎么用?C++ ActionSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActionSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addPrivilegesRequiredForMapReduce
void addPrivilegesRequiredForMapReduce(Command* commandTemplate,
const std::string& dbname,
const BSONObj& cmdObj,
std::vector<Privilege>* out) {
Config::OutputOptions outputOptions = Config::parseOutputOptions(dbname, cmdObj);
ResourcePattern inputResource(commandTemplate->parseResourcePattern(dbname, cmdObj));
uassert(17142, mongoutils::str::stream() <<
"Invalid input resource " << inputResource.toString(),
inputResource.isExactNamespacePattern());
out->push_back(Privilege(inputResource, ActionType::find));
if (outputOptions.outType != Config::INMEMORY) {
ActionSet outputActions;
outputActions.addAction(ActionType::insert);
if (outputOptions.outType == Config::REPLACE) {
outputActions.addAction(ActionType::remove);
}
else {
outputActions.addAction(ActionType::update);
}
ResourcePattern outputResource(
ResourcePattern::forExactNamespace(
NamespaceString(outputOptions.finalNamespace)));
uassert(17143, mongoutils::str::stream() << "Invalid target namespace " <<
outputResource.ns().ns(),
outputResource.ns().isValid());
// TODO: check if outputNs exists and add createCollection privilege if not
out->push_back(Privilege(outputResource, outputActions));
}
}
示例2: logoutDatabase
void AuthorizationSession::addAuthorizedPrincipal(Principal* principal) {
// Log out any already-logged-in user on the same database as "principal".
logoutDatabase(principal->getName().getDB().toString()); // See SERVER-8144.
_authenticatedPrincipals.add(principal);
if (!principal->isImplicitPrivilegeAcquisitionEnabled())
return;
const std::string dbname = principal->getName().getDB().toString();
if (dbname == StringData("local", StringData::LiteralTag()) &&
principal->getName().getUser() == internalSecurity.user) {
// Grant full access to internal user
ActionSet allActions;
allActions.addAllActions();
acquirePrivilege(Privilege(PrivilegeSet::WILDCARD_RESOURCE, allActions),
principal->getName());
return;
}
_acquirePrivilegesForPrincipalFromDatabase(ADMIN_DBNAME, principal->getName());
principal->markDatabaseAsProbed(ADMIN_DBNAME);
_acquirePrivilegesForPrincipalFromDatabase(dbname, principal->getName());
principal->markDatabaseAsProbed(dbname);
_externalState->onAddAuthorizedPrincipal(principal);
}
示例3: addRequiredPrivileges
virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
std::vector<Privilege>* out) {
ActionSet actions;
actions.addAction(ActionType::backupThrottle);
out->push_back(Privilege(AuthorizationManager::SERVER_RESOURCE_NAME, actions));
}
示例4: calculateDependencyGraph
void calculateDependencyGraph()
{
// zero out the graph
DG = DependencyGraph<bool>(size());
// for each action we have
for (size_t a=0; a<actions.size(); ++a)
{
// get the prerequisites for this action
ActionSet pre = actions[a].getPrerequisites();
// subtract the worker from resource depot, prevent cyclic dependency
if (a == DATA.getResourceDepot())
{
pre.subtract(DATA.getWorker());
}
// loop through prerequisites
while (!pre.isEmpty())
{
// get the next action
Action p = pre.popAction();
// add it to the dependency graph
DG.set(a, p, true);
}
}
// do transitive reduction to obtain the tree
DG.transitiveReduction();
}
示例5: addRequiredPrivileges
void WriteCmd::addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
std::vector<Privilege>* out) {
ActionSet actions;
actions.addAction(_action);
out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions));
}
示例6: calculateRelevantActions
// builds the relevant action set for this search
ActionSet calculateRelevantActions()
{
// the initial mask is blank
ActionSet all;
// let's say that we will always allow workers and supply producers
all.add(DATA.getWorker());
all.add(DATA.getSupplyProvider());
// loop through each nonzero element of the goal
for (Action a(0); a<DATA.size(); ++a)
{
// if we want some of this action
if (params.goal.get(a) > 0)
{
//printf("GOAL HAS: %s\n", DATA[a].getName().c_str());
// add itself to the mask
all.add(a);
// if this action costs gas
if (DATA[a].gasPrice() > 0)
{
// extractors are now relevant
all.add(DATA.getRefinery());
}
// also add all recursive prerequisites of this action
calculateRecursivePrerequisites(a, all);
}
}
return all;
}
示例7: updateResults
void CombatSearch_BestResponse::doSearch(const GameState & state, size_t depth)
{
if (timeLimitReached())
{
throw BOSS_COMBATSEARCH_TIMEOUT;
}
_bestResponseData.update(_params.getInitialState(), state, _buildOrder);
updateResults(state);
if (isTerminalNode(state, depth))
{
return;
}
ActionSet legalActions;
generateLegalActions(state, legalActions, _params);
for (UnitCountType a(0); a < legalActions.size(); ++a)
{
size_t ri = legalActions.size() - 1 - a;
GameState child(state);
child.doAction(legalActions[ri]);
_buildOrder.add(legalActions[ri]);
doSearch(child,depth+1);
_buildOrder.pop_back();
}
}
示例8: inputResource
void Pipeline::addRequiredPrivileges(Command* commandTemplate,
const string& db,
BSONObj cmdObj,
vector<Privilege>* out) {
ResourcePattern inputResource(commandTemplate->parseResourcePattern(db, cmdObj));
uassert(17138,
mongoutils::str::stream() << "Invalid input resource, " << inputResource.toString(),
inputResource.isExactNamespacePattern());
if (false && cmdObj["allowDiskUsage"].trueValue()) {
// TODO no privilege for this yet.
}
out->push_back(Privilege(inputResource, ActionType::find));
BSONObj pipeline = cmdObj.getObjectField("pipeline");
BSONForEach(stageElem, pipeline) {
BSONObj stage = stageElem.embeddedObjectUserCheck();
if (str::equals(stage.firstElementFieldName(), "$out")) {
NamespaceString outputNs(db, stage.firstElement().str());
uassert(17139,
mongoutils::str::stream() << "Invalid $out target namespace, " <<
outputNs.ns(),
outputNs.isValid());
ActionSet actions;
actions.addAction(ActionType::remove);
actions.addAction(ActionType::insert);
out->push_back(Privilege(ResourcePattern::forExactNamespace(outputNs), actions));
}
}
示例9: Q_UNUSED
bb::cascades::VisualNode*
NSRLastDocItemFactory::createItem (bb::cascades::ListView* list,
const QString& type)
{
Q_UNUSED (type);
NSRLastDocsListView *listView = static_cast<NSRLastDocsListView *> (list);
NSRLastDocItem *item = new NSRLastDocItem ();
NSRTranslator *translator = item->getTranslator ();
ActionSet *actionSet = ActionSet::create ();
ActionItem *shareAction = ActionItem::create().title (trUtf8 ("Share"));
ActionItem *hideAction = ActionItem::create().title (trUtf8 ("Clear Recent", "Clear recent files"));
DeleteActionItem *removeAction = DeleteActionItem::create ();
shareAction->setImageSource (QUrl ("asset:///share.png"));
hideAction->setImageSource (QUrl ("asset:///list-remove.png"));
#if BBNDK_VERSION_AT_LEAST(10,2,0)
shareAction->accessibility()->setName (trUtf8 ("Share file with others"));
hideAction->accessibility()->setName (trUtf8 ("Remove file from the recent list only"));
translator->addTranslatable ((UIObject *) shareAction->accessibility (),
NSRTranslator::NSR_TRANSLATOR_TYPE_A11Y,
QString ("NSRLastDocItemFactory"),
QString ("Share file with others"));
translator->addTranslatable ((UIObject *) hideAction->accessibility (),
NSRTranslator::NSR_TRANSLATOR_TYPE_A11Y,
QString ("NSRLastDocItemFactory"),
QString ("Remove file from the recent list only"));
#endif
bool ok = connect (shareAction, SIGNAL (triggered ()), listView, SLOT (onShareActionTriggered ()));
Q_UNUSED (ok);
Q_ASSERT (ok);
ok = connect (removeAction, SIGNAL (triggered ()), listView, SLOT (onRemoveActionTriggered ()));
Q_ASSERT (ok);
ok = connect (hideAction, SIGNAL (triggered ()), listView, SLOT (onHideActionTriggered ()));
Q_ASSERT (ok);
actionSet->add (shareAction);
actionSet->add (hideAction);
actionSet->add (removeAction);
item->addActionSet (actionSet);
translator->addTranslatable ((UIObject *) shareAction,
NSRTranslator::NSR_TRANSLATOR_TYPE_ACTION,
QString ("NSRLastDocItemFactory"),
QString ("Share"));
translator->addTranslatable ((UIObject *) hideAction,
NSRTranslator::NSR_TRANSLATOR_TYPE_ACTION,
QString ("NSRLastDocItemFactory"),
QString ("Clear Recent"));
return item;
}
示例10: createRecursiveActionSet_AllBulbOn
void createRecursiveActionSet_AllBulbOn()
{
string actionsetDesc;
ActionSet *allBulbOn = new ActionSet();
allBulbOn->type = OIC::ACTIONSET_TYPE::RECURSIVE;
allBulbOn->actionsetName = "AllBulbOnRecursiveCall";
allBulbOn->mTime.tm_year = 0;
allBulbOn->mTime.tm_mon = 0;
allBulbOn->mTime.tm_mday = 0;
allBulbOn->mTime.tm_hour = 0;
allBulbOn->mTime.tm_min = 0;
allBulbOn->mTime.tm_sec = 5;
allBulbOn->setDelay(allBulbOn->getSecAbsTime());
for (auto iter = lights.begin(); iter != lights.end(); ++iter)
{
Action *action = new Action();
action->target = (*iter);
Capability *capa = new Capability();
capa->capability = "power";
capa->status = "on";
action->listOfCapability.push_back(capa);
allBulbOn->listOfAction.push_back(action);
}
if (g_resource)
{
thingsMgr->addActionSet(g_resource, allBulbOn, onPut);
}
delete allBulbOn;
}
示例11: addRequiredPrivileges
void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
std::vector<Privilege>* out) const override {
ActionSet actions;
actions.addAction(ActionType::convertToCapped);
out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions));
}
示例12: addPrivilegesRequiredForFindAndModify
void addPrivilegesRequiredForFindAndModify(Command* commandTemplate,
const std::string& dbname,
const BSONObj& cmdObj,
std::vector<Privilege>* out) {
bool update = cmdObj["update"].trueValue();
bool upsert = cmdObj["upsert"].trueValue();
bool remove = cmdObj["remove"].trueValue();
ActionSet actions;
actions.addAction(ActionType::find);
if (update) {
actions.addAction(ActionType::update);
}
if (upsert) {
actions.addAction(ActionType::insert);
}
if (remove) {
actions.addAction(ActionType::remove);
}
ResourcePattern resource(commandTemplate->parseResourcePattern(dbname, cmdObj));
uassert(17137,
"Invalid target namespace " + resource.toString(),
resource.isExactNamespacePattern());
out->push_back(Privilege(resource, actions));
}
示例13: addRequiredPrivileges
virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
std::vector<Privilege>* out) {
ActionSet actions;
actions.addAction(ActionType::find);
out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions));
}
示例14: addRequiredPrivileges
virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
std::vector<Privilege>* out) {
ActionSet actions;
actions.addAction(ActionType::resync);
out->push_back(Privilege(ResourcePattern::forClusterResource(), actions));
}
示例15: xrule_impl
void XRuleIP::xrule_impl(
IronBee::Transaction tx,
ActionSet& actions
)
{
const char *remote_ip = tx.effective_remote_ip_string();
ib_ip4_t ipv4;
ib_ip6_t ipv6;
ib_log_debug_tx(tx.ib(), "Checking IP Access for %s", remote_ip);
// Check IP lists.
if (remote_ip == NULL) {
BOOST_THROW_EXCEPTION(
IronBee::einval()
<< IronBee::errinfo_what("No remote IP available.")
);
}
else if (IB_OK == ib_ip4_str_to_ip(remote_ip, &ipv4)) {
const ib_ipset4_entry_t *entry;
ib_status_t rc;
rc = ib_ipset4_query(&(m_ipset4), ipv4, NULL, &entry, NULL);
if (rc == IB_OK) {
ib_log_debug_tx(tx.ib(), "IP matched %s", remote_ip);
action_ptr action =
IronBee::data_to_value<action_ptr>(entry->data);
actions.set(action);
}
else {
ib_log_debug_tx(
tx.ib(),
"IP set is empty or does not include %s",
remote_ip);
}
}
else if (IB_OK == ib_ip6_str_to_ip(remote_ip, &ipv6)) {
const ib_ipset6_entry_t *entry;
ib_status_t rc;
rc = ib_ipset6_query(&(m_ipset6), ipv6, NULL, &entry, NULL);
if (rc == IB_OK) {
ib_log_debug_tx(tx.ib(), "IP matched %s", remote_ip);
action_ptr action =
IronBee::data_to_value<action_ptr>(entry->data);
actions.set(action);
}
else {
ib_log_debug_tx(
tx.ib(),
"IP set is empty or does not include %s",
remote_ip);
}
}
else {
BOOST_THROW_EXCEPTION(
IronBee::enoent()
<< IronBee::errinfo_what("Cannot convert IP to v4 or v6.")
);
}
}