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


C++ Tracer::getChild方法代码示例

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


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

示例1: getInstance

//
// public static methods
//
Tracer* Tracer::getInstance(const char* tracername, const char* classname)
{
    QString strTracername(tracername);
    QString strClassname(classname);

    // if neither tracername nor classname is specified we return the root-tracer
    if (strTracername.isEmpty() && strClassname.isEmpty()) {
        return getRootTracer();
    }

    Tracer* currentTracer = getRootTracer();
    QString currentTracerName = QString("");
    
    // split the tracername into its parts
    QStringList parts = QStringList::split(TRACER_NAME_SEPARATOR, strTracername, false);

    // if specified the classname is handled as last part of the tracername
    if (!strClassname.isEmpty()) {
        parts.append(strClassname);
    }

    int partsCount = parts.count();

    // loop over the tracename parts and
    // try to get the tracer matching the tracername and classname
    // as soon as we don't find a matching subtracer we begin to create new tracers...
    for (int i = 0; i < partsCount; i++) {
        QString part = parts[i];
        
        // create the tracername of the tracer we would like at this point
        if (i > 0) {
            currentTracerName = currentTracerName.append(TRACER_NAME_SEPARATOR);
        }
        currentTracerName = currentTracerName.append(part);

        // try to get a matching tracer for the currentTracerName
        Tracer* matchingChild = currentTracer->getChild(part);
        if (matchingChild) {
            currentTracer = matchingChild;
        } else {
            //no matching subtracer found --> create one!

            Tracer* child;
            if (i + 1 == partsCount) {
                // this is the last tracer to instantiate --> create WITH classname
                child = new Tracer(currentTracerName, part, strClassname);
            } else {
                // this is a missing supertracer of the tracer to create --> create without classname
                child = new Tracer(currentTracerName, part, "");
            }

            // link the new tracer into the tracer tree
            currentTracer->m_children->append(child);
            child->m_parent = currentTracer;

            // tracers inherit the tracelevel of the parent
            child->m_tracelevel = currentTracer->m_tracelevel;
            
            currentTracer = child;
        }
    }

    // if a classname is specified but the resulting tracer has no one set
    // the tracer was already instantiated without a classname set
    // this most likely occurs when the tracer was configured by a traceconfigfile
    // --> force the classname
    if (!strClassname.isEmpty() && currentTracer->m_classname->isEmpty()) {
        currentTracer->m_classname = new QString(strClassname);
    }
    

    return currentTracer;
}
开发者ID:BackupTheBerlios,项目名称:kphotobook-svn,代码行数:76,代码来源:tracer.cpp


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