本文整理汇总了C++中Store::isAssignmentPossible方法的典型用法代码示例。如果您正苦于以下问题:C++ Store::isAssignmentPossible方法的具体用法?C++ Store::isAssignmentPossible怎么用?C++ Store::isAssignmentPossible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Store
的用法示例。
在下文中一共展示了Store::isAssignmentPossible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: schedule
Algorithm::Result FirstFitAlgorithm::schedule()
{
for (Requests::iterator i = requests.begin(); i != requests.end(); i++)
{
Request * request = *i;
Assignment * assignment = new Assignment(request);
Algorithm::Result result = SUCCESS;
Nodes & vms = request->getVirtualMachines();
for (Nodes::iterator vmi = vms.begin(); vmi != vms.end(); vmi++)
{
Node * vm = *vmi;
Nodes & nodes = network->getNodes();
Nodes::iterator n;
for (n = nodes.begin(); n != nodes.end(); n++)
{
Node * node = *n;
if ( node->isAssignmentPossible(*vm) )
{
node->assign(*vm);
assignment->AddAssignment(vm, node);
break;
}
}
if ( n == nodes.end() )
{
result = FAILURE;
break;
}
}
Stores & storages = request->getStorages();
for (Stores::iterator s = storages.begin(); s != storages.end(); s++)
{
Store * storage = *s;
Stores & stores = network->getStores();
Stores::iterator si;
for ( si = stores.begin(); si != stores.end(); si++)
{
Store * store = *si;
if ( store->isAssignmentPossible(*storage) )
{
store->assign(*storage);
assignment->AddAssignment(storage, store);
break;
}
}
if ( si == storages.end() )
{
result = FAILURE;
break;
}
}
Links & vlinks = request->getVirtualLinks();
for (Links::iterator l = vlinks.begin(); l != vlinks.end(); l++)
{
Link * dummy = createDummyLink(*l, assignment);
if ( dummy == 0 )
{
result = FAILURE;
break;
}
NetPath netPath = VirtualLinkRouter::routeDejkstra(dummy, network);
delete dummy;
if ( netPath.size() == 0 )
{
result = FAILURE;
break;
}
for ( NetPath::iterator i = netPath.begin(); i != netPath.end(); i++)
{
(*i)->assign(**l);
}
assignment->AddAssignment(*l, netPath);
}
if ( result == FAILURE )
delete assignment;
else
assignments.insert(assignment);
}
printf("Assigned total of %d from %d requests", assignments.size(), requests.size());
if ( assignments.size() == requests.size() )
return SUCCESS;
else if ( assignments.size() != 0 )
return PARTIAL;
else
return FAILURE;
}