00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __CLASSAD_VIEW_H__
00022 #define __CLASSAD_VIEW_H__
00023
00024
00025 #include <string>
00026 #include <set>
00027
00028 #include "classad/classad_stl.h"
00029 #include "classad/exprTree.h"
00030 #include "classad/matchClassad.h"
00031
00032 BEGIN_NAMESPACE( classad )
00033
00034
00035 class ExprTree;
00036 class ClassAd;
00037 class View;
00038 class ClassAdCollection;
00039 class ClassAdCollectionServer;
00040
00041
00042 class ViewMember {
00043 public:
00044 ViewMember( );
00045 ViewMember(const ViewMember &other);
00046 ~ViewMember( );
00047
00048 void SetKey( const std::string &key );
00049 void SetRankValue( const Value &rankValue );
00050
00051 void GetKey( std::string &key ) const;
00052 void GetRankValue( Value &rankValue ) const;
00053
00054 ViewMember operator=( const ViewMember& );
00055 friend bool operator<(const ViewMember &vm1, const ViewMember &vm2);
00056 private:
00057 std::string key;
00058 Value rank;
00059 };
00060
00061
00062 struct ViewMemberLT {
00063 bool operator()( const ViewMember &vm1, const ViewMember &vm2 ) const;
00064 };
00065
00066
00067 typedef std::string ViewName;
00068 typedef std::multiset<ViewMember, ViewMemberLT> ViewMembers;
00069 typedef classad_slist<View*> SubordinateViews;
00070 typedef classad_map<std::string,View*> PartitionedViews;
00071 typedef classad_map<std::string,ViewMembers::iterator> MemberIndex;
00072
00073
00074
00075 class View {
00076 public:
00077 View( View *parent );
00078 ~View( );
00079
00080
00081 bool SetViewName( const ViewName &viewName );
00082 bool SetConstraintExpr( ClassAdCollection *coll,
00083 const std::string &constraint );
00084 bool SetConstraintExpr( ClassAdCollection *coll,
00085 ExprTree *constraint );
00086 bool SetRankExpr( ClassAdCollection *coll, const std::string &expr );
00087 bool SetRankExpr( ClassAdCollection *coll, ExprTree *tree );
00088 bool SetPartitionExprs( ClassAdCollection *coll,
00089 const std::string &exprList );
00090 bool SetPartitionExprs( ClassAdCollection *coll, ExprList *el );
00091 bool SetViewInfo( ClassAdCollection *coll, ClassAd *viewInfo );
00092
00093
00094 inline ViewName GetViewName( ) const { return( viewName ); }
00095 inline View *GetParent( ) const { return parent; }
00096 inline int Size( ) const { return( viewMembers.size( ) ); }
00097 ExprTree *GetConstraintExpr( );
00098 ExprTree *GetRankExpr( );
00099 ExprList *GetPartitionAttributes( );
00100 ClassAd *GetViewInfo( );
00101 bool IsMember( const std::string &key );
00102 void GetSubordinateViewNames( std::vector<std::string>& );
00103 void GetPartitionedViewNames( std::vector<std::string>& );
00104 bool FindPartition( ClassAd *rep, ViewName &partition );
00105
00106
00107 bool InsertSubordinateView( ClassAdCollection *coll, ClassAd *vInfo );
00108 bool InsertPartitionedView( ClassAdCollection *coll, ClassAd *vInfo,
00109 ClassAd *rep );
00110 bool DeleteChildView( ClassAdCollection *coll,
00111 const ViewName &viewName );
00112 bool DeleteSubordinateView( ClassAdCollection *coll,
00113 const ViewName &viewName );
00114 bool DeletePartitionedView( ClassAdCollection *coll,
00115 const ViewName &viewName );
00116 bool DeletePartitionedView( ClassAdCollection *coll, ClassAd *rep );
00117
00118
00119 bool ClassAdInserted ( ClassAdCollection *coll,
00120 const std::string &key, ClassAd *ad );
00121 void ClassAdPreModify( ClassAdCollection *coll, ClassAd *ad );
00122 bool ClassAdModified ( ClassAdCollection *coll,
00123 const std::string &key, ClassAd *ad );
00124 void ClassAdDeleted ( ClassAdCollection *coll,
00125 const std::string &key, ClassAd *ad );
00126
00127
00128 bool Display( FILE * );
00129
00131 typedef ViewMembers::iterator iterator;
00132
00134 typedef ViewMembers::const_iterator const_iterator;
00135
00138 iterator begin() { return viewMembers.begin(); }
00139
00142 const_iterator begin() const { return viewMembers.begin(); }
00143
00146 iterator end() { return viewMembers.end(); }
00147
00150 const_iterator end() const { return viewMembers.end(); }
00151
00152 private:
00153 friend class ClassAdCollection;
00154 friend class ClassAdCollectionServer;
00155 friend class LocalCollectionQuery;
00156
00157
00158 std::string makePartitionSignature( ClassAd *ad );
00159 void DeleteView( ClassAdCollection * );
00160
00161 ViewName viewName;
00162 View *parent;
00163 ViewMembers viewMembers;
00164 MemberIndex memberIndex;
00165 PartitionedViews partitionedViews;
00166 SubordinateViews subordinateViews;
00167 std::string oldAdSignature;
00168 MatchClassAd evalEnviron;
00169 };
00170
00171 END_NAMESPACE
00172
00173 #endif // __CLASSAD_VIEW_H__