glite::jdl::Ad Class Reference

#include <glite/jdl/Ad.h>

Inheritance diagram for glite::jdl::Ad:

glite::jdl::CollectionAd glite::jdl::JobAd glite::jdl::NodeAd glite::jdl::ParametricAd

Get Methods

enum  {
  TYPE_UNKNOWN = classad::Value::ERROR_VALUE, TYPE_INTEGER = classad::Value::INTEGER_VALUE, TYPE_BOOLEAN = classad::Value::BOOLEAN_VALUE, TYPE_STRING = classad::Value::STRING_VALUE,
  TYPE_REAL = classad::Value::REAL_VALUE, TYPE_CLASSAD = classad::Value::CLASSAD_VALUE, TYPE_EXPRESSION = classad::Value::UNDEFINED_VALUE
}
int getType (const std::string &attr_name)
void addAttribute (const std::string &attr_name, int attr_value)
void addAttribute (const std::string &attr_name, double attr_value)
void addAttribute (const std::string &attr_name, bool attr_value)
void addAttribute (const std::string &attr_name, const std::string &attr_value)
void addAttribute (const std::string &attr_name, const char *attr_value)
void addAttribute (const std::string &attr_name, Ad *attr_value)
virtual void setAttributeExpr (const std::string &attr_name, const std::string &attr_value)
virtual void setAttribute (const std::string &attr_name, int attr_value)
virtual void setAttribute (const std::string &attr_name, const std::string &attr_value)
virtual void setAttribute (const std::string &attr_name, const char *attr_value)
virtual void setAttribute (const std::string &attr_name, double attr_value)
virtual void setAttribute (const std::string &attr_name, bool attr_value)
virtual void setAttribute (const std::string &attr_name, Ad *attr_value)
virtual void setAttributeExpr (const std::string &attr_name, classad::ExprTree *attr_value)
virtual std::string getAttributeExpr (const std::string &attr_name)
std::vector< int > getIntValue (const std::string &attr_name)
std::vector< double > getDoubleValue (const std::string &attr_name)
std::vector< bool > getBoolValue (const std::string &attr_name)
virtual std::vector< std::string > getStringValue (const std::string &attr_name)
std::vector< std::vector<
std::string > > 
getStringList (const std::string &attr_name)
virtual Ad getAd (const std::string &attr_name)
virtual std::string getString (const std::string &attr_name)
virtual int getInt (const std::string &attr_name)
virtual double getDouble (const std::string &attr_name)
virtual bool getBool (const std::string &attr_name)

Public Member Functions

Constructors
 Ad ()
virtual ~Ad () throw ()
 Ad (const classad::ClassAd &classAd)
 Ad (const std::string &jdl_string)
 Ad (const Ad &jobad)
virtual void operator= (const Ad &jobad)
From methods
void fromString (const std::string &jdl_string, std::string jdl_file="")
void fromFile (const std::string &jdl_file)
void fromStream (std::istream &jdl_in)
virtual void fromClassAd (const classad::ClassAd &classAd)
To methods
virtual std::string toString ()
virtual std::string toString (const std::string &attr_name)
virtual std::string toLines ()
bool isSet ()
void clear ()
general methods
classad::ClassAd *const ad ()
bool hasAttribute (const std::string &attr_name)
virtual classad::ExprTree * delAttribute (const std::string &attr_name)
void remAttribute (const std::string &attr_name)
virtual classad::ExprTree * lookUp (const std::string &attr_name)
bool hasAttribute (const std::string &attr_name, const std::string &attr_value)
std::vector< std::string > attributes ()
void merge (Ad source, bool overwrite=true)
Warnings Management
bool hasWarnings ()
std::vector< std::string > getWarnings ()
void addWarning (const std::string &msg)

Protected Member Functions

virtual void addAttribute (std::string attr_name, classad::Value val)
virtual void appendValue (classad::ExprTree *tree, const classad::Value &val, const std::string &attr_name)
virtual void insertAttribute (const std::string &attr_name, classad::ExprTree *val)
virtual void insertAttribute (const std::string &attr_name, classad::Value val)
virtual classad::Value getTypeValue (const std::string &attr_name)
bool hasAttribute (classad::ExprTree *tree, const std::string &attr_value)

Protected Attributes

std::vector< std::string > warning_messages_v

Detailed Description

Provides a common interface for all Ad components. It allows the user to create a valid ClassAd instance utilizing native classes and retrieve any kind of information from it. It is utilised as a superclass for JobAd class
See also:
JobAd
Version:
0.1
Date:
15 April 2002
Author:
Alessandro Maraschini <alessandro.maraschini@datamat.it>


Member Enumeration Documentation

anonymous enum

Enumerator:
TYPE_UNKNOWN  Unknown type
See also:
getType
TYPE_INTEGER  Attribute Integer type value
See also:
getType
TYPE_BOOLEAN  Attribute Boolean type value
See also:
getType
TYPE_STRING  Attribute String type value
See also:
getType
TYPE_REAL  Attribute Real/Double type value
See also:
getType
TYPE_CLASSAD  Attribute Real/Double type value
See also:
getType
TYPE_EXPRESSION  Attribute Expression type value
See also:
getType


Constructor & Destructor Documentation

glite::jdl::Ad::Ad (  ) 

default Constructor

virtual glite::jdl::Ad::~Ad (  )  throw () [virtual]

Default Destructor

glite::jdl::Ad::Ad ( const classad::ClassAd &  classAd  ) 

Constructor by ClassAd

Parameters:
classAd the classad source where to create the Ad instance from

glite::jdl::Ad::Ad ( const std::string &  jdl_string  ) 

Constructor by string

Parameters:
jdl_string the Ad string representation

glite::jdl::Ad::Ad ( const Ad jobad  ) 


Member Function Documentation

classad::ClassAd* const glite::jdl::Ad::ad (  )  [inline]

Deep copy of Ad.

Returns:
a ClassAd pointer representing a copy of all Ad attributes

virtual void glite::jdl::Ad::addAttribute ( std::string  attr_name,
classad::Value  val 
) [protected, virtual]

Add a value to a list (if already present) or set the first value of this attribute

Parameters:
attr_name a string representing the attribute name
val The value of the attribute to be added
Exceptions:
AdMismatchException The type of value is not allowed for the specified attribute name
AdFormatException The type of value is not allowed for the specified attribute name

void glite::jdl::Ad::addAttribute ( const std::string &  attr_name,
Ad attr_value 
)

Allow adding a value to an already set attribute of the JobAd instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Parameters:
attr_name a string representing the attribute name
attr_value - The value of the attribute to be added
Exceptions:
AdMismatchException - The type of value is not allowed for the specified attribute name
AdFormatException The type of value is not allowed for the specified attribute name
AdSyntaxException - Syntax error caught while trying to add the attribute

void glite::jdl::Ad::addAttribute ( const std::string &  attr_name,
const char *  attr_value 
) [inline]

Allow adding a value to an already set attribute of the Ad instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Parameters:
attr_name a string representing the attribute name
attr_value - The value of the attribute to be added
Exceptions:
AdMismatchException - The type of value is not allowed for the specified attribute name
AdFormatException The type of value is not allowed for the specified attribute name
AdSyntaxException - Syntax error caught while trying to add the attribute

void glite::jdl::Ad::addAttribute ( const std::string &  attr_name,
const std::string &  attr_value 
)

Allow adding a value to an already set attribute of the Ad instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Parameters:
attr_name a string representing the attribute name
attr_value - The value of the attribute to be added
Exceptions:
AdMismatchException - The type of value is not allowed for the specified attribute name
AdFormatException The type of value is not allowed for the specified attribute name
AdSyntaxException - Syntax error caught while trying to add the attribute

void glite::jdl::Ad::addAttribute ( const std::string &  attr_name,
bool  attr_value 
)

Allow adding a value to an already set attribute of the JobAd instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Parameters:
attr_name a string representing the attribute name
attr_value - The value of the attribute to be added
Exceptions:
AdMismatchException - The type of value is not allowed for the specified attribute name
AdSyntaxException - Syntax error caught while trying to add the attribute

void glite::jdl::Ad::addAttribute ( const std::string &  attr_name,
double  attr_value 
)

Allow adding a value to an already set attribute of the JobAd instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Parameters:
attr_name a string representing the attribute name
attr_value - The value of the attribute to be added
Exceptions:
AdMismatchException - The type of value is not allowed for the specified attribute name
AdSyntaxException - Syntax error caught while trying to add the attribute

void glite::jdl::Ad::addAttribute ( const std::string &  attr_name,
int  attr_value 
)

Allow adding a value to an already set attribute of the JobAd instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Parameters:
attr_name a string representing the attribute name
attr_value - The value of the attribute to be added
Exceptions:
AdMismatchException - The type of value is not allowed for the specified attribute name
AdSyntaxException - Syntax error caught while trying to add the attribute

void glite::jdl::Ad::addWarning ( const std::string &  msg  ) 

Add a new warning message to Warnings may be due to usage of deprecated attributes, methods, procedures.

See also:
hasWarnings

getWarnings

Parameters:
msg the warning message to be appended

virtual void glite::jdl::Ad::appendValue ( classad::ExprTree *  tree,
const classad::Value &  val,
const std::string &  attr_name 
) [protected, virtual]

Append a value to a list

Parameters:
attr_name a string representing the attribute name
val - The value of the attribute to be added
tree the current value (before appending) of the attribute

std::vector<std::string> glite::jdl::Ad::attributes (  ) 

Retrieve the list of attribugtes present inside the instance

Returns:
a vector containing (with no order) all the attributes of the Ad

void glite::jdl::Ad::clear (  ) 

Reset the JobAd Instance. All the previous existing attributes will be deleted

virtual classad::ExprTree* glite::jdl::Ad::delAttribute ( const std::string &  attr_name  )  [virtual]

Delete an Attribute. It fails if the attribute doesn't exist

Exceptions:
AdEmptyException attribute has not been set yet
Returns:
the deep copy of the expression for the deleted attribute
Parameters:
attr_name The name of the attibute to be deleted

Reimplemented in glite::jdl::JobAd.

virtual void glite::jdl::Ad::fromClassAd ( const classad::ClassAd &  classAd  )  [virtual]

Create the JobAd object with the given classad

Parameters:
classAd this is the job description passed as a classad

Reimplemented in glite::jdl::JobAd.

void glite::jdl::Ad::fromFile ( const std::string &  jdl_file  ) 

Create an Ad instacne from a file

Parameters:
jdl_file the string representing the path containing the jdl to be parsed

void glite::jdl::Ad::fromStream ( std::istream &  jdl_in  ) 

Create the JobAd object with the given input stream.

Parameters:
jdl_in this is the job description passed in the form of a generic input stream so that it can be taken from a terminal input stream, file input stream, string streams etc.

void glite::jdl::Ad::fromString ( const std::string &  jdl_string,
std::string  jdl_file = "" 
)

Create an Ad instance from a string

Parameters:
jdl_string the ad string representation
jdl_file path of the jdl file

virtual Ad glite::jdl::Ad::getAd ( const std::string &  attr_name  )  [virtual]

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute name to be retrieved
Returns:
the Ad instance for the specified attribute
Exceptions:
AdEmptyException The checked attribute has not been set yet
AdMismatchException The type of retrieved value is not allowed for the specified attribute name

Reimplemented in glite::jdl::JobAd.

virtual std::string glite::jdl::Ad::getAttributeExpr ( const std::string &  attr_name  )  [virtual]

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute name to be retrieved
Returns:
the string representation of this attribute
Exceptions:
AdEmptyException - The checked attribute has not been set yet
AdMismatchException - The type of retrieved value is not allowed for the specified attribute name

virtual bool glite::jdl::Ad::getBool ( const std::string &  attr_name  )  [virtual]

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute name to be retrieved
Returns:
the value of the specified attribute
Exceptions:
AdEmptyException The checked attribute has not been set yet
AdMismatchException The value is not a single bool

Reimplemented in glite::jdl::JobAd.

std::vector<bool> glite::jdl::Ad::getBoolValue ( const std::string &  attr_name  ) 

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute to be retrieved
Returns:
a vector cantaining the values listed in the specified attribute , (1-size vector if the attribute has a single value)
Exceptions:
AdEmptyException - The checked attribute has not been set yet
AdMismatchException - The type of retrieved value is not allowed for the specified attribute name

virtual double glite::jdl::Ad::getDouble ( const std::string &  attr_name  )  [virtual]

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute name to be retrieved
Returns:
the value of the specified attribute
Exceptions:
AdEmptyException The checked attribute has not been set yet
AdMismatchException The value is not a single double

Reimplemented in glite::jdl::JobAd.

std::vector<double> glite::jdl::Ad::getDoubleValue ( const std::string &  attr_name  ) 

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute to be retrieved
Returns:
a vector cantaining the values listed in the specified attribute , (1-size vector if the attribute has a single value)
Exceptions:
AdEmptyException - The checked attribute has not been set yet
AdMismatchException - The type of retrieved value is not allowed for the specified attribute name

virtual int glite::jdl::Ad::getInt ( const std::string &  attr_name  )  [virtual]

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute name to be retrieved
Returns:
the value of the specified attribute
Exceptions:
AdEmptyException The checked attribute has not been set yet
AdMismatchException The value is not a single int

Reimplemented in glite::jdl::JobAd.

std::vector<int> glite::jdl::Ad::getIntValue ( const std::string &  attr_name  ) 

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute name to be retrieved
Returns:
a vector cantaining the values listed in the specified attribute , (1-size vector if the attribute has a single value)
Exceptions:
AdEmptyException - The checked attribute has not been set yet
AdMismatchException - The type of retrieved value is not allowed for the specified attribute name

virtual std::string glite::jdl::Ad::getString ( const std::string &  attr_name  )  [virtual]

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute name to be retrieved
Returns:
the value of the specified attribute
Exceptions:
AdEmptyException The checked attribute has not been set yet
AdMismatchException The value is not a single string

Reimplemented in glite::jdl::JobAd.

std::vector<std::vector<std::string> > glite::jdl::Ad::getStringList ( const std::string &  attr_name  ) 

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute to be retrieved
Returns:
a vector cantaining the a vector of strings (1-size vector if the attribute has a single value)
Exceptions:
AdEmptyException - The checked attribute has not been set yet
AdMismatchException - The type of retrieved value is not allowed for the specified attribute name

virtual std::vector<std::string> glite::jdl::Ad::getStringValue ( const std::string &  attr_name  )  [virtual]

Retreive the value of the specified attribute

Parameters:
attr_name The name of the attribute to be retrieved
Returns:
a vector cantaining the values listed in the specified attribute , (1-size vector if the attribute has a single value)
Exceptions:
AdEmptyException - The checked attribute has not been set yet
AdMismatchException - The type of retrieved value is not allowed for the specified attribute name

Reimplemented in glite::jdl::NodeAd, and glite::jdl::ParametricAd.

int glite::jdl::Ad::getType ( const std::string &  attr_name  ) 

Retrieve the type of the value specified for attr_name

Parameters:
attr_name the name of the attribute
Returns:
an integer representing the type of the attribute
Exceptions:
AdEmptyException if the attribute is not present in the JobAd instance
See also:
TYPE_UNKNOWN

TYPE_INTEGER

TYPE_BOOLEAN

TYPE_STRING

TYPE_REAL

TYPE_CLASSAD

TYPE_EXPRESSION

virtual classad::Value glite::jdl::Ad::getTypeValue ( const std::string &  attr_name  )  [protected, virtual]

Retrieve the Value of the specified attribute

Parameters:
attr_name a string representing the attribute name
Returns:
the Value of the attribute inside the Ad instance

std::vector<std::string> glite::jdl::Ad::getWarnings (  ) 

Retrieve all collected warnings Warnings may be due to usage of deprecated attributes, methods, procedures.

See also:
hasWarnings

addWarning

Returns:
a list of string, each one represent the warning message

bool glite::jdl::Ad::hasAttribute ( classad::ExprTree *  tree,
const std::string &  attr_value 
) [protected]

Check whether a value is present inside a classad Expression

Parameters:
tree the expression to be checked
attr_value the value to be checked
Returns:
true (if the value is present) false otherwise

bool glite::jdl::Ad::hasAttribute ( const std::string &  attr_name,
const std::string &  attr_value 
)

Check if the specified value is present in the specified attribute

bool glite::jdl::Ad::hasAttribute ( const std::string &  attr_name  ) 

Check If the specified attribute has already been set

Parameters:
attr_name The name of the attibute to be looked for
Returns:
true if the attribute has been found, false otherwise

bool glite::jdl::Ad::hasWarnings (  ) 

Determine whether there are any warning. Warnings may be due to usage of deprecated attributes, methods, procedures.

See also:
getWarnings

addWarning

Returns:
true whether warnings have been found

virtual void glite::jdl::Ad::insertAttribute ( const std::string &  attr_name,
classad::Value  val 
) [protected, virtual]

Insert a classad Exptression inside the Ad instance

Parameters:
attr_name a string representing the attribute name
val - The value of the attribute to be added

virtual void glite::jdl::Ad::insertAttribute ( const std::string &  attr_name,
classad::ExprTree *  val 
) [protected, virtual]

Insert a classad Exptression inside the Ad instance

Parameters:
attr_name a string representing the attribute name
val - The value of the attribute to be added

Reimplemented in glite::jdl::JobAd, glite::jdl::NodeAd, and glite::jdl::ParametricAd.

bool glite::jdl::Ad::isSet (  ) 

Check whether the JobAd has been initialised

Returns:
whether the JobAd has been initialised(true) or not (false)

virtual classad::ExprTree* glite::jdl::Ad::lookUp ( const std::string &  attr_name  )  [inline, virtual]

Returns an expression. NULL returned if the attribute doesn't exist

Returns:
the deep copy of the expression for the attribute
Parameters:
attr_name The name of the attibute to be deleted

void glite::jdl::Ad::merge ( Ad  source,
bool  overwrite = true 
)

merge the attributes of the specified classad overriding the attribute with the same name Classad type attribute will be recoursively merged

Parameters:
source the Ad instance which will be merged in the current Ad. attributes with the same name will have its values
overwrite in case of already exising attriubte, determine whether to overwrite it

virtual void glite::jdl::Ad::operator= ( const Ad jobad  )  [virtual]

Operator "=" performs a deep copy of the Ad instance

void glite::jdl::Ad::remAttribute ( const std::string &  attr_name  ) 

Delete an Attribute. It fails if the attribute doesn't exist

Exceptions:
AdEmptyException attribute has not been set yet
Parameters:
attr_name The name of the attibute to be deleted

virtual void glite::jdl::Ad::setAttribute ( const std::string &  attr_name,
Ad attr_value 
) [virtual]

Add The specified Integer Attribute to the jdl istance

Parameters:
attr_name - The Name of the attribute to be added
attr_value - The value of the attribute to be added
Exceptions:
AdSyntaxException - Syntax error caught while trying to add the attribute
AdEmptyException - The attribute attr_name had been already set

virtual void glite::jdl::Ad::setAttribute ( const std::string &  attr_name,
bool  attr_value 
) [virtual]

Add The specified String Attribute to the jdl istance

Parameters:
attr_name - The Name of the attribute to be added
attr_value - The value of the attribute to be added
Exceptions:
AdSyntaxException - Syntax error caught while trying to add the attribute
AdEmptyException - The attribute attr_name had been already set

virtual void glite::jdl::Ad::setAttribute ( const std::string &  attr_name,
double  attr_value 
) [virtual]

Add The specified String Attribute to the jdl istance

Parameters:
attr_name - The Name of the attribute to be added
attr_value - The value of the attribute to be added
Exceptions:
AdSyntaxException - Syntax error caught while trying to add the attribute
AdEmptyException - The attribute attr_name had been already set

virtual void glite::jdl::Ad::setAttribute ( const std::string &  attr_name,
const char *  attr_value 
) [inline, virtual]

Add The specified String Attribute to the jdl istance

Parameters:
attr_name - The Name of the attribute to be added
attr_value - The value of the attribute to be added
Exceptions:
AdEmptyException - The attribute attr_name had been already set
AdFormatException The type of value is not allowed for the specified attribute name

virtual void glite::jdl::Ad::setAttribute ( const std::string &  attr_name,
const std::string &  attr_value 
) [virtual]

Add The specified String Attribute to the jdl istance

Parameters:
attr_name - The Name of the attribute to be added
attr_value - The value of the attribute to be added
Exceptions:
AdEmptyException - The attribute attr_name had been already set
AdFormatException The type of value is not allowed for the specified attribute name

virtual void glite::jdl::Ad::setAttribute ( const std::string &  attr_name,
int  attr_value 
) [virtual]

Add The specified Integer Attribute to the jdl istance

Parameters:
attr_name - The Name of the attribute to be added
attr_value - The value of the attribute to be added
Exceptions:
AdSyntaxException - Syntax error caught while trying to add the attribute
AdEmptyException - The attribute attr_name had been already set

virtual void glite::jdl::Ad::setAttributeExpr ( const std::string &  attr_name,
classad::ExprTree *  attr_value 
) [virtual]

Add The specified Expression Attribute to the jdl istance

Parameters:
attr_name - The Name of the attribute to be added
attr_value - The value of the attribute to be added
Exceptions:
AdSyntaxException - Syntax error caught while trying to add the attribute
AdEmptyException - The attribute attr_name had been already set

virtual void glite::jdl::Ad::setAttributeExpr ( const std::string &  attr_name,
const std::string &  attr_value 
) [virtual]

Add The specified Expression Attribute to the jdl istance

Parameters:
attr_name - The Name of the attribute to be added
attr_value - The string expression of the attribute to be added
Exceptions:
AdClassAdException - a classAd method raised an error
AdEmptyException - The attribute attr_name had been already set

Reimplemented in glite::jdl::JobAd.

virtual std::string glite::jdl::Ad::toLines (  )  [virtual]

Convert the Ad Instance into a multi line indented string representation

Returns:
as in toString() methods but splits the string one line per attribute

virtual std::string glite::jdl::Ad::toString ( const std::string &  attr_name  )  [virtual]

Convert an Ad attribute into its string representation

Parameters:
attr_name the attribute to be looked up
Returns:
return the attrbute string representation

virtual std::string glite::jdl::Ad::toString (  )  [virtual]

Convert the Ad Instance into a single line string representation

Returns:
the ad as in its string representation


Field Documentation

std::vector<std::string> glite::jdl::Ad::warning_messages_v [protected]

Collection of all warning messages (if any)


The documentation for this class was generated from the following file:
Generated on 7 Mar 2013 for jdl-api-cpp-3.4.1 by  doxygen 1.4.7