| Rev | Line | |
|---|
| [48b662] | 1 | /**
|
|---|
| 2 | * @file com_check_iteration_counter.cpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Mon Apr 18 12:29:39 2011
|
|---|
| 5 | *
|
|---|
| 6 | * @brief Increases the iteration counter and checks if
|
|---|
| 7 | * the maximum number of iterations is reached.
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | #ifdef HAVE_CONFIG_H
|
|---|
| 12 | #include <config.h>
|
|---|
| 13 | #endif
|
|---|
| 14 |
|
|---|
| 15 | #include "base/command.hpp"
|
|---|
| 16 | #include "base/object.hpp"
|
|---|
| 17 | #include "mg.hpp"
|
|---|
| 18 |
|
|---|
| 19 | using namespace VMG;
|
|---|
| 20 |
|
|---|
| 21 | class VMGCommandCheckIterationCounter : public Command
|
|---|
| 22 | {
|
|---|
| 23 | public:
|
|---|
| 24 | VMGCommandCheckIterationCounter()
|
|---|
| 25 | {
|
|---|
| 26 | new ObjectStorage<int>("ITERATION", 0);
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | Request Run(Command::argument_vector arguments)
|
|---|
| 30 | {
|
|---|
| 31 | const int& max_iteration = MG::GetFactory().GetObject("MAX_ITERATION")->Cast< ObjectStorage<int> >()->Val();
|
|---|
| 32 | int& iteration = MG::GetFactory().GetObject("ITERATION")->Cast< ObjectStorage<int> >()->Val();
|
|---|
| 33 |
|
|---|
| 34 | if (++iteration >= max_iteration)
|
|---|
| 35 | return StopCycleLater;
|
|---|
| 36 | else
|
|---|
| 37 | return Continue;
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | static const char* Name() {return "CheckIterationCounter";}
|
|---|
| 41 | static int Arguments() {return 0;}
|
|---|
| 42 | };
|
|---|
| 43 |
|
|---|
| 44 | CREATE_INITIALIZER(VMGCommandCheckIterationCounter);
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.