• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

k3resolverworkerbase.h

Go to the documentation of this file.
00001 /*  -*- C++ -*-
00002  *  Copyright (C) 2003-2005 Thiago Macieira <thiago@kde.org>
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 "k3resolver.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 
00070   class ResolverLocker
00071   {
00072   public:
00076     ResolverLocker(KResolverWorkerBase* parent)
00077       : parent( parent ) 
00078     {
00079       parent->acquireResolver();
00080     }
00081 
00085     ~ResolverLocker() 
00086     {
00087       parent->releaseResolver();
00088     }
00089 
00095     void openClose() 
00096     {
00097       parent->releaseResolver();
00098       parent->acquireResolver();
00099     }
00100 
00101   private:
00103     KResolverWorkerBase* parent;
00104   };
00105 private:
00106   // this will be like our d pointer
00107   KNetwork::Internal::KResolverThread *th;
00108   const KNetwork::Internal::InputData *input;
00109   friend class KNetwork::Internal::KResolverThread;
00110   friend class KNetwork::Internal::KResolverManager;
00111   friend class KResolverWorkerBase::ResolverLocker;
00112 
00113   int m_finished : 1;
00114   int m_reserved : 31;      // reserved
00115 
00116 public:
00124   KResolverResults results;
00125 
00126 public:
00127   // default constructor
00128   KResolverWorkerBase();
00129 
00130   // virtual destructor
00131   virtual ~KResolverWorkerBase();
00132 
00136   QString nodeName() const;
00137 
00141   QString serviceName() const;
00142 
00146   int flags() const;
00147 
00151   int familyMask() const;
00152 
00156   int socketType() const;
00157 
00161   int protocol() const;
00162 
00166   QByteArray protocolName() const;
00167 
00174   void finished();
00175 
00176 protected:
00177   // like a QThread
00190   virtual bool run() = 0;
00191 
00211   virtual bool preprocess() = 0;
00212 
00221   virtual bool postprocess();
00222 
00226   inline void setError(int errorcode, int syserror = 0)
00227   { results.setError(errorcode, syserror); }
00228 
00244   bool enqueue(KResolver* other);
00245 
00249   bool enqueue(KResolverWorkerBase* worker);
00250 
00257   bool checkResolver();
00258 
00268   void acquireResolver();
00269 
00274   void releaseResolver();
00275 
00276 };
00277 
00283 class KResolverWorkerFactoryBase
00284 {
00285 public:
00286   virtual ~KResolverWorkerFactoryBase() {}
00287   virtual KResolverWorkerBase* create() const = 0;
00293   static void registerNewWorker(KResolverWorkerFactoryBase* factory);
00294 };
00295 
00301 template<class Worker>
00302 class KResolverWorkerFactory: public KResolverWorkerFactoryBase
00303 {
00304 public:
00305   virtual KResolverWorkerBase* create() const
00306   { return new Worker; }
00307 };
00308 
00309 }               // namespace KNetwork
00310 
00311 #endif

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal