本文整理汇总了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;
}