1 #include "YDFXResourceModel.hxx"
3 #include "YACSEvalYFX.hxx"
4 #include "YACSEvalResource.hxx"
5 //#include "ResourcesManager.hxx"
11 YDFXResourceModel::YDFXResourceModel(YACSEvalYFX* eval)
12 : AbstractResourceModel(),
17 YDFXResourceModel::~YDFXResourceModel()
21 bool YDFXResourceModel::getParallelizeStatus()const
23 return _eval->getParallelizeStatus();
26 void YDFXResourceModel::setParallelizeStatus(bool v)
28 _eval->setParallelizeStatus(v);
31 std::string YDFXResourceModel::getRemoteDir()const
33 return getClusterParams().getRemoteWorkingDir();
36 void YDFXResourceModel::setRemoteDir(const std::string& v)
38 getClusterParams().setRemoteWorkingDir(v);
41 std::string YDFXResourceModel::getDefaultRemoteDir(std::string machine)const
46 std::string YDFXResourceModel::getLocalDir()const
48 return getClusterParams().getLocalWorkingDir();
51 void YDFXResourceModel::setLocalDir(const std::string& v)
53 getClusterParams().setLocalWorkingDir(v);
56 std::string YDFXResourceModel::getWckey()const
58 return getClusterParams().getWCKey();
61 void YDFXResourceModel::setWckey(const std::string& v)
63 getClusterParams().setWCKey(v);
66 int YDFXResourceModel::getMaxDurationMinutes()const
70 getMaxDuration(hours, minutes);
74 void YDFXResourceModel::setMaxDurationMinutes(int v)
78 getMaxDuration(hours, minutes);
79 setMaxDuration(hours, v);
82 int YDFXResourceModel::getMaxDurationHours()const
86 getMaxDuration(hours, minutes);
90 void YDFXResourceModel::setMaxDurationHours(int v)
94 getMaxDuration(hours, minutes);
95 setMaxDuration(v, minutes);
98 unsigned int YDFXResourceModel::getNbprocs()const
100 return getClusterParams().getNbProcs();
103 void YDFXResourceModel::setNbprocs(unsigned int v)
105 getClusterParams().setNbProcs(v);
108 std::string YDFXResourceModel::getWantedMachine()const
110 const std::string default_machine("localhost");
111 std::vector<std::string> chosenMachines = resources()->getAllChosenMachines();
112 std::vector<std::string> fittingMachines = resources()->getAllFittingMachines();
113 std::string wantedMachine="";
114 std::vector<std::string>::const_iterator it;
115 bool foundMachine = false;
116 it = chosenMachines.begin();
117 // take the first chosen machine which is also fitting.
118 while(!foundMachine && it!=chosenMachines.end())
120 if(std::find(fittingMachines.begin(), fittingMachines.end(), *it)
121 != fittingMachines.end())
129 // take localhost if fitting
130 if(std::find(fittingMachines.begin(), fittingMachines.end(),
131 default_machine) != fittingMachines.end())
134 wantedMachine = default_machine;
136 else if(fittingMachines.size() > 0)
139 wantedMachine = fittingMachines[0];
142 return wantedMachine;
145 void YDFXResourceModel::setWantedMachine(const std::string& v)
147 resources()->setWantedMachine(v);
150 std::vector<std::string> YDFXResourceModel::getFittingMachines()const
152 return resources()->getAllFittingMachines();
155 const std::list<std::string>& YDFXResourceModel::getInFiles()const
157 return getClusterParams().getInFiles();
160 std::list<std::string>& YDFXResourceModel::getInFiles()
162 return getClusterParams().getInFiles();
165 bool YDFXResourceModel::isMachineInteractive(const std::string& machine)const
167 return resources()->isMachineInteractive(machine);
170 void YDFXResourceModel::reset(YACSEvalYFX* eval)
175 YACSEvalListOfResources* YDFXResourceModel::resources()
177 return _eval->giveResources();
180 const YACSEvalListOfResources* YDFXResourceModel::resources()const
182 return _eval->giveResources();
185 YACSEvalParamsForCluster& YDFXResourceModel::getClusterParams()
187 return _eval->giveResources()->getAddParamsForCluster();
190 const YACSEvalParamsForCluster& YDFXResourceModel::getClusterParams()const
192 return _eval->giveResources()->getAddParamsForCluster();
195 void YDFXResourceModel::getMaxDuration(int& hours, int& minutes)const
197 std::string duration = getClusterParams().getMaxDuration();
200 if(duration.size() > 0)
202 std::stringstream ss(duration);
204 std::getline(ss, value, ':');
205 hours = atoi(value.c_str());
206 std::getline(ss, value, ':');
207 minutes = atoi(value.c_str());
219 void YDFXResourceModel::setMaxDuration(int hours, int minutes)
221 getClusterParams().setMaxDuration(AbstractResourceModel::getMaxDuration());