• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • network
k3resolverworkerbase.h
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * Copyright (C) 2003-2005 Thiago Macieira <thiago@kde.org>
3  *
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef KRESOLVERWORKERBASE_H
26 #define KRESOLVERWORKERBASE_H
27 
28 #include "k3resolver.h"
29 
30 // forward declarations
31 class QString;
32 template <class T> class QValueList;
33 
34 namespace KNetwork {
35 
36  namespace Internal
37  {
38  class KResolverThread;
39  struct InputData;
40  }
41 
64 class KResolverWorkerBase
65 {
66 public:
67 
74  class ResolverLocker
75  {
76  public:
80  ResolverLocker(KResolverWorkerBase* parent)
81  : parent( parent )
82  {
83  parent->acquireResolver();
84  }
85 
89  ~ResolverLocker()
90  {
91  parent->releaseResolver();
92  }
93 
99  void openClose()
100  {
101  parent->releaseResolver();
102  parent->acquireResolver();
103  }
104 
105  private:
107  KResolverWorkerBase* parent;
108  };
109 private:
110  // this will be like our d pointer
111  KNetwork::Internal::KResolverThread *th;
112  const KNetwork::Internal::InputData *input;
113  friend class KNetwork::Internal::KResolverThread;
114  friend class KNetwork::Internal::KResolverManager;
115  friend class KResolverWorkerBase::ResolverLocker;
116 
117  int m_finished : 1;
118  int m_reserved : 31; // reserved
119 
120 public:
128  KResolverResults results;
129 
130 public:
131  // default constructor
132  KResolverWorkerBase();
133 
134  // virtual destructor
135  virtual ~KResolverWorkerBase();
136 
140  QString nodeName() const;
141 
145  QString serviceName() const;
146 
150  int flags() const;
151 
155  int familyMask() const;
156 
160  int socketType() const;
161 
165  int protocol() const;
166 
170  QByteArray protocolName() const;
171 
178  void finished();
179 
180 protected:
181  // like a QThread
194  virtual bool run() = 0;
195 
215  virtual bool preprocess() = 0;
216 
225  virtual bool postprocess();
226 
230  inline void setError(int errorcode, int syserror = 0)
231  { results.setError(errorcode, syserror); }
232 
248  bool enqueue(KResolver* other);
249 
253  bool enqueue(KResolverWorkerBase* worker);
254 
261  bool checkResolver();
262 
272  void acquireResolver();
273 
278  void releaseResolver();
279 
280 };
281 
291 class KResolverWorkerFactoryBase
292 {
293 public:
294  virtual ~KResolverWorkerFactoryBase() {}
295  virtual KResolverWorkerBase* create() const = 0;
301  static void registerNewWorker(KResolverWorkerFactoryBase* factory);
302 };
303 
313 template<class Worker>
314 class KResolverWorkerFactory: public KResolverWorkerFactoryBase
315 {
316 public:
317  virtual KResolverWorkerBase* create() const
318  { return new Worker; }
319 };
320 
321 } // namespace KNetwork
322 
323 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Mon Jul 15 2013 13:00:51 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs-4.10.5 API Reference

Skip menu "kdelibs-4.10.5 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal