- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/WorldAction/InputAction.cpp
r1fd675 rbd2390 30 30 #include <string> 31 31 32 #include <boost/filesystem/fstream.hpp> 33 32 34 using namespace std; 33 35 … … 39 41 /** =========== define the function ====================== */ 40 42 Action::state_ptr WorldInputAction::performCall() { 41 MoleculeListClass *molecules = World::getInstance().getMolecules();42 molecule *mol = NULL;43 std::ifstream test;43 // MoleculeListClass *molecules = World::getInstance().getMolecules(); 44 // molecule *mol = NULL; 45 boost::filesystem::ifstream test; 44 46 45 47 // obtain information 46 48 getParametersfromValueStorage(); 47 49 48 DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl); 49 if (params.filename.find('.') != string::npos) { 50 std::string FilenamePrefix = params.filename.substr(0,params.filename.find_last_of('.')); 51 std::string FilenameSuffix = params.filename.substr(params.filename.find_last_of('.')+1, params.filename.length()); 50 DoLog(0) && (Log() << Verbose(0) << "Config file given " << params.filename << "." << endl); 51 // using the filename as prefix for all parsers 52 std::string FilenameSuffix; 53 std::string FilenamePrefix; 54 if (params.filename.has_filename()) { 55 // get suffix 56 FilenameSuffix = params.filename.extension().substr(1); // remove the prefixed "." 57 FilenamePrefix = params.filename.stem(); 52 58 DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl); 53 test.open(params.filename.c_str());54 if (test == NULL) {55 DoLog(1) && (Log() << Verbose(1) << "Specified config file " << params.filename << " not found." << endl);56 } else {57 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");58 FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix);59 test.close();60 }61 59 FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix); 62 // set mol to first active molecule63 if (molecules->ListOfMolecules.size() != 0) {64 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)65 if ((*ListRunner)->ActiveFlag) {66 mol = *ListRunner;67 break;68 }69 }70 if (mol == NULL) {71 mol = World::getInstance().createMolecule();72 mol->ActiveFlag = true;73 molecules->insert(mol);74 }75 mol->SetNameFromFilename(params.filename.substr(0,params.filename.find('.')).c_str());76 60 } else { 77 61 DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl); 62 return Action::failure; 63 } 64 65 // parsing file if present 66 if (!boost::filesystem::exists(params.filename)) { 67 DoLog(1) && (Log() << Verbose(1) << "Specified config file " << params.filename << " not found." << endl); 68 // DONT FAIL: it's just empty and we use the name. // return Action::failure; 69 } else { 70 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... "); 71 72 // parse the file 73 test.open(params.filename); 74 FormatParserStorage::getInstance().get(test, FilenameSuffix); 75 test.close(); 76 77 // set file name of last molecule 78 MoleculeList::const_iterator iter = World::getInstance().getMolecules()->ListOfMolecules.end(); 79 iter--; 80 (*iter)->SetNameFromFilename(FilenamePrefix.c_str()); 78 81 } 79 82 return Action::success;
Note:
See TracChangeset
for help on using the changeset viewer.