本文整理汇总了C++中SerialPort::addRef方法的典型用法代码示例。如果您正苦于以下问题:C++ SerialPort::addRef方法的具体用法?C++ SerialPort::addRef怎么用?C++ SerialPort::addRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerialPort
的用法示例。
在下文中一共展示了SerialPort::addRef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refresh
void SerialPortEnumerator::refresh()
{
std::set<SerialPort *> portsToDisown = m_ownedPorts;
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
for (int i = 0; i < ports.size(); ++i)
{
QextPortInfo info = ports[i];
QHash<QString, SerialPort *>::const_iterator it = m_portMap.find(ports[i].physName);
if (it == m_portMap.end())
{
ConnectionPointer<SerialPort> portGuard(new SerialPort());
portGuard->setName(info.portName, /*isDefault=*/true);
portGuard->setDeviceName(info.physName);
portGuard->setFriendlyName(info.friendName);
portGuard->setBaudRate(38400);
portGuard->setDevNameEditable(false);
QHash<QString, QVariant>::iterator cfgIt = m_connCfg.find(info.physName);
if(cfgIt != m_connCfg.end() && (*cfgIt).type() == QVariant::Hash)
portGuard->applyConfig((*cfgIt).toHash());
connect(portGuard.data(), SIGNAL(destroyed()), this, SLOT(connectionDestroyed()));
m_portMap[info.physName] = portGuard.data();
sConMgr2.addConnection(portGuard.data());
m_ownedPorts.insert(portGuard.data());
portGuard->setRemovable(false);
portGuard.take();
}
else
{
SerialPort * port = it.value();
if (m_ownedPorts.find(port) == m_ownedPorts.end())
{
m_ownedPorts.insert(port);
port->setRemovable(false);
port->addRef();
}
else
{
portsToDisown.erase(port);
}
}
}
for (std::set<SerialPort *>::const_iterator it = portsToDisown.begin(); it != portsToDisown.end(); ++it)
{
SerialPort * port = *it;
m_ownedPorts.erase(port);
port->setRemovable(true);
port->release();
}
}