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 #include "util/Clone.hh"
00028 
00029 namespace fatalmind {
00030 
00031 template<class PT>class ResourcePool; 
00032 
00033 
00034 
00035 
00036 class NonTemplateCommand: public Clone {
00037     public:
00038         NonTemplateCommand();
00039         ~NonTemplateCommand();
00040     protected:
00041         bool topLevel() const {
00042             return _tl;
00043         }
00044         void topLevel(bool tl) {
00045             _tl = tl;
00046         }
00047     private:
00048         bool _tl;
00049         virtual void outputoperator(std::ostream&) const;
00050 
00051     template<class charT, class traits>
00052     friend 
00053         std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& s, const fatalmind::NonTemplateCommand& rho);
00054 };
00055 
00059 template<class PT>
00060 class Command: public NonTemplateCommand {
00061     protected:
00062         Command() 
00063         : NonTemplateCommand()
00064         {
00065         };
00066     public:
00067         typedef PT pool_type;
00068 
00069         virtual ~Command() {
00070         }
00071 
00083         virtual void execute(typename PT::resource_t& rr) = 0;
00084 
00085     protected:
00086         const typename PT::factory_t& getFactory(const ResourcePool<PT>& p) const {
00087             return p.getFactory();
00088         }
00089 
00090     friend 
00091         class ResourcePool<PT>;
00092 };
00093 
00094 } 
00095 
00096 template<class charT, class traits>
00097 std::basic_ostream<charT, traits>& fatalmind::operator<<(std::basic_ostream<charT, traits>& s, const fatalmind::NonTemplateCommand& rho) {
00098     rho.outputoperator(s);
00099     return s;
00100 }
00101 
00102 
00103 #endif