00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef RESOURCEPOOL_BATCHCOMMAND_HH
00025 #define RESOURCEPOOL_BATCHCOMMAND_HH
00026
00027 #include <vector>
00028
00029 #include "mm/gc_ptr.hh"
00030 #include "util/Clone.hh"
00031
00032 namespace fatalmind {
00033
00039 template<class CommandType>
00040 class BatchCommand: public CommandType
00041 {
00042 protected:
00043 typedef gc_ptr<CommandType> member_t;
00044 typedef std::vector<member_t> list_t;
00045 public:
00046 typedef CommandType innercommand_t;
00047 typedef typename list_t::const_iterator const_iterator;
00048 static const int NOT_STARTED;
00049 static const int NO_FURTHER_ERROR;
00050
00077 BatchCommand(bool cont = false);
00078 BatchCommand(const BatchCommand&);
00079 virtual ~BatchCommand() {
00080 }
00081
00092 virtual void add(const CommandType&);
00093 virtual void execute(typename CommandType::pool_type::resource_t&);
00094
00133 int getError();
00139 const_iterator getExecPosition() const;
00140
00146 bool doesContinue() const {
00147 return cont;
00148 }
00149
00154 const_iterator end() const;
00160 const_iterator begin() const;
00165 bool empty() const;
00166
00167 virtual void outputoperator(std::ostream&) const;
00168 protected:
00169 virtual Clone* DoClone() const {
00170 return new BatchCommand(*this);
00171 }
00172
00173 member_t getLast() const {
00174 return list.back();
00175 }
00176
00177 bool wasStarted() const {
00178 return started;
00179 }
00180
00181
00182 private:
00183 list_t list;
00184 const bool cont;
00185 bool started;
00186 protected:
00187 const_iterator exec_pos;
00188 typedef std::vector<int> errors_t;
00189 errors_t errors;
00190 unsigned int error_pos;
00191 };
00192
00193 }
00194 #endif