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