src/requestad/Ad.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_AD_H
00021 #define GLITE_WMS_COMMON_REQUESTAD_AD_H
00022 /*
00023  * Ad.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 
00028 
00051 #include "classad_distribution.h"
00052 
00053 namespace glite {
00054 namespace jdl {
00055 
00067 class Ad : protected classad::ClassAd{
00068         public :
00073                 Ad() ;
00076                 virtual ~Ad() throw();
00080                 Ad(const classad::ClassAd& classAd );
00084                 Ad(const std::string& jdl_string) ;
00085                 Ad(const Ad& jobad);
00087                 virtual void operator=(const Ad& jobad);
00088 
00090 
00095                 void fromString(const std::string& jdl_string, std::string jdl_file= "") ;
00099                 void fromFile(const std::string& jdl_file) ;
00104                 void fromStream(std::istream& jdl_in) ;
00108                 virtual void fromClassAd(const classad::ClassAd& classAd);
00110 
00115                 virtual std::string toString();
00119                 virtual std::string toString( const std::string& attr_name );
00123                 virtual std::string toLines();
00126                 bool isSet() ;
00128                 void clear();
00130 
00134                 classad::ClassAd* const ad(){return static_cast<ClassAd*>(Copy());}
00138                 bool hasAttribute(const std::string& attr_name);
00144                 virtual classad::ExprTree* delAttribute(const std::string& attr_name) ;
00149                 void remAttribute(const std::string& attr_name) ;
00154                 virtual classad::ExprTree* lookUp(const std::string& attr_name){ return Lookup(attr_name);};
00155 
00158                 bool hasAttribute(const std::string& attr_name, const std::string& attr_value);
00163                 std::vector<std::string> attributes() ;
00170                 void merge (Ad source, bool overwrite=true);
00172 
00174                 enum {
00177                 TYPE_UNKNOWN = classad::Value::ERROR_VALUE,
00180                 TYPE_INTEGER =classad::Value::INTEGER_VALUE,
00183                 TYPE_BOOLEAN =classad::Value::BOOLEAN_VALUE,
00186                 TYPE_STRING =classad::Value::STRING_VALUE,
00189                 TYPE_REAL =classad::Value::REAL_VALUE,
00192                 TYPE_CLASSAD =classad::Value::CLASSAD_VALUE,
00195                 TYPE_EXPRESSION =classad::Value::UNDEFINED_VALUE
00196                 };
00209                 int getType (const std::string& attr_name )   ;
00217                 void  addAttribute (const std::string& attr_name, int attr_value)          ;
00225                 void  addAttribute (const std::string& attr_name, double attr_value)       ;
00233                 void  addAttribute (const std::string& attr_name, bool attr_value)         ;
00242                 void  addAttribute (const std::string& attr_name, const std::string& attr_value);
00251                 void  addAttribute (const std::string& attr_name, const char *attr_value){addAttribute(attr_name , std::string(attr_value));}
00260                 void  addAttribute (const std::string& attr_name, Ad* attr_value);
00267                 virtual void  setAttributeExpr (const std::string& attr_name, const std::string& attr_value);
00274                 virtual void  setAttribute (const std::string& attr_name, int attr_value) ;
00281                 virtual void  setAttribute (const std::string& attr_name, const std::string& attr_value) ;
00288                 virtual void  setAttribute (const std::string& attr_name, const char *attr_value ) {  setAttribute (attr_name , std::string(attr_value) ); }
00295                 virtual void  setAttribute (const std::string& attr_name, double attr_value)   ;
00302                 virtual void  setAttribute (const std::string& attr_name, bool attr_value)   ;
00309                 virtual void  setAttribute (const std::string& attr_name, Ad* attr_value) ;
00316                 virtual void  setAttributeExpr (const std::string& attr_name, classad::ExprTree* attr_value) ;
00323                 virtual std::string  getAttributeExpr (const std::string& attr_name)    ;
00330                 std::vector<int> getIntValue(const std::string& attr_name) ;
00337                 std::vector<double> getDoubleValue(const std::string& attr_name) ;
00344                 std::vector<bool> getBoolValue(const std::string& attr_name) ;
00351                 virtual std::vector<std::string> getStringValue(const std::string& attr_name) ;
00358                 std::vector<std::vector<std::string> > getStringList(const std::string& attr_name) ;
00365                 virtual Ad getAd(const std::string& attr_name);
00372                 virtual std::string getString(const std::string& attr_name) ;
00379                 virtual int getInt(const std::string& attr_name) ;
00386                 virtual double getDouble(const std::string& attr_name) ;
00393                 virtual bool getBool(const std::string& attr_name) ;
00395 
00403                 bool hasWarnings();
00410                 std::vector<std::string> getWarnings();
00417                 void addWarning(const std::string &msg);
00419         protected:
00427                 virtual void addAttribute(std::string attr_name , classad::Value val) ;
00434                 virtual void appendValue(classad::ExprTree* tree , const classad::Value& val, const std::string& attr_name) ;
00440                 virtual void insertAttribute(const std::string& attr_name , classad::ExprTree* val);
00446                 virtual void insertAttribute(const std::string& attr_name , classad::Value val);
00452                 virtual classad::Value getTypeValue(const std::string& attr_name);
00457                 bool hasAttribute( classad::ExprTree* tree ,  const std::string& attr_value);
00459                 std::vector<std::string> warning_messages_v ;
00460 
00461 };
00462 /******************************************************************
00463  method :   glite_wms_jdl_toLower
00464 return the input string as in lower case
00465 *******************************************************************/
00466 std::string glite_wms_jdl_toLower ( const std::string &src);
00467 } // jdl namespace
00468 } // glite namespace
00469 
00470 #endif
00471 
00472 //EOF
00473 

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