2019-05-09 21:41:54 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
output.cc - This file is part of MUSIC -
|
|
|
|
a code to generate multi-scale initial conditions
|
|
|
|
for cosmological simulations
|
|
|
|
|
|
|
|
Copyright (C) 2010 Oliver Hahn
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "output_plugin.hh"
|
|
|
|
|
|
|
|
|
2019-05-24 08:13:58 +02:00
|
|
|
std::map< std::string, output_plugin_creator *>& get_output_plugin_map()
|
2019-05-09 21:41:54 +02:00
|
|
|
{
|
|
|
|
static std::map< std::string, output_plugin_creator* > output_plugin_map;
|
|
|
|
return output_plugin_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
void print_output_plugins()
|
|
|
|
{
|
|
|
|
std::map< std::string, output_plugin_creator *>& m = get_output_plugin_map();
|
|
|
|
|
|
|
|
std::map< std::string, output_plugin_creator *>::iterator it;
|
|
|
|
it = m.begin();
|
2019-05-15 21:11:28 +02:00
|
|
|
csoca::ilog << "Available output plug-ins:\n";
|
2019-05-09 21:41:54 +02:00
|
|
|
while( it!=m.end() )
|
|
|
|
{
|
2019-05-24 08:13:58 +02:00
|
|
|
if( it->second )
|
|
|
|
csoca::ilog << "\t\'" << it->first << "\'\n";
|
2019-05-09 21:41:54 +02:00
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-24 08:13:58 +02:00
|
|
|
std::unique_ptr<output_plugin> select_output_plugin( ConfigFile& cf )
|
2019-05-09 21:41:54 +02:00
|
|
|
{
|
|
|
|
std::string formatname = cf.GetValue<std::string>( "output", "format" );
|
|
|
|
|
|
|
|
output_plugin_creator *the_output_plugin_creator
|
|
|
|
= get_output_plugin_map()[ formatname ];
|
|
|
|
|
|
|
|
if( !the_output_plugin_creator )
|
|
|
|
{
|
2019-05-15 21:11:28 +02:00
|
|
|
csoca::elog << "Error: output plug-in \'" << formatname << "\' not found." << std::endl;
|
2019-05-09 21:41:54 +02:00
|
|
|
print_output_plugins();
|
|
|
|
throw std::runtime_error("Unknown output plug-in");
|
|
|
|
|
2019-05-22 22:25:27 +02:00
|
|
|
}else{
|
2019-10-16 17:39:55 +02:00
|
|
|
csoca::ilog << "-------------------------------------------------------------------------------" << std::endl;
|
2019-09-11 17:34:16 +02:00
|
|
|
csoca::ilog << std::setw(32) << std::left << "Output plugin" << " : " << formatname << std::endl;
|
2019-05-22 22:25:27 +02:00
|
|
|
}
|
2019-05-09 21:41:54 +02:00
|
|
|
|
2019-05-24 08:13:58 +02:00
|
|
|
return std::move(the_output_plugin_creator->create( cf ));
|
2019-05-09 21:41:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|