Back to index

nordugrid-arc-nox  1.1.0~rc6
Broker.h
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifndef __ARC_BROKER_H__
00004 #define __ARC_BROKER_H__
00005 
00006 #include <list>
00007 #include <string>
00008 
00009 #include <arc/loader/Loader.h>
00010 #include <arc/loader/Plugin.h>
00011 
00012 namespace Arc {
00013 
00014   class ExecutionTarget;
00015   class JobDescription;
00016   class Logger;
00017   class UserConfig;
00018 
00019   class Broker
00020     : public Plugin {
00021 
00022   public:
00024 
00036     const ExecutionTarget* GetBestTarget();
00038 
00044     void PreFilterTargets(std::list<ExecutionTarget>& targets,
00045                           const JobDescription& job);
00046 
00048     void RegisterJobsubmission();
00049 
00050   protected:
00051     Broker(const UserConfig& usercfg);
00052   public:
00053     virtual ~Broker();
00054   protected:
00056 
00060     virtual void SortTargets() = 0;
00061 
00062     const UserConfig& usercfg;
00063 
00065 
00068     std::list<ExecutionTarget*> PossibleTargets;
00070     bool TargetSortingDone;
00071     const JobDescription *job;
00072 
00073     static Logger logger;
00074 
00075   private:
00078     std::list<ExecutionTarget*>::iterator current;
00079   };
00080 
00084   class BrokerLoader
00085     : public Loader {
00086 
00087   public:
00090     BrokerLoader();
00091 
00095     ~BrokerLoader();
00096 
00101     Broker* load(const std::string& name,
00102                  const UserConfig& usercfg);
00103 
00106     const std::list<Broker*>& GetBrokers() const {
00107       return brokers;
00108     }
00109 
00110   private:
00111     std::list<Broker*> brokers;
00112   };
00113 
00114   class BrokerPluginArgument
00115     : public PluginArgument {
00116   public:
00117     BrokerPluginArgument(const UserConfig& usercfg)
00118       : usercfg(usercfg) {}
00119     ~BrokerPluginArgument() {}
00120     operator const UserConfig&() {
00121       return usercfg;
00122     }
00123   private:
00124     const UserConfig& usercfg;
00125   };
00126 
00127 } // namespace Arc
00128 
00129 #endif // __ARC_BROKER_H__