Ignore:
Timestamp:
Feb 16, 2010, 5:26:59 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
b53a7e
Parents:
323177
Message:

Moved control of molecules and periode to World.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/builder.cpp

    r323177 r120f8b  
    7676#include "Actions/MethodAction.hpp"
    7777#include "Actions/small_actions.hpp"
     78#include "World.hpp"
    7879#include "version.h"
    7980
     
    21642165/********************************************** Main routine **************************************/
    21652166
     2167void cleanUp(config *configuration){
     2168  World::destroy();
     2169  delete(configuration);
     2170  Log() << Verbose(0) <<  "Maximum of allocated memory: "
     2171    << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
     2172  Log() << Verbose(0) <<  "Remaining non-freed memory: "
     2173    << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
     2174  MemoryUsageObserver::purgeInstance();
     2175  logger::purgeInstance();
     2176  errorLogger::purgeInstance();
     2177  UIFactory::purgeInstance();
     2178  ActionRegistry::purgeRegistry();
     2179}
     2180
    21662181int main(int argc, char **argv)
    21672182{
    2168   periodentafel *periode = new periodentafel;
    2169     MoleculeListClass *molecules = new MoleculeListClass;
    21702183    molecule *mol = NULL;
    21712184    config *configuration = new config;
     
    21782191    setVerbosity(0);
    21792192    /* structure of ParseCommandLineOptions will be refactored later */
    2180     j = ParseCommandLineOptions(argc, argv, molecules, periode, *configuration, ConfigFileName);
     2193    j = ParseCommandLineOptions(argc, argv,  World::get()->getMolecules(), World::get()->getPeriode(), *configuration, ConfigFileName);
    21812194    switch (j){
    21822195        case 255:
    21832196        case 2:
    21842197        case 1:
    2185             delete (molecules);
    2186             delete (periode);
    2187             delete (configuration);
    2188             Log() << Verbose(0) << "Maximum of allocated memory: " << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
    2189             Log() << Verbose(0) << "Remaining non-freed memory: " << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
    2190             MemoryUsageObserver::getInstance()->purgeInstance();
    2191             logger::purgeInstance();
    2192             errorLogger::purgeInstance();
     2198            cleanUp(configuration);
    21932199            return (j == 1 ? 0 : j);
    21942200        default:
    21952201            break;
    21962202    }
    2197     if(molecules->ListOfMolecules.size() == 0){
    2198         mol = new molecule(periode);
     2203    if(World::get()->numMolecules() == 0){
     2204        mol = World::get()->createMolecule();
    21992205        if(mol->cell_size[0] == 0.){
    22002206            Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
     
    22042210            }
    22052211        }
    2206 
    22072212        mol->ActiveFlag = true;
    2208         molecules->insert(mol);
    22092213    }
    22102214
     
    22182222
    22192223      UIFactory::makeUserInterface(UIFactory::Text);
    2220       MainWindow *mainWindow = UIFactory::get()->makeMainWindow(populaters,molecules, configuration, periode, ConfigFileName);
     2224      MainWindow *mainWindow = UIFactory::get()->makeMainWindow(populaters,World::get()->getMolecules(), configuration, World::get()->getPeriode(), ConfigFileName);
    22212225      mainWindow->display();
    22222226      delete mainWindow;
    22232227    }
    22242228
    2225     if(periode->StorePeriodentafel(configuration->databasepath))
     2229    if(World::get()->getPeriode()->StorePeriodentafel(configuration->databasepath))
    22262230        Log() << Verbose(0) << "Saving of elements.db successful." << endl;
    22272231
     
    22292233        Log() << Verbose(0) << "Saving of elements.db failed." << endl;
    22302234
    2231     delete (molecules);
    2232     delete(periode);
    2233   delete(configuration);
    2234 
    2235 
    2236 
    2237   Log() << Verbose(0) <<  "Maximum of allocated memory: "
    2238     << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
    2239   Log() << Verbose(0) <<  "Remaining non-freed memory: "
    2240     << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
    2241   MemoryUsageObserver::purgeInstance();
    2242   logger::purgeInstance();
    2243   errorLogger::purgeInstance();
    2244   UIFactory::purgeInstance();
    2245   ActionRegistry::purgeRegistry();
     2235  cleanUp(configuration);
    22462236  return (0);
    22472237}
Note: See TracChangeset for help on using the changeset viewer.