00001 /*************************************************************************** 00002 * Copyright (C) 2006-2008 by Antonello Lobianco * 00003 * http://regmas.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 3 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #include "MainProgram.h" 00021 //#include "InputDocument.h" 00022 //#include "RegData.h" 00023 #include "ThreadManager.h" 00024 00025 //constructor 00026 MainProgram::MainProgram(ThreadManager* MTHREAD_h) 00027 { 00028 //input_filename = input_filename_h; 00029 MTHREAD = MTHREAD_h; 00030 // Creating objects for the program flow: 00031 // the regional data object.. 00032 RegData *RD = new RegData(MTHREAD); 00033 MTHREAD->setRDPointer(RD); 00034 MTHREAD->RD->setBaseDiretory(MTHREAD->getBaseDirectory()); 00035 MTHREAD->RD->loadInput(); // Unzip the ooffice input file and load it into memory 00036 } 00037 00038 //distructor 00039 MainProgram::~MainProgram() 00040 { 00041 } 00042 00049 void 00050 MainProgram::run(){ 00051 00052 00053 00054 00055 00056 00057 00058 // GIS information and methods.. 00059 Gis *GIS = new Gis(MTHREAD); 00060 MTHREAD->setGISPointer(GIS); 00061 // a test object for various 0-effects tests (sandbox).. 00062 Sandbox* TEST = new Sandbox(MTHREAD); 00063 TEST->test(); 00064 // the agent super manager, will deal with all the manager objects.. 00065 SuperAgentManager *SAM = new SuperAgentManager(MTHREAD); 00066 MTHREAD->setSAMPointer(SAM); 00067 // the Init object, it schedule the pre-simulation phase.. 00068 Init *INIT = new Init(MTHREAD); 00069 MTHREAD->setINITPointer(INIT); 00070 // the scheduler object. It manage the simulation loops.. 00071 Scheduler *SCD = new Scheduler(MTHREAD); 00072 MTHREAD->setSCDPointer(SCD); 00073 // manage the printing of data needed for scenario-analisys. The "message output" (needed to see "what is it happening?" are instead simply printed with msgOut().. 00074 Output *DO = new Output(MTHREAD); 00075 MTHREAD->setDOPointer(DO); 00076 00077 // Creating an istance of regional data and assigning the first data (the input_file /output_directory) 00078 //msgOut(MSG_DEBUG, input_filename); 00079 00080 //MTHREAD->RD->parseInitialConfigFile(); 00081 00082 00083 // Creating an istance of INIT and delegating to it the Initialization phase.. 00084 MTHREAD->INIT->setInitLevel(1); // Initial environment setting and agent rising 00085 refreshGUI(); 00086 MTHREAD->INIT->setInitLevel(3); // assigning resources to agents and evenutal env reallocation 00087 refreshGUI(); 00088 MTHREAD->INIT->setInitLevel(5); // starting simulations. Once INIT has ended it is the turn of SCD (Scheduler) to manage the simulation... 00089 refreshGUI(); 00090 MTHREAD->INIT->setInitLevel(6); // ending simulations 00091 refreshGUI(); 00092 00093 // Deleting the pointers... 00094 // 20070102: if I delete the pointers I can not access the legend after simulation has ended 00095 // 20070109: pointers (e.g. INIT) are deleted in ThreadManager when a new simulation start 00096 }