当前位置: 首页>>代码示例>>C++>>正文


C++ IPacket::className方法代码示例

本文整理汇总了C++中IPacket::className方法的典型用法代码示例。如果您正苦于以下问题:C++ IPacket::className方法的具体用法?C++ IPacket::className怎么用?C++ IPacket::className使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPacket的用法示例。


在下文中一共展示了IPacket::className方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: process

void PacketStream::process(IPacket& packet)
{
    TraceS(this) << "Processing packet: " << state() << ": "
                 << packet.className() << endl;
    // assert(Thread::currentID() == _runner->tid());

    try {

        // Auto start the stream if required and currently inactive
        if (_autoStart && stateEquals(PacketStreamState::None))
            start();

        // Process the packet if the stream is active
        PacketProcessor* firstProc = nullptr;
        if (stateEquals(PacketStreamState::Active) &&
            !packet.flags.has(PacketFlags::NoModify)) {
            {
                std::lock_guard<std::mutex> guard(_mutex);
                firstProc = !_processors.empty()
                                ? reinterpret_cast<PacketProcessor*>(
                                      _processors[0]->ptr)
                                : nullptr;
            }
            if (firstProc) {

                // Lock the processor mutex to synchronize multi source streams
                std::lock_guard<std::mutex> guard(_procMutex);

                // Sync queued states
                synchronizeStates();

                // Send the packet to the first processor in the chain
                if (stateEquals(PacketStreamState::Active)) {
                    // TraceS(this) << "Starting process chain: "
                    //     << firstProc << ": " << packet.className() << endl;
                    // assert(stateEquals(PacketStreamState::Active));
                    if (firstProc->accepts(packet))
                        firstProc->process(packet);
                    else
                        firstProc->emit(packet);

                    // TraceS(this) << "After process chain: "
                    //     << firstProc << ": " << packet.className() << endl;
                    // If all went well the packet was processed and emitted...
                }

                // Proxy packets which are rejected by the first processor
                else {
                    WarnS(this) << "Source packet rejected: " << firstProc
                                << ": " << packet.className() << endl;
                    firstProc = nullptr;
                }
            }
        }

        // Otherwise just proxy and emit the packet
        // TODO: Should we pass the packet to the PacketSyncQueue if
        // synchronizeOutput was used?
        if (!firstProc) {
            TraceS(this) << "Proxying packet: " << state() << ": "
                         << packet.className() << endl;
            emit(packet);
        }

        // Stop the packet stream on the final packet
        if (stateEquals(PacketStreamState::Active) &&
            packet.flags.has(PacketFlags::Final)) {
            this->stop();
        }
    }

    // Catch any exceptions thrown within the processor
    catch (std::exception& exc) {
        handleException(exc);
    }

    // TraceS(this) << "End process chain: "
    //     << state() << ": " << packet.className() << endl;
}
开发者ID:,项目名称:,代码行数:79,代码来源:


注:本文中的IPacket::className方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。