/** * @file com_check_iteration_counter.cpp * @author Julian Iseringhausen * @date Mon Apr 18 12:29:39 2011 * * @brief Increases the iteration counter and checks if * the maximum number of iterations is reached. * */ #ifdef HAVE_CONFIG_H #include #endif #include "base/command.hpp" #include "base/object.hpp" #include "mg.hpp" using namespace VMG; class VMGCommandCheckIterationCounter : public Command { public: VMGCommandCheckIterationCounter() { new ObjectStorage("ITERATION", 0); } Request Run(Command::argument_vector arguments) { const int& max_iteration = MG::GetFactory().GetObject("MAX_ITERATION")->Cast< ObjectStorage >()->Val(); int& iteration = MG::GetFactory().GetObject("ITERATION")->Cast< ObjectStorage >()->Val(); if (++iteration >= max_iteration) return StopCycleLater; else return Continue; } static const char* Name() {return "CheckIterationCounter";} static int Arguments() {return 0;} }; CREATE_INITIALIZER(VMGCommandCheckIterationCounter);