glite/jdl/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 
00096                 void fromString(const std::string& jdl_string, std::string jdl_file= "") ;
00100                 void fromFile(const std::string& jdl_file) ;
00105                 void fromStream(std::istream& jdl_in) ;
00109                 virtual void fromClassAd(const classad::ClassAd& classAd);
00111 
00116                 virtual std::string toString();
00120                 virtual std::string toString( const std::string& attr_name );
00124                 virtual std::string toLines();
00127                 bool isSet() ;
00129                 void clear();
00131 
00135                 classad::ClassAd* const ad(){return static_cast<ClassAd*>(Copy());}
00139                 bool hasAttribute(const std::string& attr_name);
00145                 virtual classad::ExprTree* delAttribute(const std::string& attr_name) ;
00150                 void remAttribute(const std::string& attr_name) ;
00155                 virtual classad::ExprTree* lookUp(const std::string& attr_name){ return Lookup(attr_name);};
00156 
00159                 bool hasAttribute(const std::string& attr_name, const std::string& attr_value);
00164                 std::vector<std::string> attributes() ;
00171                 void merge (Ad source, bool overwrite=true);
00173 
00175                 enum {
00178                 TYPE_UNKNOWN = classad::Value::ERROR_VALUE,
00181                 TYPE_INTEGER =classad::Value::INTEGER_VALUE,
00184                 TYPE_BOOLEAN =classad::Value::BOOLEAN_VALUE,
00187                 TYPE_STRING =classad::Value::STRING_VALUE,
00190                 TYPE_REAL =classad::Value::REAL_VALUE,
00193                 TYPE_CLASSAD =classad::Value::CLASSAD_VALUE,
00196                 TYPE_EXPRESSION =classad::Value::UNDEFINED_VALUE
00197                 };
00210                 int getType (const std::string& attr_name )   ;
00218                 void  addAttribute (const std::string& attr_name, int attr_value)          ;
00226                 void  addAttribute (const std::string& attr_name, double attr_value)       ;
00234                 void  addAttribute (const std::string& attr_name, bool attr_value)         ;
00243                 void  addAttribute (const std::string& attr_name, const std::string& attr_value);
00252                 void  addAttribute (const std::string& attr_name, const char *attr_value){addAttribute(attr_name , std::string(attr_value));}
00261                 void  addAttribute (const std::string& attr_name, Ad* attr_value);
00268                 virtual void  setAttributeExpr (const std::string& attr_name, const std::string& attr_value);
00275                 virtual void  setAttribute (const std::string& attr_name, int attr_value) ;
00282                 virtual void  setAttribute (const std::string& attr_name, const std::string& attr_value) ;
00289                 virtual void  setAttribute (const std::string& attr_name, const char *attr_value ) {  setAttribute (attr_name , std::string(attr_value) ); }
00296                 virtual void  setAttribute (const std::string& attr_name, double attr_value)   ;
00303                 virtual void  setAttribute (const std::string& attr_name, bool attr_value)   ;
00310                 virtual void  setAttribute (const std::string& attr_name, Ad* attr_value) ;
00317                 virtual void  setAttributeExpr (const std::string& attr_name, classad::ExprTree* attr_value) ;
00324                 virtual std::string  getAttributeExpr (const std::string& attr_name)    ;
00331                 std::vector<int> getIntValue(const std::string& attr_name) ;
00338                 std::vector<double> getDoubleValue(const std::string& attr_name) ;
00345                 std::vector<bool> getBoolValue(const std::string& attr_name) ;
00352                 virtual std::vector<std::string> getStringValue(const std::string& attr_name) ;
00359                 std::vector<std::vector<std::string> > getStringList(const std::string& attr_name) ;
00366                 virtual Ad getAd(const std::string& attr_name);
00373                 virtual std::string getString(const std::string& attr_name) ;
00380                 virtual int getInt(const std::string& attr_name) ;
00387                 virtual double getDouble(const std::string& attr_name) ;
00394                 virtual bool getBool(const std::string& attr_name) ;
00396 
00404                 bool hasWarnings();
00411                 std::vector<std::string> getWarnings();
00418                 void addWarning(const std::string &msg);
00420         protected:
00428                 virtual void addAttribute(std::string attr_name , classad::Value val) ;
00435                 virtual void appendValue(classad::ExprTree* tree , const classad::Value& val, const std::string& attr_name) ;
00441                 virtual void insertAttribute(const std::string& attr_name , classad::ExprTree* val);
00447                 virtual void insertAttribute(const std::string& attr_name , classad::Value val);
00453                 virtual classad::Value getTypeValue(const std::string& attr_name);
00458                 bool hasAttribute( classad::ExprTree* tree ,  const std::string& attr_value);
00460                 std::vector<std::string> warning_messages_v ;
00461 
00462 };
00463 /******************************************************************
00464  method :   glite_wms_jdl_toLower
00465 return the input string as in lower case
00466 *******************************************************************/
00467 std::string glite_wms_jdl_toLower ( const std::string &src);
00468 } // jdl namespace
00469 } // glite namespace
00470 
00471 #endif
00472 
00473 //EOF
00474 

Generated on 2 Jul 2013 for jdl-api-cpp-3.4.2 by  doxygen 1.4.7