예제 #1
0
void FixLog::dequeue(AutoLocker& autolock)
{
    FixRecord& rec = queue_.front();
    if( !parse(rec) ) {
        autolock.lockWrite();
        queue_.pop_front();
        return;
    }

    QString str = rec.message_;
    rec.message_.clear();
    rec.size_ = str.length();

    if( online_ && writer_.checkLoggingEnabled() ) {
        if( rec.type_ & Incoming )
            str = "[" + QString(Global::timestamp(rec.time_).c_str()) + "]  << " + str + "\n";
        else if( rec.type_ & Outgoing )
            str = "[" + QString(Global::timestamp(rec.time_).c_str()) + "]  >> " + str + "\n";
        else
            str = "[" + QString(Global::timestamp(rec.time_).c_str()) + "]     " + str + "\n";

        *(QTextStream*)(this) << str;
        flush();
        rec.position_ = (qint32)writer_.size()-1;
        autolock.lockWrite();
    }
    else {
        rec.position_ = reader_.pos();
    }

    RecordsMap::iterator mIt = msgmap_.insert(rec.position_, rec);
    if( readerPos_ && !viewmap_.empty() ) 
    {
        if( mIt.value().position_ > readerPos_ )
            if((rec.code_ == -1) || 
               ((rec.type_ & matching_.type_) &&
                (rec.code_ == matching_.code_ || rec.symbol_ == matching_.symbol_)
               ))
            {
                viewmap_.insert(mIt.value().position_, &mIt.value());
                queue_.pop_front();
                autolock.unlock();
                emit notifyHasNext(true);
            }
            else
                queue_.pop_front();
    }
    else
        queue_.pop_front();
}