Beispiel #1
0
void
QmcMetric::dumpEventMetric(QTextStream &os, bool srcFlag, uint instance) const
{
    Q_ASSERT(event());

    for (int i = 0; i < my.values.size(); i++) {
	int instID;

	if (srcFlag == true)
	    dumpSource(os);
	os << name();

	instID = PM_IN_NULL;
	if (hasInstances()) {
	    if (instance != UINT_MAX)
		instID = (int)instance;
	    else
		instID = my.values[i].instance();

	    QString inst = instName(instID);
	    if (inst == QString::null)
		os << "[" << instID << "]";
	    else
		os << "[\"" << inst << "\"]";
	}
	os << ": ";
	my.values[i].dumpEventRecords(os, instID);
    }
}
Beispiel #2
0
void
QmcMetric::dumpSampledMetric(QTextStream &stream, bool srcFlag, uint instance) const
{
    Q_ASSERT(!event());

    stream << name();

    if (srcFlag == true)
	dumpSource(stream);

    if (my.status < 0)
	stream << ": " << pmErrStr(my.status) << endl;
    else if (hasInstances()) {
	if (instance == UINT_MAX) {
	    if (numInst() == 1)
		stream << ": 1 instance";
	    else
		stream << ": " << numInst() << " instances";
	    if (indom()->changed())
		stream << " (indom has changed)";
	    stream << endl;

	    for (int i = 0; i < numInst(); i++) {
		stream << "  [" << instID(i) << " or \"" << instName(i)
		       << "\" (" << my.values[i].instance() << ")] = ";
		dumpValue(stream, i);
		stream << endl;
	    }
	}
	else {
	    stream << '[' << instID(instance) << " or \"" << instName(instance) 
		   << "\" (" << my.values[instance].instance() << ")] = ";
	    dumpValue(stream, instance);
	    stream << endl;
	}
    }
    else {
	stream << " = ";
	dumpValue(stream, 0);
	stream << endl;
    }
}
Beispiel #3
0
int on_export(char * v, void *k)
{
	CArgsEx a;
	char * path = 0;
	char * ofname = 0;
	__bool includeConfig = 0;
	__bool includeSource = 0;

	BEGIN_ARGS
		ARG("-of:", ofname, "char *", "output file name")
		ARG("-p:", path, "char *", "root block path")
		ARG("-config", includeConfig, "tbool", "include configuration")
		ARG("-source", includeSource, "tbool", "include source")
	END_ARGS
		
	a.parse(v, FS);

	if(process_args_1(a.argc, a.argv) < 0){
		print_usage_1();
		return F8_SYNTAX;
	}

	if(!includeSource && !includeConfig){
		return F8_SUCCESS;
	}

	IBlk * b;
	if(path){
		b = IBlk_blk_by_path(sections, path);
	}else{
		b = sections;
	}
	if(!b){
		utils_error("%s - path not found.\n", path);
		return F8_PATH_NOT_FOUND;
	}
	FILE * of;
	if(ofname){
		of = fopen(ofname, "wt");
		if(!of){
			utils_error("%s - cannot open.\n", ofname);
			return F8_FILE_NOT_FOUND;
		}
	}else{
		of = stdout;
	}

	if(includeSource){
		dumpSource(of, b);
	}

	if(includeConfig){
		dumpDevices(of);
	}

	if(of != stdout){
		fclose(of);
	}
	
	return F8_SUCCESS;
}