/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * WorldTime.cpp * * Created on: Feb 7, 2011 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "WorldTime.hpp" #include "CodePatterns/Log.hpp" #include "CodePatterns/Observer/Channels.hpp" #include "CodePatterns/Observer/Notification.hpp" #include "CodePatterns/Singleton_impl.hpp" unsigned int WorldTime::CurrentTime = 0; WorldTime::WorldTime() : Observable("WorldTime"), StepWidth(0.) { // observable stuff Channels *OurChannel = new Channels; NotificationChannels.insert( std::make_pair(this, OurChannel) ); // add instance for each notification type for (size_t type = 0; type < NotificationType_MAX; ++type) OurChannel->addChannel(type); } WorldTime::~WorldTime() { // observable stuff std::map::iterator iter = NotificationChannels.find(this); delete iter->second; NotificationChannels.erase(iter); } void WorldTime::setStepWidth(const double _width) { LOG(1, "INFO: Setting current world time to " << _width << "."); StepWidth = _width; } double WorldTime::getStepWidth() const { return StepWidth; } void WorldTime::setTime(const unsigned int _time) { if (WorldTime::CurrentTime != _time) { OBSERVE; NOTIFY(TimeChanged); WorldTime::CurrentTime = _time; } } CONSTRUCT_SINGLETON(WorldTime)