src/requestad/ExpDagAd.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) Members of the EGEE Collaboration. 2004.
00003 See http://www.eu-egee.org/partners/ for details on the
00004 copyright holders.
00005 
00006 Licensed under the Apache License, Version 2.0 (the "License");
00007 you may not use this file except in compliance with the License.
00008 You may obtain a copy of the License at
00009 
00010     http://www.apache.org/licenses/LICENSE-2.0
00011 
00012 Unless required by applicable law or agreed to in writing, software
00013 distributed under the License is distributed on an "AS IS" BASIS,
00014 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
00015 either express or implied.
00016 See the License for the specific language governing permissions and
00017 limitations under the License.
00018 */
00019 
00020 #ifndef GLITE_WMS_COMMON_REQUESTAD_EXPDAGAD_H
00021 #define GLITE_WMS_COMMON_REQUESTAD_EXPDAGAD_H
00022 /*
00023  * ExpDagAd.h
00024  * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved.
00025  * Contributors are mentioned in the code where appropriate.
00026  */
00027 #include "boost/scoped_ptr.hpp"
00028 #include "NodeAd.h"
00029 #include "DAGAd.h"
00030 #include "JdlAttributeList.h"
00031 #include "glite/jobid/JobId.h"
00032 #include <classad_distribution.h>
00033 #include "extractfiles.h"
00034 namespace glite {
00035 namespace jdl {
00036 
00041 struct JobIdStruct{
00042 
00044         JobIdStruct();
00045         
00047         JobIdStruct(const JobIdStruct& jobStruct);
00048 
00050         ~JobIdStruct();
00051 
00053         JobIdStruct& operator=(const JobIdStruct& jobStruct);
00054         
00056         glite::jobid::JobId jobid ;
00057 
00059         std::string* nodeName ;
00060 
00062         std::vector< JobIdStruct* > children ;
00063         
00064 private:
00065 
00069         void flushMemory(void); 
00070 };
00071 
00084 class ExpDagAd{
00085         typedef std::vector<classad::ExprTree*>  isb_value;
00086         public:
00088                 enum attribute {
00090                         EDG_JOBID,
00092                         VIRTUAL_ORGANISATION,
00094                         MYPROXY_SERVER,
00096                         SEQUENCE_CODE,
00098                         ISB_DEST_URI,
00100                         SUBMIT_TO
00101                 };
00103                 enum multiAttribute {
00105                         INPUTSB,
00107                         ZIPPED_ISB
00108                 };
00109                 enum level {
00111                         CURRENT ,
00113                         SUBMISSION,
00115                         NO_NODES,
00117                         MULTI_LINES,
00119                         RESTORED
00120                 };
00124                 ExpDagAd(  const std::string& jdl ) ;
00126                 ExpDagAd(  std::ifstream&  jdl_in ) ;
00128                 ExpDagAd( const ExpDagAd& dag );
00130                 ExpDagAd( Ad *ad );
00132                 ExpDagAd( const classad::ClassAd &classAd);
00134                 void operator=(const ExpDagAd& dag);
00136                 ExpDagAd( DAGAd* ad);
00138                 virtual ~ExpDagAd() throw();
00143                 ExpDagAd* check ();
00145 
00148                 std::string toString (const level &lev = CURRENT ) ;
00149 
00154                 std::vector<std::string> getSubmissionStrings (std::vector<std::string> *jobids=NULL) ;
00157                 std::string jobid2node(const std::string &jobid);
00159 
00164                 bool hasAttribute (const std::string& attr_name ) ;
00169                 bool hasNodeAttribute ( const glite::jobid::JobId &node,
00170                         const std::string &attr_name);
00175                 bool hasNodeAttribute (const std::string &node,
00176                         const std::string &attr_name);
00178 
00184                 void replaceNode (const glite::jobid::JobId &nodeId, NodeAd &nodeAd);
00189                 void replaceNode (const std::string &nodeName, NodeAd &nodeAd);
00191 
00198                 void setNodeAttribute ( const glite::jobid::JobId &node,
00199                         const std::string &attr_name,const std::string &attr_value);
00205                 void setNodeAttribute (const std::string &node,
00206                         const std::string &attr_name , const std::string &attr_value);
00212                 void setNodeAttribute ( const glite::jobid::JobId &node,
00213                         const std::string &attr_name,int &attr_value);
00219                 void setNodeAttribute (const std::string &node,
00220                         const std::string &attr_name , int &attr_value);
00226                 void setNodeAttribute ( const glite::jobid::JobId &node,
00227                         const std::string &attr_name,bool &attr_value);
00233                 void setNodeAttribute (const std::string &node,
00234                         const std::string &attr_name , bool &attr_value);
00241                 void setNodeAttribute (const glite::jobid::JobId &node,
00242                         const std::string &attr_name , const std::vector<std::string> &attr_value);
00249                 void setNodeAttribute (const std::string &node,
00250                         const std::string &attr_name , const std::vector<std::string> &attr_value);
00252 
00257                 NodeAd getNode (const glite::jobid::JobId &nodeId);
00261                 NodeAd getNode (const std::string &nodeName);
00267                 std::vector< std::string > getNodeStringValue (const glite::jobid::JobId &node,
00268                         const std::string &attr_name);
00274                 std::vector< std::string > getNodeStringValue (const std::string &node,
00275                         const std::string &attr_name);
00281                 int getNodeInt (const glite::jobid::JobId &node,
00282                         const std::string &attr_name);
00288                 int getNodeInt (const std::string &node,
00289                         const std::string &attr_name);
00295                 bool getNodeBool (const glite::jobid::JobId &node,
00296                         const std::string &attr_name);
00302                 bool getNodeBool (const std::string &node,
00303                         const std::string &attr_name);
00309                 std::string getNodeAttribute (const std::string &node,
00310                         const std::string &attr_name );
00314                 std::vector<  std::pair<  std::string  ,     classad::ExprTree* > >
00315                 getSubAttributes (const std::string &attr_name);
00318                 std::vector<std::string> getNodes();
00320 
00327                 void delNodeAttribute (const glite::jobid::JobId &node,
00328                         const std::string &attr_name );
00333                 void delNodeAttribute (const std::string &node,
00334                         const std::string &attr_name );
00338                 bool removeAttribute(attribute attr_name);
00342                 bool removeAttribute(const std::string& attr_name);
00344 
00346                 
00351                 void getJobIdStruct (JobIdStruct& jobIdStruct);
00352                 
00356                 std::map<std::string,std::string> getJobIdMap();
00361                 bool gettoBretrieved(){return toBretrieved;}
00367                 ExtractedAd* getExtractedAd();
00371                 void inherit(const std::string& attr_name);
00378                 void setLocalAccess(bool lookInto);
00381                 void expand () ;
00384                 std::string showDependencies () ;
00386 
00391                 std::string getAttribute (attribute attr_name );
00395                 std::string getString(const std::string &attr_name);
00399                 bool getBool(const std::string &attr_name);
00403                 Ad getAttributeAd (const std::string& attr_name);
00406                 std::vector<std::string> getInputSandbox ();
00407                 /*
00408                 *Retreive a Value instance of the selected type
00409                 * This Method is used by all  get<type>value methods
00410                 */
00411                 classad::Value getTypeValue(const std::string& attr_name);
00412                 std::vector<std::string> getStringValue(const std::string& attr_name);
00418                 std::vector<std::string> getAttribute (multiAttribute attr_name);
00420 
00426                 void setAttribute (attribute attr_name, const std::string& attr_value);
00431                 void setAttribute (multiAttribute attr_name, const std::vector<std::string>& attr_values);
00432 
00435                 std::size_t size();
00437 
00441                 const std::string getDefaultRank ();
00444                 const std::string getDefaultReq  ();
00450                 void setDefaultRank (const std::string& attr_value ) ;
00456                 void setDefaultReq   (const std::string& attr_value ) ;
00462                 void setDefaultRank (classad::ExprTree *attr_value ) ;
00468                 void setDefaultReq   (classad::ExprTree *attr_value ) ;
00474                 void setDefaultValues   (bool val) {  uiManipulation = val;  };
00476 
00485                 bool hasWarnings();
00492                 std::vector<std::string> getWarnings();
00499                 void addWarning(const std::string &msg);
00507                 void addWarnings(const std::string &nodeName, Ad *ad);
00509         protected:
00511                 boost::shared_ptr<glite::jdl::DAGAd> dagad;
00512         private:
00513                 // Reset all values
00514                 void reset() ;
00515                 void inherit(glite::jdl::NodeAd* jobad, const std::string& attr_name,
00516                         classad::ExprTree* expression, bool force=false);
00517                 void inherit(glite::jdl::NodeAd* jobad,classad::ClassAd &dagClassAd);
00518                 void evaluateAttribute(const std::string& attr_name, bool flatten=false) ;
00524                 std::vector<DAGAd::node_iterator> orderNodes();
00525                 void createMap();
00526                 classad::ExprTree* EvaluateValue(classad::Value val, classad::ExprList* list );
00527                 void checkSandBox( std::vector < std::pair<std::string , isb_value > >&  isb  , Ad& osb_nodes   );
00528                 void fromString (const std::string& jdl, std::string jdl_file ="") ;
00529                 void fromFile ( std::ifstream&  jdl_int ) ;
00530                 void extract();
00531                 bool checked ;
00532                 std::map<std::string,std::string> map_nodes;
00533                 checkType lookInto_b;
00534                 classad::ExprTree *defaultRank ;
00535                 classad::ExprTree  *defaultReq ;
00536                 bool uiManipulation,toBretrieved ;
00537                 // extracted local files
00538                 ExtractedAd *extractedAd ;
00539                 std::vector<std::string> warning_messages_v ;
00540 }; //ExpDag class definition end
00541 
00542 } // jdl namespace
00543 } // glite namespace
00544 
00545 #endif
00546 //EOF

Generated on Wed May 16 15:17:09 2012 for glite-jdl-api-cpp-3.2.5 by  doxygen 1.4.7