kdecore Library API Documentation

kresolverworkerbase.h

00001 /* -*- C++ -*- 00002 * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net> 00003 * 00004 * 00005 * Permission is hereby granted, free of charge, to any person obtaining 00006 * a copy of this software and associated documentation files (the 00007 * "Software"), to deal in the Software without restriction, including 00008 * without limitation the rights to use, copy, modify, merge, publish, 00009 * distribute, sublicense, and/or sell copies of the Software, and to 00010 * permit persons to whom the Software is furnished to do so, subject to 00011 * the following conditions: 00012 * 00013 * The above copyright notice and this permission notice shall be included 00014 * in all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00017 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00019 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00020 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00021 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00022 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 */ 00024 00025 #ifndef KRESOLVERWORKERBASE_H 00026 #define KRESOLVERWORKERBASE_H 00027 00028 #include "kresolver.h" 00029 00030 // forward declarations 00031 class QString; 00032 template <class T> class QValueList; 00033 00034 namespace KNetwork { 00035 00036 namespace Internal 00037 { 00038 class KResolverThread; 00039 } 00040 00059 class KResolverWorkerBase 00060 { 00061 private: 00062 // this will be like our d pointer 00063 KNetwork::Internal::KResolverThread *th; 00064 const KResolverPrivate::InputData *input; 00065 friend class KNetwork::Internal::KResolverThread; 00066 friend class KNetwork::Internal::KResolverManager; 00067 00068 int m_finished : 1; 00069 int m__reserved : 31; // reserved 00070 00071 public: 00079 KResolverResults results; 00080 00081 public: 00082 // default constructor 00083 KResolverWorkerBase(); 00084 00085 // virtual destructor 00086 virtual ~KResolverWorkerBase(); 00087 00091 QString nodeName() const; 00092 00096 QString serviceName() const; 00097 00101 int flags() const; 00102 00106 int familyMask() const; 00107 00111 int socketType() const; 00112 00116 int protocol() const; 00117 00121 QCString protocolName() const; 00122 00129 void finished(); 00130 00131 protected: 00132 // like a QThread 00145 virtual bool run() = 0; 00146 00166 virtual bool preprocess() = 0; 00167 00176 virtual bool postprocess(); 00177 00181 inline void setError(int errorcode, int syserror = 0) 00182 { results.setError(errorcode, syserror); } 00183 00199 bool enqueue(KResolver* other); 00200 00204 bool enqueue(KResolverWorkerBase* worker); 00205 }; 00206 00212 class KResolverWorkerFactoryBase 00213 { 00214 public: 00215 virtual KResolverWorkerBase* create() const = 0; 00216 00217 /* 00218 * Wrapper call to register workers 00219 * 00220 * It is NOT thread-safe! 00221 */ 00222 static void registerNewWorker(KResolverWorkerFactoryBase* factory); 00223 }; 00224 00230 template<class Worker> 00231 class KResolverWorkerFactory: public KResolverWorkerFactoryBase 00232 { 00233 public: 00234 virtual KResolverWorkerBase* create() const 00235 { return new Worker; } 00236 }; 00237 00238 } // namespace KNetwork 00239 00240 #endif
KDE Logo
This file is part of the documentation for kdecore Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:40:09 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003