/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * CommandLineStatusIndicator.cpp * * Created on: May 8, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "CommandLineUI/CommandLineStatusIndicator.hpp" #include #include "Actions/Process.hpp" using namespace std; CommandLineStatusIndicator::CommandLineStatusIndicator() : Observer("CommandLineStatusIndicator") { Process::AddObserver(this); } CommandLineStatusIndicator::~CommandLineStatusIndicator() { Process::RemoveObserver(this); } void CommandLineStatusIndicator::update(Observable *subject){ Process *proc; // we are only observing Processes if((proc=dynamic_cast(subject))){ // see what kind of progress we have to display if(proc->getMaxSteps()>0){ if(!proc->doesStop()){ cout << "Busy (" << proc->getName() << ") "; // we can show a percentage done cout << (int)proc->getDoneRatio() << "% done" << endl; } } else{ // we only show some kind of busy animation if(proc->doesStart()){ cout << "Busy (" << proc->getName() << ")"; } if(!proc->doesStop()){ cout << "."; } else { cout << endl; } } } } void CommandLineStatusIndicator::subjectKilled(Observable *subject){ }