query.h

00001 /***************************************************************
00002  *
00003  * Copyright (C) 1990-2007, Condor Team, Computer Sciences Department,
00004  * University of Wisconsin-Madison, WI.
00005  * 
00006  * Licensed under the Apache License, Version 2.0 (the "License"); you
00007  * may not use this file except in compliance with the License.  You may
00008  * 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, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  *
00018  ***************************************************************/
00019 
00020 
00021 #ifndef __CLASSAD_QUERY_H__
00022 #define __CLASSAD_QUERY_H__
00023 
00024 #include <vector>
00025 #include <list>
00026 #include <string>
00027 
00028 BEGIN_NAMESPACE( classad )
00029 
00030 class ClassAdCollection;
00031 class ExprTree;
00032 class ClassAd;
00033 
00034 class LocalCollectionQuery {
00035 public:
00036     LocalCollectionQuery( );
00037     ~LocalCollectionQuery( );
00038 
00039     void Bind( ClassAdCollection * );
00040     bool Query( const std::string &viewName, ExprTree *constraint=NULL, 
00041                 bool two_way_matching = false);
00042     void Clear( );
00043 
00044     void ToFirst(void);
00045     bool IsAtFirst( ) const { return( itr==keys.begin( ) ); }
00046     bool Current( std::string &key );
00047     bool Next( std::string &key );
00048     bool Prev( std::string &key );
00049     void ToAfterLast(void);
00050     bool IsAfterLast(void) const { return( itr==keys.end( ) ); }
00051 
00052     typedef std::vector<std::string>::iterator iterator;
00053     typedef std::vector<std::string>::const_iterator const_iterator;
00054 
00055     iterator begin()              { return keys.begin(); }
00056     const_iterator begin() const  { return keys.begin(); }
00057     iterator end()                { return keys.end(); }
00058     const_iterator end() const    { return keys.end(); }
00059 
00060 private:
00061     ClassAdCollection                   *collection;
00062     std::vector<std::string>            keys;
00063     std::vector<std::string>::iterator  itr;
00064 };
00065 
00066 
00067 END_NAMESPACE // classad
00068 
00069 #endif
00070 
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends