本文整理汇总了C++中MpResource::reserveFirstUnconnectedInput方法的典型用法代码示例。如果您正苦于以下问题:C++ MpResource::reserveFirstUnconnectedInput方法的具体用法?C++ MpResource::reserveFirstUnconnectedInput怎么用?C++ MpResource::reserveFirstUnconnectedInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MpResource
的用法示例。
在下文中一共展示了MpResource::reserveFirstUnconnectedInput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: linkTopologyResources
//.........这里部分代码省略.........
result = lookupResource(outputResourceName, outputResource);
if(result != OS_SUCCESS)
{
int virtPortIdx = outputResourcePortIndex>=0?outputResourcePortIndex:-1;
int realPortIdx;
result = lookupVirtualOutput(outputResourceName, virtPortIdx,
outputResource, realPortIdx);
if (result == OS_SUCCESS && outputResourcePortIndex>=0)
{
outputResourcePortIndex = realPortIdx;
}
}
assert(result == OS_SUCCESS);
}
inputResource = (MpResource*) newResources.find(&inputResourceName);
if(inputResource == NULL)
{
result = lookupResource(inputResourceName, inputResource);
if(result != OS_SUCCESS)
{
int virtPortIdx = inputResourcePortIndex>=0?inputResourcePortIndex:-1;
int realPortIdx;
result = lookupVirtualInput(inputResourceName, virtPortIdx,
inputResource, realPortIdx);
if (result == OS_SUCCESS && inputResourcePortIndex>=0)
{
inputResourcePortIndex = realPortIdx;
}
}
assert(result == OS_SUCCESS);
}
assert(outputResource);
assert(inputResource);
if(outputResource && inputResource)
{
if(outputResourcePortIndex == MpResourceTopology::MP_TOPOLOGY_NEXT_AVAILABLE_PORT)
{
outputResourcePortIndex = outputResource->reserveFirstUnconnectedOutput();
assert(outputResourcePortIndex >= 0);
}
else if(outputResourcePortIndex < MpResourceTopology::MP_TOPOLOGY_NEXT_AVAILABLE_PORT)
{
// First see if a real port is already in the dictionary
UtlInt searchKey(outputResourcePortIndex);
UtlInt* foundValue = NULL;
if((foundValue = (UtlInt*) newConnectionIds.findValue(&searchKey)))
{
// Use the mapped index
outputResourcePortIndex = foundValue->getValue();
}
else
{
// Find an available port and add it to the map
int realPortNum = outputResource->reserveFirstUnconnectedOutput();
assert(realPortNum >= 0);
UtlInt* portKey = new UtlInt(outputResourcePortIndex);
UtlInt* portValue = new UtlInt(realPortNum);
newConnectionIds.insertKeyAndValue(portKey, portValue);
outputResourcePortIndex = realPortNum;
}
}
if(inputResourcePortIndex == MpResourceTopology::MP_TOPOLOGY_NEXT_AVAILABLE_PORT)
{
inputResourcePortIndex = inputResource->reserveFirstUnconnectedInput();
assert(inputResourcePortIndex >= 0);
}
else if(inputResourcePortIndex < MpResourceTopology::MP_TOPOLOGY_NEXT_AVAILABLE_PORT)
{
// First see if a real port is already in the dictionary
UtlInt searchKey(inputResourcePortIndex);
UtlInt* foundValue = NULL;
if((foundValue = (UtlInt*) newConnectionIds.findValue(&searchKey)))
{
// Use the mapped index
inputResourcePortIndex = foundValue->getValue();
}
else
{
// Find an available port and add it to the map
int realPortNum = inputResource->reserveFirstUnconnectedInput();
assert(realPortNum >= 0);
UtlInt* portKey = new UtlInt(inputResourcePortIndex);
UtlInt* portValue = new UtlInt(realPortNum);
newConnectionIds.insertKeyAndValue(portKey, portValue);
inputResourcePortIndex = realPortNum;
}
}
result = addLink(*outputResource, outputResourcePortIndex, *inputResource, inputResourcePortIndex);
assert(result == OS_SUCCESS);
}
connectionIndex++;
}
newConnectionIds.destroyAll();
return(connectionIndex);
}