Source Code (Use browser search to find items of interest.)

Class Index

kdat'TapeManager (./kdeadmin/kdat/TapeManager.h:43)

class TapeManager : public QObject {
    Q_OBJECT

    static TapeManager* _instance;

    QDict<Tape> _tapes;
    QStrList    _tapeIDs;
    Tape*       _mountedTape;
    
    TapeManager();
public:
    ~TapeManager();

    /**
     * All access to the TapeManager goes through this method.
     *
     * @return a pointer to the single instance of the TapeManager.
     */
    static TapeManager* instance();

    /**
     * Get the list of all known tape IDs.
     *
     * @return a QStrList containing the tape IDs.
     */
    const QStrList& getTapeIDs();

    /**
     * Retrieve the index for a tape.
     *
     * @param id the ID of the tape.
     * @return the tape's index.
     */
    Tape* findTape( const char* id );

    /**
     * Add a new tape index.
     *
     * @param tape a pointer to the new tape index.
     */
    void addTape( Tape* tape );

    /**
     * Remove a tape index.  The tape index is removed from memory and from
     * disk.  A signal is emitted before the tape is actually removed.
     *
     * @param tape a pointer to the tape index to remove.
     */
    void removeTape( Tape* tape );

    /**
     * Notify anyone who cares that the tape index has been modified.
     *
     * @param tape a pointer to the tape index that was modified.
     */
    void tapeModified( Tape* tape );

    /**
     * Call this method whenever a tape is first mounted.
     *
     * @param tape a pointer to the newly mounted tape's index.
     */
    void mountTape( Tape* tape );

    /**
     * Call this method whenever the current tape is about to be unmounted.
     */
    void unmountTape();

    /**
     * Get a handle on the currently mounted tape's index.
     *
     * @return a pointer to the mounted tape's index, or NULL if no tape is
     * mounted.
     */
    Tape* getMountedTape();
signals:
    /**
     * Emitted after a new tape index is created.
     *
     * @param tape a pointer to the new tape index.
     */
    void sigTapeAdded( Tape* tape );

    /**
     * Emitted before a tape index is destroyed.  This signal is emitted
     * immediately before the tape index is deleted.
     *
     * @param tape a pointer to the tape index that is about to be destroyed.
     */
    void sigTapeRemoved( Tape* tape );

    /**
     * Emitted after a tape index has been changed in some way.
     *
     * @param tape a pointer to the tape index that has been modified.
     */
    void sigTapeModified( Tape* tape );

    /**
     * Emitted after a tape has been mounted.
     */
    void sigTapeMounted();

    /**
     * Emitted just before the current tape is unmounted.
     */
    void sigTapeUnmounted();
};

kdat'TapeManager::TapeManager() (./kdeadmin/kdat/TapeManager.cpp:32)

TapeManager::TapeManager()
        : _mountedTape( 0 )
{
    _tapes.setAutoDelete( TRUE );

    // Get a list of all available tape indexes.
    QStringList relList;
    (void) KGlobal::dirs()->findAllResources( "appdata", ".*:[0-9]+", false, true, relList);
    
    for(QStringList::Iterator it = relList.begin();
        it != relList.end();
        it++)
    {
        QString fn = *it;
        // Convert to outdated QStrList :-)
        _tapeIDs.append( QFile::encodeName(fn) );
    }
}


kdat'TapeManager::~TapeManager() (./kdeadmin/kdat/TapeManager.cpp:51)

TapeManager::~TapeManager()
{
}


kdat'TapeManager::instance() (./kdeadmin/kdat/TapeManager.cpp:57)

TapeManager* TapeManager::instance()
{
    if ( _instance == 0 ) {
        _instance = new TapeManager();
    }

    return _instance;
}


kdat'TapeManager::getTapeIDs() (./kdeadmin/kdat/TapeManager.cpp:66)

const QStrList& TapeManager::getTapeIDs()
{
    return _tapeIDs;
}


kdat'TapeManager::findTape() (./kdeadmin/kdat/TapeManager.cpp:71)

Tape* TapeManager::findTape( const char* id )
{
    Tape* tape = _tapes[ id ];

    if ( !tape ) {
        tape = new Tape( id );
        _tapes.insert( tape->getID(), tape );
    }

    return tape;
}


kdat'TapeManager::addTape() (./kdeadmin/kdat/TapeManager.cpp:83)

void TapeManager::addTape( Tape* tape )
{
    Tape* old = _tapes[ tape->getID() ];
    if ( old ) {
        removeTape( old );
    }

    _tapeIDs.append( tape->getID() );
    _tapes.insert( tape->getID(), tape );

    emit sigTapeAdded( tape );
}


kdat'TapeManager::removeTape() (./kdeadmin/kdat/TapeManager.cpp:96)

void TapeManager::removeTape( Tape* tape )
{
    emit sigTapeRemoved( tape );

    // Remove the index file.
    QString filename = locateLocal( "appdata", tape->getID() );
    
    unlink( QFile::encodeName(filename) );

    _tapeIDs.remove( tape->getID() );
    _tapes.remove( tape->getID() );
}


kdat'TapeManager::tapeModified() (./kdeadmin/kdat/TapeManager.cpp:109)

void TapeManager::tapeModified( Tape* tape )
{
    emit sigTapeModified( tape );
}


kdat'TapeManager::mountTape() (./kdeadmin/kdat/TapeManager.cpp:114)

void TapeManager::mountTape( Tape* tape )
{
    _mountedTape = tape;
    emit sigTapeMounted();
}


kdat'TapeManager::unmountTape() (./kdeadmin/kdat/TapeManager.cpp:120)

void TapeManager::unmountTape()
{
    emit sigTapeUnmounted();
    _mountedTape = 0;
}


kdat'TapeManager::getMountedTape() (./kdeadmin/kdat/TapeManager.cpp:126)

Tape* TapeManager::getMountedTape()
{
    return _mountedTape;
}