21 #include "getopts/getopts.h"
35 int main(
int argc,
char **argv ) {
41 opts.addOption(
"v",
"version" ,
"Display version info" ,
false );
42 opts.addOption(
"r",
"xml-req" ,
"Model creation request file in XML" ,
true );
43 opts.addOption(
"m",
"model-file" ,
"File to store the generated model" ,
true );
44 opts.addOption(
"" ,
"log-level" ,
"Set the log level (debug, warn, info, error)",
true );
45 opts.addOption(
"" ,
"log-file" ,
"Log file" ,
true );
46 opts.addOption(
"" ,
"prog-file" ,
"File to store model creation progress" ,
true );
47 opts.addOption(
"c",
"config-file" ,
"Configuration file for openModeller" ,
true );
49 std::string log_level(
"info");
50 std::string request_file;
51 std::string model_file;
53 std::string progress_file;
54 std::string config_file;
56 if ( ! opts.parse( argc, argv ) ) {
58 opts.showHelp( argv[0] );
67 while ( ( option = opts.cycle() ) >= 0 ) {
72 printf(
"om_model %s\n", om.
getVersion().c_str() );
73 printf(
"This is free software; see the source for copying conditions. There is NO\n");
74 printf(
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
78 request_file = opts.getArgs( option );
81 model_file = opts.getArgs( option );
84 log_level = opts.getArgs( option );
87 log_file = opts.getArgs( option );
90 progress_file = opts.getArgs( option );
93 config_file = opts.getArgs( option );
104 if ( ! log_file.empty() ) {
115 if ( ! config_file.empty() ) {
122 if ( request_file.empty() ) {
124 printf(
"Please specify a model creation request file in XML\n");
131 if ( ! progress_file.empty() ) {
151 if ( ! progress_file.empty() ) {
156 else if ( ! model_file.empty() ) {
172 std::ostringstream model_output;
179 if ( ! model_file.empty() ) {
181 ofstream file( model_file.c_str() );
182 file << model_output.str();
188 std::cout << model_output.str().c_str() << endl << flush;
192 if ( ! progress_file.empty() ) {
202 catch ( runtime_error e ) {
205 if ( ! progress_file.empty() ) {
211 printf(
"om_model aborted: %s\n", e.what() );
static void loadConfig(const std::string configFile)
static ConfigurationPtr readXml(char const *filename)
void setModelCallback(ModelCreationCallback func, void *param=0)
void calculateModelStatistics(const ConstConfigurationPtr &)
static Log * instance()
Returns the instance pointer, creating the object on the first call.
ConfigurationPtr getModelConfiguration() const
Log::Level getLogLevel(std::string level)
void setLevel(Level level)
int main(int argc, char **argv)
Main code.
void setupExternalResources()
void set(Level level, std::string fileName, char const *pref="")
void progressDisplayCallback(float progress, void *extraParam)
static void writeXml(const ConstConfigurationPtr &config, char const *fileaname)
static int searchDefaultDirs()
void setModelConfiguration(const ConstConfigurationPtr &)
void progressFileCallback(float progress, void *progressData)