home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ksycocaentry.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.3 KB  |  124 lines

  1. /*  This file is part of the KDE libraries
  2.  *  Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
  3.  *
  4.  *  This library is free software; you can redistribute it and/or
  5.  *  modify it under the terms of the GNU Library General Public
  6.  *  License version 2 as published by the Free Software Foundation;
  7.  *
  8.  *  This library is distributed in the hope that it will be useful,
  9.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.  *  Library General Public License for more details.
  12.  *
  13.  *  You should have received a copy of the GNU Library General Public License
  14.  *  along with this library; see the file COPYING.LIB.  If not, write to
  15.  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.  *  Boston, MA 02110-1301, USA.
  17.  **/
  18.  
  19. #ifndef __ksycocaentry_h__
  20. #define __ksycocaentry_h__
  21.  
  22. #include "ksycocatype.h"
  23.  
  24. #include <qstringlist.h>
  25. #include <ksharedptr.h>
  26. class QDataStream;
  27.  
  28. /**
  29.  * Base class for all Sycoca entries.
  30.  * 
  31.  * You can't create an instance of KSycocaEntry, but it provides
  32.  * the common functionality for servicetypes and services.
  33.  * 
  34.  * @internal
  35.  * @see http://developer.kde.org/documentation/library/kdeqt/kde3arch/ksycoca.html 
  36.  */
  37. class KDECORE_EXPORT KSycocaEntry : public KShared
  38. {
  39.  
  40. public:
  41.    virtual bool isType(KSycocaType t) const { return (t == KST_KSycocaEntry); }
  42.    virtual KSycocaType sycocaType() const { return KST_KSycocaEntry; }
  43.  
  44. public:
  45.   typedef KSharedPtr<KSycocaEntry> Ptr;
  46.   typedef QValueList<Ptr> List;
  47. public: // KDoc seems to barf on those typedefs and generates no docs after them
  48.    /**
  49.     * Default constructor
  50.     */
  51.    KSycocaEntry(const QString &path) : mOffset(0), m_bDeleted(false), mPath(path) { }
  52.  
  53.    /**
  54.     * Safe demarshalling functions.
  55.     */
  56.    static void read( QDataStream &s, QString &str );
  57.    static void read( QDataStream &s, QStringList &list );
  58.  
  59.    /**
  60.     * @internal
  61.     * Restores itself from a stream.
  62.     */
  63.    KSycocaEntry( QDataStream &_str, int offset ) : 
  64.               mOffset( offset ), m_bDeleted(false) 
  65.    { 
  66.      read(_str, mPath);
  67.    }
  68.  
  69.    /**
  70.     * @return the name of this entry
  71.     */
  72.    virtual QString name() const = 0;
  73.  
  74.    /**
  75.     * @return the path of this entry 
  76.     * The path can be absolute or relative.
  77.     * The corresponding factory should know relative to what.
  78.     */
  79.    QString entryPath() const { return mPath; }
  80.   
  81.    /**
  82.     * @return true if valid
  83.     */
  84.    virtual bool isValid() const = 0;
  85.   
  86.    /**
  87.     * @return true if deleted
  88.     */
  89.    virtual bool isDeleted() const { return m_bDeleted; }
  90.  
  91.    /**
  92.     * @internal
  93.     * @return the position of the entry in the sycoca file
  94.     */
  95.    int offset() { return mOffset; }
  96.  
  97.    /**
  98.     * @internal
  99.     * Save ourselves to the database. Don't forget to call the parent class
  100.     * first if you override this function.
  101.     */
  102.    virtual void save(QDataStream &s)
  103.      {
  104.        mOffset = s.device()->at(); // store position in member variable
  105.        s << (Q_INT32) sycocaType() << mPath;
  106.      }
  107.  
  108.    /**
  109.     * @internal
  110.     * Load ourselves from the database. Don't call the parent class!
  111.     */
  112.    virtual void load(QDataStream &) = 0;
  113.  
  114. private:
  115.    int mOffset;
  116. protected:
  117.    bool m_bDeleted;
  118.    QString mPath;   
  119. protected:
  120.    virtual void virtual_hook( int id, void* data );
  121. };
  122.  
  123. #endif
  124.