00001
00002
00003
00004
00005
00006
00007
00008
00016 #ifndef _LDIFOBJECT_
00017 #define _LDIFOBJECT_
00018
00019 #include <iostream>
00020 #include <map>
00021 #include <string>
00022 #include "edg/workload/common/utilities/edgstrstream.h"
00023 #include <vector>
00024 #include <classad_distribution.h>
00025
00026 namespace edg {
00027 namespace workload {
00028 namespace common {
00029 namespace utilities {
00030 }
00031 namespace ldif2classad {
00032
00033 #define LEFT 1
00034 #define RIGHT 2
00035
00036 struct UndefinedRankEx
00037 {
00038 };
00039
00041 typedef std::vector<std::string> LDIFValue;
00043 typedef std::map<std::string,LDIFValue> LDIFAttributes;
00044
00050 class LDIFObject
00051 {
00052 public:
00053
00058 LDIFObject();
00059 LDIFObject(classad::ClassAd*);
00060
00066 LDIFObject(const LDIFObject&);
00073 LDIFObject& operator= (const LDIFObject& o );
00074
00081 void add(const std::string&, const std::string&);
00082
00083 void merge(const LDIFObject& o);
00084
00092 bool EvaluateAttribute(const std::string&, std::vector<std::string>&) const;
00093
00101 bool EvaluateAttribute(const std::string&, std::string&) const;
00102
00103 classad::ClassAd* asClassAd( void ) const { return ExportClassAd(); }
00104 classad::ClassAd* asClassAd( std::vector< std::string >::const_iterator b, std::vector<std::string>::const_iterator e) const { return ExportClassAd( b,e ); }
00105 private:
00106 void ParseValue( const std::string&, utilities::edgstrstream& ) const;
00107 void ParseMultiValue( const LDIFValue&, utilities::edgstrstream& ) const;
00108 std::string as_string(const classad::Value& v);
00109 LDIFAttributes from_ad(classad::ClassAd *ad);
00110 classad::ClassAd* ExportClassAd ( void ) const;
00111 classad::ClassAd* ExportClassAd ( std::vector< std::string >::const_iterator, std::vector<std::string>::const_iterator ) const;
00119 friend std::ostream& operator << (std::ostream&, const LDIFObject&);
00120
00122 mutable LDIFAttributes attributes;
00123 };
00124
00125 extern std::ostream& operator<< (std::ostream&, const LDIFObject&);
00126 extern bool MatchClassifiedAd (classad::ClassAd *where, classad::ClassAd *what);
00127 extern double RankClassifiedAd (classad::ClassAd *where, classad::ClassAd *what, int);
00128
00129 }
00130 }
00131 }
00132 }
00133
00134 #endif
00135
00136
00137
00138
00139
00140