本文整理汇总了C++中TaskManager::TaskSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskManager::TaskSize方法的具体用法?C++ TaskManager::TaskSize怎么用?C++ TaskManager::TaskSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskManager
的用法示例。
在下文中一共展示了TaskManager::TaskSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_task_bad
bool test_task_bad(TaskManager& task_manager,
const Waypoints& waypoints)
{
test_task_random(task_manager,waypoints,2);
task_manager.SetFactory(TaskFactoryType::RACING);
AbstractTaskFactory& fact = task_manager.GetFactory();
const Waypoint* wp = random_waypoint(waypoints);
ok (!fact.CreateFinish((TaskPointFactoryType)20,*wp),"bad finish type",0);
ok (!fact.CreateStart((TaskPointFactoryType)20,*wp),"bad start type",0);
ok (!fact.CreateIntermediate((TaskPointFactoryType)20,*wp),"bad intermediate type",0);
// now create a taskpoint from FAI
const TaskPointFactoryType s = GetRandomType(fact.GetIntermediateTypes());
// test it is bad for AAT
task_manager.SetFactory(TaskFactoryType::AAT);
AbstractTaskFactory& bfact = task_manager.GetFactory();
ok (!bfact.CreateIntermediate(s,*wp),"bad intermediate type (after task change)",0);
bfact.Remove(1);
bfact.UpdateStatsGeometry();
ok (bfact.Validate(),"ok with one tp",0);
bfact.Remove(1);
bfact.UpdateStatsGeometry();
ok (bfact.Validate(),"ok with zero tps (just start and finish)",0);
ok (bfact.Remove(task_manager.TaskSize()-1,false),"remove finish manually",0);
bfact.UpdateStatsGeometry();
ok (!bfact.Validate(),"aat is invalid (no finish)",0);
return true;
}
示例2: test_task_random_RT_AAT_FAI
//.........这里部分代码省略.........
OrderedTaskPoint *tp;
char tmp[255];
char tskType[20];
tskType[0] = '\0';
switch (rand() %3) {
case 0:
task_manager.SetFactory(TaskFactoryType::AAT);
strcpy(tskType,"AAT");
test_note("# creating random AAT task\n");
break;
case 1:
task_manager.SetFactory(TaskFactoryType::RACING);
strcpy(tskType,"RT");
test_note("# creating random RT task\n");
break;
case 2:
task_manager.SetFactory(TaskFactoryType::FAI_GENERAL);
strcpy(tskType,"FAI");
test_note("# creating random FAI GENERAL\n");
break;
}
AbstractTaskFactory &fact = task_manager.GetFactory();
//max points includes start & finish
const TaskFactoryConstraints &constraints =
task_manager.GetOrderedTask().GetFactoryConstraints();
const unsigned num_points_total =
std::max(constraints.min_points,
_num_points % constraints.max_points) + 1;
const unsigned num_int_points = num_points_total - 2;
test_note("# adding start\n");
wp = random_waypoint(waypoints);
if (wp) {
const TaskPointFactoryType s = GetRandomType(fact.GetStartTypes());
tp = fact.CreateStart(s,*wp);
if (!fact.Append(*tp,false)) {
return false;
}
delete tp;
}
for (unsigned i=0; i<num_int_points; i++) {
test_note("# adding intermediate\n");
wp = random_waypoint(waypoints);
if (wp) {
const TaskPointFactoryType s = GetRandomType(fact.GetIntermediateTypes());
tp = fact.CreateIntermediate(s,*wp);
if (!fact.Append(*tp,false)) {
return false;
}
delete tp;
}
}
test_note("# adding finish\n");
wp = random_waypoint(waypoints);
if (wp) {
const TaskPointFactoryType s = GetRandomType(fact.GetFinishTypes());
tp = fact.CreateFinish(s,*wp);
if (!fact.Append(*tp,false)) {
return false;
}
delete tp;
}
fact.UpdateStatsGeometry();
test_note("# validating task..\n");
if (!fact.Validate()) {
return false;
}
if (task_manager.GetOrderedTask().GetFactoryType()
== TaskFactoryType::FAI_GENERAL)
{
test_note("# checking OZs for FAI General..\n");
if (!fact.ValidateFAIOZs())
return false;
}
if (task_manager.GetOrderedTask().GetFactoryType()
== TaskFactoryType::MAT)
{
test_note("# checking OZs for MAT General..\n");
if (!fact.ValidateMATOZs())
return false;
}
task_manager.Resume();
sprintf(tmp, "# SUCCESS CREATING %s task! task_size():%d..\n",
tskType,
task_manager.TaskSize());
test_note(tmp);
return true;
}
示例3: test_task_type_manip
bool test_task_type_manip(TaskManager& task_manager,
const Waypoints &waypoints, unsigned n_points)
{
if (!test_task_random_RT_AAT_FAI(task_manager, waypoints, n_points))
return false;
switch (rand() %4) {
case 0:
task_manager.SetFactory(TaskFactoryType::AAT);
test_note("# switched FACTORY TYPE to AAT\n");
break;
case 1:
task_manager.SetFactory(TaskFactoryType::RACING);
test_note("# switched FACTORY TYPE to RT\n");
break;
case 2:
task_manager.SetFactory(TaskFactoryType::FAI_GENERAL);
test_note("# switched FACTORY TYPE to FAI GENERAL\n");
break;
case 3:
task_manager.SetFactory(TaskFactoryType::MAT);
test_note("# switched FACTORY TYPE to MAT\n");
break;
default:
test_note("# unknown task type\n");
}
AbstractTaskFactory &fact = task_manager.GetFactory();
fact.MutateTPsToTaskType();
fact.UpdateStatsGeometry();
test_note("# checking mutated start..\n");
if (!fact.IsValidStartType(fact.GetType(task_manager.GetOrderedTask().GetTaskPoint(0))))
return false;
char tmp[255];
sprintf(tmp, "# checking mutated intermediates. task_size():%d..\n",
task_manager.TaskSize());
test_note(tmp);
for (unsigned i = 1; i < (task_manager.TaskSize() - 1); i++) {
sprintf(tmp, "# checking mutated intermediate point %d..\n", i);
test_note(tmp);
if (!fact.IsValidIntermediateType(fact.GetType(task_manager.GetOrderedTask().GetTaskPoint(i))))
return false;
}
test_note("# checking mutated finish..\n");
if (!fact.IsValidFinishType(
fact.GetType(task_manager.GetOrderedTask().GetTaskPoint(task_manager.TaskSize() - 1))))
return false;
test_note("# validating task..\n");
if (!fact.Validate()) {
return false;
}
test_note("# checking task..\n");
if (!task_manager.CheckOrderedTask()) {
return false;
}
if (task_manager.GetOrderedTask().GetFactoryType() ==
TaskFactoryType::FAI_GENERAL) {
test_note("# checking OZs for FAI task..\n");
if (!fact.ValidateFAIOZs())
return false;
}
if (task_manager.GetOrderedTask().GetFactoryType() ==
TaskFactoryType::MAT) {
test_note("# checking OZs for MAT task..\n");
if (!fact.ValidateMATOZs())
return false;
}
return true;
}
示例4: test_task_manip
bool test_task_manip(TaskManager& task_manager,
const Waypoints &waypoints)
{
if (!test_task_mixed(task_manager, waypoints)) {
return false;
}
AbstractTaskFactory &fact = task_manager.GetFactory();
task_report(task_manager, "# removing tp 2\n");
if (!fact.Remove(2)) {
return false;
}
task_report(task_manager, "# removing tp 0\n");
if (!fact.Remove(0)) {
return false;
}
task_report(task_manager, "# removing tp -1 (illegal)\n");
if (fact.Remove(0-1)) {
return false;
}
task_report(task_manager, "# removing tp 50 (illegal)\n");
if (fact.Remove(50)) {
return false;
}
OrderedTaskPoint *tp;
const Waypoint *wp;
task_report(task_manager, "# inserting at 3\n");
wp = waypoints.LookupId(3);
if (wp) {
tp = fact.CreateIntermediate(TaskPointFactoryType::AST_CYLINDER,*wp);
if (!fact.Insert(*tp,3)) return false;
delete tp;
}
task_report(task_manager, "# auto-replacing at 2 (no morph)\n");
wp = waypoints.LookupId(9);
if (wp) {
tp = fact.CreateIntermediate(TaskPointFactoryType::AST_CYLINDER,*wp);
if (!fact.Replace(*tp,2)) return false;
delete tp;
}
task_report(task_manager, "# auto-replacing at 2 (morph)\n");
wp = waypoints.LookupId(9);
if (wp) {
tp = fact.CreateStart(*wp);
if (!fact.Replace(*tp,2)) return false;
delete tp;
}
task_report(task_manager, "# auto-replacing at 0 (morph this)\n");
wp = waypoints.LookupId(12);
if (wp) {
tp = fact.CreateIntermediate(TaskPointFactoryType::AST_CYLINDER,*wp);
if (!fact.Replace(*tp,0)) return false;
delete tp;
}
task_report(task_manager, "# auto-replacing at end (morph this)\n");
wp = waypoints.LookupId(14);
if (wp) {
tp = fact.CreateIntermediate(TaskPointFactoryType::AST_CYLINDER,*wp);
if (!fact.Replace(*tp,task_manager.TaskSize()-1)) return false;
delete tp;
}
task_report(task_manager, "# removing finish point\n");
if (!fact.Remove(task_manager.TaskSize()-1)) {
return false;
}
task_report(task_manager, "# inserting at 50 (equivalent to append)\n");
wp = waypoints.LookupId(8);
if (wp) {
tp = fact.CreateFinish(*wp);
if (!fact.Insert(*tp,50)) return false;
delete tp;
}
task_report(task_manager, "# inserting at 0 (morph this)\n");
wp = waypoints.LookupId(3);
if (wp) {
tp = fact.CreateFinish(*wp);
if (!fact.Insert(*tp,0)) return false;
delete tp;
}
task_report(task_manager, "# inserting at 2 (morph this)\n");
wp = waypoints.LookupId(4);
if (wp) {
tp = fact.CreateStart(*wp);
if (!fact.Insert(*tp,2)) return false;
delete tp;
}
//.........这里部分代码省略.........