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_COMMAND_HH
00025 #define RESOURCEPOOL_COMMAND_HH
00026
00027 #ifndef RESOURCEPOOL_EXECUTEFWD_HH
00028 #include "ExecuteFwd.hh"
00029 #endif
00030
00031 #include "util/Clone.hh"
00032
00033 namespace fatalmind {
00034
00035 template<class PT>class ResourcePool;
00036
00040 template<class PT>
00041 class Command: public Clone {
00042 protected:
00043 Command();
00044 public:
00045 typedef PT pool_type;
00046
00047 virtual ~Command() {
00048 }
00049
00061 virtual void execute(typename PT::resource_t& rr) = 0;
00062
00063 virtual void outputoperator(std::ostream&) const;
00064
00065 protected:
00066 const typename PT::factory_t& getFactory(const ResourcePool<PT>& p) const {
00067 return p.getFactory();
00068 }
00069
00070 private:
00071 bool topLevel() const;
00072 void topLevel(bool tl);
00073 bool _tl;
00074
00075 friend
00076 class _RPExecute<PT>;
00077 };
00078
00079 }
00080
00081 template<class charT, class traits, class PT>
00082 inline
00083 std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& s, const fatalmind::Command<PT>& rho) {
00084 rho.outputoperator(s);
00085 return s;
00086 }
00087
00088 #endif