Main Page | Class Hierarchy | Class List | File List | Class Members

query.h

00001 /*********************************************************************
00002  *
00003  * Condor ClassAd library
00004  * Copyright (C) 1990-2003, Condor Team, Computer Sciences Department,
00005  * University of Wisconsin-Madison, WI and Rajesh Raman.
00006  *
00007  * This source code is covered by the Condor Public License, which can
00008  * be found in the accompanying LICENSE file, or online at
00009  * www.condorproject.org.
00010  *
00011  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00012  * AND THE UNIVERSITY OF WISCONSIN-MADISON "AS IS" AND ANY EXPRESS OR
00013  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00014  * WARRANTIES OF MERCHANTABILITY, OF SATISFACTORY QUALITY, AND FITNESS
00015  * FOR A PARTICULAR PURPOSE OR USE ARE DISCLAIMED. THE COPYRIGHT
00016  * HOLDERS AND CONTRIBUTORS AND THE UNIVERSITY OF WISCONSIN-MADISON
00017  * MAKE NO MAKE NO REPRESENTATION THAT THE SOFTWARE, MODIFICATIONS,
00018  * ENHANCEMENTS OR DERIVATIVE WORKS THEREOF, WILL NOT INFRINGE ANY
00019  * PATENT, COPYRIGHT, TRADEMARK, TRADE SECRET OR OTHER PROPRIETARY
00020  * RIGHT.
00021  *
00022  *********************************************************************/
00023 
00024 #ifndef __QUERY_H__
00025 #define __QUERY_H__
00026 
00027 #include <vector>
00028 #include <list>
00029 #include <string>
00030 
00031 BEGIN_NAMESPACE( classad )
00032 
00033 class ClassAdCollection;
00034 class ExprTree;
00035 class ClassAd;
00036 
00037 class LocalCollectionQuery {
00038 public:
00039         LocalCollectionQuery( );
00040         ~LocalCollectionQuery( );
00041 
00042         void Bind( ClassAdCollection * );
00043         bool Query( const std::string &viewName, ExprTree *constraint=NULL );
00044         void Clear( );
00045 
00046         void ToFirst(void);
00047         bool IsAtFirst( ) const { return( itr==keys.begin( ) ); }
00048         bool Current( std::string &key );
00049         bool Next( std::string &key );
00050         bool Prev( std::string &key );
00051         void ToAfterLast(void);
00052         bool IsAfterLast(void) const { return( itr==keys.end( ) ); }
00053 
00054         typedef std::vector<std::string>::iterator iterator;
00055         typedef std::vector<std::string>::const_iterator const_iterator;
00056 
00057         iterator begin()              { return keys.begin(); }
00058         const_iterator begin() const  { return keys.begin(); }
00059         iterator end()                { return keys.end(); }
00060         const_iterator end() const    { return keys.end(); }
00061 
00062 private:
00063         ClassAdCollection                   *collection;
00064         std::vector<std::string>            keys;
00065         std::vector<std::string>::iterator  itr;
00066 };
00067 
00068 
00069 END_NAMESPACE // classad
00070 
00071 #endif
00072