예제 #1
0
파일: ctobssim.cpp 프로젝트: lyang54/ctools
/***********************************************************************//**
 * @brief Save the selected event list(s)
 *
 * This method saves the selected event list(s) into FITS file(s). There are
 * two modes, depending on the m_use_xml flag.
 *
 * If m_use_xml is true, all selected event list(s) will be saved into FITS
 * files, where the output filenames are constructued from the input
 * filenames by prepending the m_prefix string to name. Any path information
 * will be stripped form the input name, hence event files will be written
 * into the local working directory (unless some path information is present
 * in the prefix). In addition, an XML file will be created that gathers
 * the filename information for the selected event list(s). If an XML file
 * was present on input, all metadata information will be copied from this
 * input file.
 *
 * If m_use_xml is false, the selected event list will be saved into a FITS
 * file.
 ***************************************************************************/
void ctobssim::save(void)
{
    // Write header
    if (logTerse()) {
        log << std::endl;
        if (m_obs.size() > 1) {
            log.header1("Save observations");
        }
        else {
            log.header1("Save observation");
        }
    }

    // Case A: Save event file(s) and XML metadata information
    if (m_use_xml) {
        save_xml();
    }

    // Case B: Save event file as FITS file
    else {
        save_fits();
    }

    // Return
    return;
}
예제 #2
0
파일: config.cpp 프로젝트: Robbbert/store1
void configuration_manager::save_settings()
{
	/* loop over all registrants and call their init function */
	for (auto type : m_typelist)
		type.save(config_type::INIT, nullptr);

	/* save the defaults file */
	emu_file file(machine().options().cfg_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
	osd_file::error filerr = file.open("default.cfg");
	if (filerr == osd_file::error::NONE)
		save_xml(file, config_type::DEFAULT);

	/* finally, save the game-specific file */
	filerr = file.open(machine().basename(), ".cfg");
	if (filerr == osd_file::error::NONE)
		save_xml(file, config_type::GAME);

	/* loop over all registrants and call their final function */
	for (auto type : m_typelist)
		type.save(config_type::FINAL, nullptr);
}
예제 #3
0
void SC_ASIYA::write_report(string TGT, string REF, string METRIC, const MetricScore &m){
    // description _ writes evaluation scores onto a given XML report file
    //stringstream r_xml;
    string report_xml = Common::DATA_PATH+"/"+Common::REPORTS+"/"+TGT +"/"+REF+"/"+METRIC+"."+Common::XMLEXT;

    if (Config::verbose) fprintf(stderr, "writing XML REPORT <%s>\n", report_xml.c_str());

    string p_aux = Common::DATA_PATH+"/"+Common::REPORTS;
    string p_tgt = Common::DATA_PATH+"/"+Common::REPORTS+"/"+TGT;
    string p_ref = Common::DATA_PATH+"/"+Common::REPORTS+"/"+TGT+"/"+REF;

    boost::filesystem::path p (p_aux);
    boost::filesystem::path p2 (p_tgt);
    boost::filesystem::path p3 (p_ref);

    if (!exists(p)) {
        string s_aux = "mkdir " + p_aux;
        system(s_aux.c_str());
    }
    if (!exists(p2)) {
        string s_aux = "mkdir " + p_tgt;
        system(s_aux.c_str());
    }
    if (!exists(p3)) {
        string s_aux = "mkdir " + p_ref;
        system(s_aux.c_str());
    }

    save_xml(report_xml, TGT, REF, METRIC, m);

    report_xml = TESTBED::replace_special_characters(report_xml);

    string command = Common::GZIP + " " + report_xml;
    string error = "Couldn't " + Common::GZIP + " " + report_xml;
    Common::execute_or_die(command, error);
}
예제 #4
0
int main(int argc, char *argv[])
{
	int c, cmd, ret;
	conf_info_t info = {0};
	char *config = DEFAULT_INTERNAL;
	xmlKeepBlanksDefault(0);
	xmlTreeIndentString = "\t";
	
	if (argc < 2) {
		usage(argv[0]);
		return 1;
	}
	
	cmd = command_decode(argv[1]);

	/* parse params */
	while ((c = getopt_long(argc, argv, OPTSTRING, long_opts, NULL)) != -1) {
		switch (c) {
		case 'h':
			usage(argv[0]);
			return 0;
		case 'c':
			config = optarg;
			break;
		case 'p':
			switch (optarg[0]) {
			case 'i': case 'I':
				info.type = PL_INPUT;
				break;
			case 'm': case 'M':
				info.type = PL_INTERMEDIATE;
				break;
			case 'o': case 'O':
				info.type = PL_OUTPUT;
				break;
			default:
				fprintf(stderr, "Unknown plugin type '%c'\n", optarg[0]);
				return 1;
			}
			break;
		case 'n':
			info.name = optarg;
			break;
		case 's':
			info.sofile = optarg;
			break;
		case 't':
			info.thread = optarg;
			break;
		case 'f':
			info.force = 1;
			break;
		default:
			return 1;
		}
	}
	
	ret = open_xml(&info, config);
	if (ret != 0) {
		return 1;
	}
	
	switch (cmd) {
		case CMD_ADD:
			ret = add_plugin(&info);
			break;
		case CMD_REMOVE:
			ret = remove_plugin(&info);
			break;
		case CMD_LIST:
			ret = list_plugins(&info);
			break;
		default:
			fprintf(stderr, "Unknown command '%s'\n", argv[1]);
			ret = 1;
			break;
	}
	
	if (ret == 0 && cmd != CMD_LIST) {
		save_xml(&info, config);
	}
	
	close_xml(&info);
	
	return ret;
}