# kdecore Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kresolverworkerbase.h

    00001 /*  -*- C++ -*-
    00002  *  Copyright (C) 2003,2004 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     struct InputData;
    00040   }
    00041
    00060 class KResolverWorkerBase
    00061 {
    00062 public:
    00063
    00071   class ResolverLocker
    00072   {
    00073   public:
    00077     ResolverLocker(KResolverWorkerBase* parent)
    00078       : parent( parent )
    00079     {
    00080       parent->acquireResolver();
    00081     }
    00082
    00086     ~ResolverLocker()
    00087     {
    00088       parent->releaseResolver();
    00089     }
    00090
    00096     void openClose()
    00097     {
    00098       parent->releaseResolver();
    00099       parent->acquireResolver();
    00100     }
    00101
    00102   private:
    00104     KResolverWorkerBase* parent;
    00105   };
    00106 private:
    00107   // this will be like our d pointer
    00108   KNetwork::Internal::KResolverThread *th;
    00109   const KNetwork::Internal::InputData *input;
    00110   friend class KNetwork::Internal::KResolverThread;
    00111   friend class KNetwork::Internal::KResolverManager;
    00112   friend class KResolverWorkerBase::ResolverLocker;
    00113
    00114   int m_finished : 1;
    00115   int m_reserved : 31;      // reserved
    00116
    00117 public:
    00125   KResolverResults results;
    00126
    00127 public:
    00128   // default constructor
    00129   KResolverWorkerBase();
    00130
    00131   // virtual destructor
    00132   virtual ~KResolverWorkerBase();
    00133
    00137   QString nodeName() const;
    00138
    00142   QString serviceName() const;
    00143
    00147   int flags() const;
    00148
    00152   int familyMask() const;
    00153
    00157   int socketType() const;
    00158
    00162   int protocol() const;
    00163
    00167   QCString protocolName() const;
    00168
    00175   void finished();
    00176
    00177 protected:
    00178   // like a QThread
    00191   virtual bool run() = 0;
    00192
    00212   virtual bool preprocess() = 0;
    00213
    00222   virtual bool postprocess();
    00223
    00227   inline void setError(int errorcode, int syserror = 0)
    00228   { results.setError(errorcode, syserror); }
    00229
    00245   bool enqueue(KResolver* other);
    00246
    00250   bool enqueue(KResolverWorkerBase* worker);
    00251
    00259   bool checkResolver();
    00260
    00272   void acquireResolver();
    00273
    00280   void releaseResolver();
    00281
    00282 };
    00283
    00289 class KResolverWorkerFactoryBase
    00290 {
    00291 public:
    00292   virtual KResolverWorkerBase* create() const = 0;
    00293
    00299   static void registerNewWorker(KResolverWorkerFactoryBase* factory);
    00300 };
    00301
    00307 template<class Worker>
    00308 class KResolverWorkerFactory: public KResolverWorkerFactoryBase
    00309 {
    00310 public:
    00311   virtual KResolverWorkerBase* create() const
    00312   { return new Worker; }
    00313 };
    00314
    00315 }               // namespace KNetwork
    00316
    00317 #endif

This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:18:10 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003