• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

scheduler.h

00001 // -*- c++ -*-
00002 /* This file is part of the KDE libraries
00003     Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
00004                        Waldo Bastian <bastian@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef _tdeio_scheduler_h
00023 #define _tdeio_scheduler_h
00024 
00025 #include "tdeio/job.h"
00026 #include "tdeio/jobclasses.h"
00027 #include <tqtimer.h>
00028 #include <tqptrdict.h>
00029 #include <tqmap.h>
00030 
00031 #include <dcopobject.h>
00032 
00033 namespace TDEIO {
00034 
00035     class Slave;
00036     class SlaveList;
00037     class SlaveConfig;
00038     class SessionData;
00039 
00111     class TDEIO_EXPORT Scheduler : public TQObject, virtual public DCOPObject {
00112         Q_OBJECT
00113 
00114     public:
00115         typedef TQPtrList<SimpleJob> JobList;
00116 
00117         // InfoDict needs Info, so we can't declare it private
00118         class ProtocolInfo;
00119         class JobData;
00120 
00121         ~Scheduler();
00122 
00129         static void doJob(SimpleJob *job)
00130         { self()->_doJob(job); }
00131 
00138         static void scheduleJob(SimpleJob *job)
00139         { self()->_scheduleJob(job); }
00140 
00145         static void cancelJob(SimpleJob *job)
00146         { self()->_cancelJob(job); }
00147 
00153         static void jobFinished(TDEIO::SimpleJob *job, TDEIO::Slave *slave)
00154         { self()->_jobFinished(job, slave); }
00155 
00167         static void putSlaveOnHold(TDEIO::SimpleJob *job, const KURL &url)
00168         { self()->_putSlaveOnHold(job, url); }
00169 
00174         static void removeSlaveOnHold()
00175         { self()->_removeSlaveOnHold(); }
00176 
00182         static void publishSlaveOnHold()
00183         { self()->_publishSlaveOnHold(); }
00184 
00196         static TDEIO::Slave *getConnectedSlave(const KURL &url, const TDEIO::MetaData &config = MetaData() )
00197         { return self()->_getConnectedSlave(url, config); }
00198 
00199         /*
00200          * Uses @p slave to do @p job.
00201          * This function should be called immediately after creating a Job.
00202          *
00203          * @param slave The slave to use. The slave must have been obtained
00204          *              with a call to getConnectedSlave and must not
00205          *              be currently assigned to any other job.
00206          * @param job The job to do.
00207          *
00208          * @return true is successful, false otherwise.
00209          *
00210          * @see getConnectedSlave()
00211          * @see disconnectSlave()
00212          * @see slaveConnected()
00213          * @see slaveError()
00214          */
00215         static bool assignJobToSlave(TDEIO::Slave *slave, TDEIO::SimpleJob *job)
00216         { return self()->_assignJobToSlave(slave, job); }
00217 
00218         /*
00219          * Disconnects @p slave.
00220          *
00221          * @param slave The slave to disconnect. The slave must have been
00222          *              obtained with a call to getConnectedSlave
00223          *              and must not be assigned to any job.
00224          *
00225          * @return true is successful, false otherwise.
00226          *
00227          * @see getConnectedSlave
00228          * @see assignJobToSlave
00229          */
00230         static bool disconnectSlave(TDEIO::Slave *slave)
00231         { return self()->_disconnectSlave(slave); }
00232 
00243         static void registerWindow(TQWidget *wid)
00244         { self()->_registerWindow(wid); }
00245         
00250         static void unregisterWindow(TQObject *wid)
00251         { self()->slotUnregisterWindow(wid); }
00252 
00259         static bool connect( const char *signal, const TQObject *receiver,
00260                              const char *member)
00261         { return TQObject::connect(self(), signal, receiver, member); }
00262 
00263         static bool connect( const TQObject* sender, const char* signal,
00264                              const TQObject* receiver, const char* member )
00265         { return TQObject::connect(sender, signal, receiver, member); }
00266 
00267         static bool disconnect( const TQObject* sender, const char* signal,
00268                                 const TQObject* receiver, const char* member )
00269         { return TQObject::disconnect(sender, signal, receiver, member); }
00270 
00271         bool connect( const TQObject *sender, const char *signal,
00272                       const char *member )
00273         { return TQObject::connect(sender, signal, member); }
00274 
00280         static void checkSlaveOnHold(bool b) { self()->_checkSlaveOnHold(b); }
00281 
00282         void debug_info();
00283 
00284         virtual bool process(const TQCString &fun, const TQByteArray &data,
00285                              TQCString& replyType, TQByteArray &replyData);
00286 
00287         virtual QCStringList functions();
00288 
00289     public slots:
00290         void slotSlaveDied(TDEIO::Slave *slave);
00291         void slotSlaveStatus(pid_t pid, const TQCString &protocol,
00292                              const TQString &host, bool connected);
00293     signals:
00294         void slaveConnected(TDEIO::Slave *slave);
00295         void slaveError(TDEIO::Slave *slave, int error, const TQString &errorMsg);
00296 
00297     protected:
00298         void setupSlave(TDEIO::Slave *slave, const KURL &url, const TQString &protocol, const TQString &proxy , bool newSlave, const TDEIO::MetaData *config=0);
00299         bool startJobScheduled(ProtocolInfo *protInfo);
00300         bool startJobDirect();
00301         Scheduler();
00302 
00303     protected slots:
00304         void startStep();
00305         void slotCleanIdleSlaves();
00306         void slotSlaveConnected();
00307         void slotSlaveError(int error, const TQString &errorMsg);
00308         void slotScheduleCoSlave();
00310         void slotUnregisterWindow(TQObject *);
00311 
00312     private:
00313         class ProtocolInfoDict;
00314         class ExtraJobData;
00315 
00316         Scheduler(const Scheduler&);
00317         static Scheduler *self();
00318         static Scheduler *instance;
00319         void _doJob(SimpleJob *job);
00320         void _scheduleJob(SimpleJob *job);
00321         void _cancelJob(SimpleJob *job);
00322         void _jobFinished(TDEIO::SimpleJob *job, TDEIO::Slave *slave);
00323         void _scheduleCleanup();
00324         void _putSlaveOnHold(TDEIO::SimpleJob *job, const KURL &url);
00325         void _removeSlaveOnHold();
00326         Slave *_getConnectedSlave(const KURL &url, const TDEIO::MetaData &metaData );
00327         bool _assignJobToSlave(TDEIO::Slave *slave, TDEIO::SimpleJob *job);
00328         bool _disconnectSlave(TDEIO::Slave *slave);
00329         void _checkSlaveOnHold(bool b);
00330         void _publishSlaveOnHold();
00331         void _registerWindow(TQWidget *wid);
00332         
00333         Slave *findIdleSlave(ProtocolInfo *protInfo, SimpleJob *job, bool &exact);
00334         Slave *createSlave(ProtocolInfo *protInfo, SimpleJob *job, const KURL &url);
00335         
00336 
00337         TQTimer slaveTimer;
00338         TQTimer coSlaveTimer;
00339         TQTimer cleanupTimer;
00340         bool busy;
00341 
00342         SlaveList *slaveList;
00343         SlaveList *idleSlaves;
00344         SlaveList *coIdleSlaves;
00345 
00346         ProtocolInfoDict *protInfoDict;
00347         Slave *slaveOnHold;
00348         KURL urlOnHold;
00349         JobList newJobs;
00350 
00351         TQPtrDict<JobList> coSlaves;
00352         ExtraJobData *extraJobData;
00353         SlaveConfig *slaveConfig;
00354         SessionData *sessionData;
00355         bool checkOnHold;
00356         TQMap<TQObject *,WId> m_windowList;
00357     protected:
00358     virtual void virtual_hook( int id, void* data );
00359     private:
00360     class SchedulerPrivate* d;
00361 };
00362 
00363 }
00364 #endif

tdeio/tdeio

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

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.7.1
This website is maintained by Timothy Pearson.