本文整理汇总了C++中MooseSharedPointer::getAllTasks方法的典型用法代码示例。如果您正苦于以下问题:C++ MooseSharedPointer::getAllTasks方法的具体用法?C++ MooseSharedPointer::getAllTasks怎么用?C++ MooseSharedPointer::getAllTasks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MooseSharedPointer
的用法示例。
在下文中一共展示了MooseSharedPointer::getAllTasks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
ActionWarehouse::addActionBlock(MooseSharedPointer<Action> action)
{
/**
* Note: This routine uses the XTerm colors directly which is not advised for general purpose output coloring.
* Most users should prefer using Problem::colorText() which respects the "color_output" option for terminals
* that do not support coloring. Since this routine is intended for debugging only and runs before several
* objects exist in the system, we are just using the constants directly.
*/
std::string registered_identifier = action->parameters().get<std::string>("registered_identifier");
std::set<std::string> tasks;
if (_show_parser)
Moose::err << COLOR_DEFAULT << "Parsing Syntax: " << COLOR_GREEN << action->name() << '\n'
<< COLOR_DEFAULT << "Building Action: " << COLOR_DEFAULT << action->type() << '\n'
<< COLOR_DEFAULT << "Registered Identifier: " << COLOR_GREEN << registered_identifier << '\n'
<< COLOR_DEFAULT << "Specific Task: " << COLOR_CYAN << action->specificTaskName() << '\n';
/**
* We need to see if the current Action satisfies multiple tasks. There are a few cases to consider:
*
* 1. The current Action is registered with multiple syntax blocks. In this case we can only use the
* current instance to satisfy the specific task listed for this syntax block. We can detect this
* case by inspecting whether it has a "specific task name" set in the Action instance.
*
* 2. This action does not have a valid "registered identifier" set in the Action instance. This means
* that this Action was not built by the Parser. It was most likely created through a Meta-Action.
* In this case, the ActionFactory itself would have already set the task it found from the build
* info used to construct the Action.
*
* 3. The current Action is registered with only a single syntax block. In this case we can simply
* re-use the current instance to act and satisfy _all_ registered tasks. This is the normal
* case where we have a Parser-built Action that does not have a specific task name to satisfy.
* We will use the Action "type" to retrieve the list of tasks that this Action may satisfy.
*/
if (action->specificTaskName() != "") // Case 1
tasks.insert(action->specificTaskName());
else if (registered_identifier == "") // Case 2
{
std::set<std::string> local_tasks = action->getAllTasks();
mooseAssert(local_tasks.size() == 1, "More than one task inside of the " << action->name());
tasks.insert(*local_tasks.begin());
}
else // Case 3
tasks = _action_factory.getTasksByAction(action->type());
//TODO: Now we need to weed out the double registrations!
for (std::set<std::string>::iterator it = tasks.begin(); it != tasks.end(); ++it)
{
const std::string & task = *it;
// Some error checking
if (!_syntax.hasTask(task))
mooseError("A(n) " << task << " is not a registered task");
// Make sure that the ObjectAction task and Action task are consistent
// otherwise that means that is action was built by the wrong type
MooseSharedPointer<MooseObjectAction> moa = MooseSharedNamespace::dynamic_pointer_cast<MooseObjectAction>(action);
if (moa.get())
{
InputParameters mparams = moa->getObjectParams();
if (mparams.have_parameter<std::string>("_moose_base"))
{
const std::string & base = mparams.get<std::string>("_moose_base");
if (!_syntax.verifyMooseObjectTask(base, *it))
mooseError("Task " << *it << " is not registered to build " << base << " derived objects");
}
else
mooseError("Unable to locate registered base parameter for " << moa->getMooseObjectType());
}
// Add the current task to current action
action->appendTask(*it);
if (_show_parser)
Moose::err << COLOR_YELLOW << "Adding Action: " << COLOR_DEFAULT << action->type() << " (" << COLOR_YELLOW << *it << COLOR_DEFAULT << ")\n";
// Add it to the warehouse
_all_ptrs.push_back(action);
_action_blocks[*it].push_back(action.get());
}
if (_show_parser)
Moose::err << std::endl;
}