00001
00002
00003
00004
00005
00006
00007
00008
00015 #ifndef _FILESTREAMCONNECTION_
00016 #define _FILESTREAMCONNECTION_
00017
00018 #include <list>
00019 #include <fstream>
00020
00021 #include "edg/workload/common/ldif2classad/LDAPConnection.h"
00022 #include "edg/workload/common/ldif2classad/LDIFObject.h"
00023
00024 namespace classad {
00025 class ClassAd;
00026 }
00027
00028 namespace edg {
00029 namespace workload {
00030 namespace common {
00031 namespace ldif2classad {
00032
00033 class fstream_result_entry_t;
00038 class fstream_search_result_t : public generic_search_result_t
00039 {
00040 public:
00041 typedef std::list<classad::ClassAd*> result_container_type_t;
00042 typedef result_container_type_t::const_iterator const_iterator;
00043
00047 fstream_search_result_t(result_container_type_t *result);
00048
00049 ~fstream_search_result_t();
00050
00054 bool good() const;
00055 bool empty() const;
00056
00061 generic_result_entry_t* make_first_entry() const;
00062
00063 private:
00064
00065 result_container_type_t *fsresult;
00066 };
00067
00073 class fstream_result_entry_t : public generic_result_entry_t
00074 {
00075 public:
00081 fstream_result_entry_t( const fstream_search_result_t::const_iterator& first,
00082 const fstream_search_result_t::const_iterator& last );
00083
00088 bool next();
00093 bool good () const;
00094
00099 std::string distinguished_name() const;
00100
00105 LDIFObject* value();
00106
00107 private:
00108
00109 fstream_search_result_t::const_iterator fsentry;
00110
00111 fstream_search_result_t::const_iterator noentry;
00112
00113 LDIFObject object;
00114 };
00115
00123 class FileStreamConnection : public LDAPConnection
00124 {
00125 public:
00126 typedef classad::ClassAd source_data_type_t;
00127 typedef std::list<source_data_type_t*> source_data_container_t;
00131 FileStreamConnection(const std::string&);
00132
00136 virtual ~FileStreamConnection();
00137
00143 bool open();
00149 bool close();
00156 generic_search_result_t* execute(LDAPQuery* q);
00161 bool is_established() const;
00162 void use_multi_attribute_list(std::vector<std::string>* multi_attributes) { this -> multi_attributes = multi_attributes; }
00163
00164 void delete_source_data();
00165 bool load_source_data();
00166 bool read_data_object(std::string& s);
00167 bool seek_data_object();
00168
00169
00170 bool to_requirements(const std::string& s, std::string& r);
00171
00172 private:
00173 std::string source_name;
00174 std::ifstream source_stream;
00175 source_data_container_t *source_data;
00176 std::vector<std::string>* multi_attributes;
00177 };
00178
00179 #endif
00180
00181 }
00182 }
00183 }
00184 }
00185
00186
00187
00188
00189
00190