00001
00002
00003
00004
00005
00006 #include "gui/CompoundCommand.h"
00007 #include <algorithm>
00008
00009 namespace gui {
00010
00011 CompoundCommand::CompoundCommand(Command* cmd)
00012 {
00013 if(cmd ) append(cmd);
00014 }
00015
00016 void CompoundCommand::append(Command * cmd)
00017 {
00018 push_back(cmd);
00019 }
00020
00021 CompoundCommand::~CompoundCommand()
00022 {
00023 iterator ic = begin();
00024 while (ic != end() )
00025 delete *ic++;
00026 }
00027
00028
00029 class Executor {
00030 public:
00031 void operator()(Command* c){c->execute();}
00032 };
00033
00034 void CompoundCommand::execute()
00035 {
00036 std::for_each (begin (), end (), Executor());
00037 }
00038
00039 }