jdl-api-cpp-3.4.4
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExpDagAd.h
Go to the documentation of this file.
1 /*
2 Copyright (c) Members of the EGEE Collaboration. 2004.
3 See http://www.eu-egee.org/partners/ for details on the
4 copyright holders.
5 
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15 either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 */
19 
20 #ifndef GLITE_WMS_COMMON_REQUESTAD_EXPDAGAD_H
21 #define GLITE_WMS_COMMON_REQUESTAD_EXPDAGAD_H
22 /*
23  * ExpDagAd.h
24  * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved.
25  * Contributors are mentioned in the code where appropriate.
26  */
27 #include "boost/scoped_ptr.hpp"
28 #include "NodeAd.h"
29 #include "DAGAd.h"
30 #include "JdlAttributeList.h"
31 #include "glite/jobid/JobId.h"
32 #include <classad_distribution.h>
33 #include "extractfiles.h"
34 namespace glite {
35 namespace jdl {
36 
41 struct JobIdStruct{
42 
44  JobIdStruct();
45 
47  JobIdStruct(const JobIdStruct& jobStruct);
48 
50  ~JobIdStruct();
51 
53  JobIdStruct& operator=(const JobIdStruct& jobStruct);
54 
56  glite::jobid::JobId jobid ;
57 
59  std::string* nodeName ;
60 
62  std::vector< JobIdStruct* > children ;
63 
64 private:
65 
69  void flushMemory(void);
70 };
71 
84 class ExpDagAd{
85  typedef std::vector<classad::ExprTree*> isb_value;
86  public:
88  enum attribute {
101  };
108  };
109  enum level {
120  };
124  ExpDagAd( const std::string& jdl ) ;
126  ExpDagAd( std::ifstream& jdl_in ) ;
128  ExpDagAd( const ExpDagAd& dag );
130  ExpDagAd( Ad *ad );
132  ExpDagAd( const classad::ClassAd &classAd);
134  void operator=(const ExpDagAd& dag);
136  ExpDagAd( DAGAd* ad);
138  virtual ~ExpDagAd() throw();
143  ExpDagAd* check ();
145 
148  std::string toString (const level &lev = CURRENT ) ;
149 
154  std::vector<std::string> getSubmissionStrings (std::vector<std::string> *jobids=NULL) ;
157  std::string jobid2node(const std::string &jobid);
159 
164  bool hasAttribute (const std::string& attr_name ) ;
169  bool hasNodeAttribute ( const glite::jobid::JobId &node,
170  const std::string &attr_name);
175  bool hasNodeAttribute (const std::string &node,
176  const std::string &attr_name);
178 
184  void replaceNode (const glite::jobid::JobId &nodeId, NodeAd &nodeAd);
189  void replaceNode (const std::string &nodeName, NodeAd &nodeAd);
191 
198  void setNodeAttribute ( const glite::jobid::JobId &node,
199  const std::string &attr_name,const std::string &attr_value);
205  void setNodeAttribute (const std::string &node,
206  const std::string &attr_name , const std::string &attr_value);
212  void setNodeAttribute ( const glite::jobid::JobId &node,
213  const std::string &attr_name,int &attr_value);
219  void setNodeAttribute (const std::string &node,
220  const std::string &attr_name , int &attr_value);
226  void setNodeAttribute ( const glite::jobid::JobId &node,
227  const std::string &attr_name,bool &attr_value);
233  void setNodeAttribute (const std::string &node,
234  const std::string &attr_name , bool &attr_value);
241  void setNodeAttribute (const glite::jobid::JobId &node,
242  const std::string &attr_name , const std::vector<std::string> &attr_value);
249  void setNodeAttribute (const std::string &node,
250  const std::string &attr_name , const std::vector<std::string> &attr_value);
252 
257  NodeAd getNode (const glite::jobid::JobId &nodeId);
261  NodeAd getNode (const std::string &nodeName);
267  std::vector< std::string > getNodeStringValue (const glite::jobid::JobId &node,
268  const std::string &attr_name);
274  std::vector< std::string > getNodeStringValue (const std::string &node,
275  const std::string &attr_name);
281  int getNodeInt (const glite::jobid::JobId &node,
282  const std::string &attr_name);
288  int getNodeInt (const std::string &node,
289  const std::string &attr_name);
295  bool getNodeBool (const glite::jobid::JobId &node,
296  const std::string &attr_name);
302  bool getNodeBool (const std::string &node,
303  const std::string &attr_name);
309  std::string getNodeAttribute (const std::string &node,
310  const std::string &attr_name );
314  std::vector< std::pair< std::string , classad::ExprTree* > >
315  getSubAttributes (const std::string &attr_name);
318  std::vector<std::string> getNodes();
320 
327  void delNodeAttribute (const glite::jobid::JobId &node,
328  const std::string &attr_name );
333  void delNodeAttribute (const std::string &node,
334  const std::string &attr_name );
338  bool removeAttribute(attribute attr_name);
342  bool removeAttribute(const std::string& attr_name);
344 
346 
351  void getJobIdStruct (JobIdStruct& jobIdStruct);
352 
356  std::map<std::string,std::string> getJobIdMap();
361  bool gettoBretrieved(){return toBretrieved;}
371  void inherit(const std::string& attr_name);
378  void setLocalAccess(bool lookInto);
381  void expand () ;
384  std::string showDependencies () ;
386 
391  std::string getAttribute (attribute attr_name );
395  std::string getString(const std::string &attr_name);
399  bool getBool(const std::string &attr_name);
403  Ad getAttributeAd (const std::string& attr_name);
406  std::vector<std::string> getInputSandbox ();
407  /*
408  *Retreive a Value instance of the selected type
409  * This Method is used by all get<type>value methods
410  */
411  classad::Value getTypeValue(const std::string& attr_name);
412  std::vector<std::string> getStringValue(const std::string& attr_name);
418  std::vector<std::string> getAttribute (multiAttribute attr_name);
420 
426  void setAttribute (attribute attr_name, const std::string& attr_value);
431  void setAttribute (multiAttribute attr_name, const std::vector<std::string>& attr_values);
432 
435  std::size_t size();
437 
441  const std::string getDefaultRank ();
444  const std::string getDefaultReq ();
450  void setDefaultRank (const std::string& attr_value ) ;
456  void setDefaultReq (const std::string& attr_value ) ;
462  void setDefaultRank (classad::ExprTree *attr_value ) ;
468  void setDefaultReq (classad::ExprTree *attr_value ) ;
474  void setDefaultValues (bool val) { uiManipulation = val; };
476 
485  bool hasWarnings();
492  std::vector<std::string> getWarnings();
499  void addWarning(const std::string &msg);
507  void addWarnings(const std::string &nodeName, Ad *ad);
509  protected:
511  boost::shared_ptr<glite::jdl::DAGAd> dagad;
512  private:
513  // Reset all values
514  void reset() ;
515  void inherit(glite::jdl::NodeAd* jobad, const std::string& attr_name,
516  classad::ExprTree* expression, bool force=false);
517  void inherit(glite::jdl::NodeAd* jobad,classad::ClassAd &dagClassAd);
518  void evaluateAttribute(const std::string& attr_name, bool flatten=false) ;
524  std::vector<DAGAd::node_iterator> orderNodes();
525  void createMap();
526  classad::ExprTree* EvaluateValue(classad::Value val, classad::ExprList* list );
527  void checkSandBox( std::vector < std::pair<std::string , isb_value > >& isb , Ad& osb_nodes );
528  void fromString (const std::string& jdl, std::string jdl_file ="") ;
529  void fromFile ( std::ifstream& jdl_int ) ;
530  void extract();
531  bool checked ;
532  std::map<std::string,std::string> map_nodes;
533  checkType lookInto_b;
534  classad::ExprTree *defaultRank ;
535  classad::ExprTree *defaultReq ;
536  bool uiManipulation,toBretrieved ;
537  // extracted local files
538  ExtractedAd *extractedAd ;
539  std::vector<std::string> warning_messages_v ;
540 }; //ExpDag class definition end
541 
542 } // jdl namespace
543 } // glite namespace
544 
545 #endif
546 //EOF
void addWarning(const std::string &msg)
Provides a representation of the job description in the JDL language.
Definition: NodeAd.h:43
bool gettoBretrieved()
Definition: ExpDagAd.h:361
Ad getAttributeAd(const std::string &attr_name)
std::string * nodeName
Definition: ExpDagAd.h:59
classad::Value getTypeValue(const std::string &attr_name)
Definition: ExpDagAd.h:117
const std::string getDefaultRank()
void setAttribute(attribute attr_name, const std::string &attr_value)
bool getNodeBool(const glite::jobid::JobId &node, const std::string &attr_name)
Definition: ExpDagAd.h:98
Provides a representation of the job description in the JDL language.
Definition: ExpDagAd.h:84
std::vector< JobIdStruct * > children
Definition: ExpDagAd.h:62
std::string getNodeAttribute(const std::string &node, const std::string &attr_name)
std::vector< std::string > getInputSandbox()
std::vector< std::string > getStringValue(const std::string &attr_name)
bool getBool(const std::string &attr_name)
bool hasAttribute(const std::string &attr_name)
Definition: ExpDagAd.h:107
JobIdStruct & operator=(const JobIdStruct &jobStruct)
Definition: DAGAd.h:398
Definition: ExpDagAd.h:119
glite::jobid::JobId jobid
Definition: ExpDagAd.h:56
void setDefaultReq(const std::string &attr_value)
Definition: Ad.h:67
void operator=(const ExpDagAd &dag)
void inherit(const std::string &attr_name)
Definition: ExpDagAd.h:111
attribute
Definition: ExpDagAd.h:88
NodeAd getNode(const glite::jobid::JobId &nodeId)
Definition: ExpDagAd.h:96
Definition: ExpDagAd.h:113
Definition: ExpDagAd.h:115
void setDefaultRank(const std::string &attr_value)
std::string getString(const std::string &attr_name)
void addWarnings(const std::string &nodeName, Ad *ad)
const std::string getDefaultReq()
ExpDagAd * check()
void setDefaultValues(bool val)
Definition: ExpDagAd.h:474
void replaceNode(const glite::jobid::JobId &nodeId, NodeAd &nodeAd)
std::string showDependencies()
std::vector< std::string > getNodeStringValue(const glite::jobid::JobId &node, const std::string &attr_name)
bool hasNodeAttribute(const glite::jobid::JobId &node, const std::string &attr_name)
level
Definition: ExpDagAd.h:109
ExtractedAd * getExtractedAd()
std::vector< std::string > getWarnings()
std::vector< std::pair< std::string, classad::ExprTree * > > getSubAttributes(const std::string &attr_name)
ExpDagAd(const std::string &jdl)
std::string jobid2node(const std::string &jobid)
std::vector< std::string > getSubmissionStrings(std::vector< std::string > *jobids=NULL)
void setLocalAccess(bool lookInto)
Definition: extractfiles.h:56
void setNodeAttribute(const glite::jobid::JobId &node, const std::string &attr_name, const std::string &attr_value)
std::string getAttribute(attribute attr_name)
Definition: ExpDagAd.h:100
std::vector< std::string > getNodes()
Definition: ExpDagAd.h:105
boost::shared_ptr< glite::jdl::DAGAd > dagad
Definition: ExpDagAd.h:511
checkType
Provides a method for extracting files from a specified path.
Definition: extractfiles.h:215
int getNodeInt(const glite::jobid::JobId &node, const std::string &attr_name)
std::size_t size()
std::string toString(const level &lev=CURRENT)
void delNodeAttribute(const glite::jobid::JobId &node, const std::string &attr_name)
Definition: ExpDagAd.h:90
std::map< std::string, std::string > getJobIdMap()
bool removeAttribute(attribute attr_name)
Definition: ExpDagAd.h:94
Definition: ExpDagAd.h:41
multiAttribute
Definition: ExpDagAd.h:103
void getJobIdStruct(JobIdStruct &jobIdStruct)