// -*- c++ -*-

/*
 *
 * Copyright (C) 2002 Richard Moore <rich@kde.org>
 * Copyright (C) 2002 George Staikos <staikos@kde.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef CHANNELIO_H
#define CHANNELIO_H

#include <qptrlist.h>
#include <qstring.h>

#include "channelioformat.h"

class ChannelStore;
class QtVision;

/**
 * Support for loading and saving channel suites in different formats.
 *
 * @author Richard Moore, <rich@kde.org>
 */
class ChannelIO
{
public:
    typedef ChannelIOFormat Format;
    typedef ChannelIOFormatList FormatList;

    /**
     * Get the meta info for a given channel file.
     */
    static ChannelFileMetaInfo getMetaInfo( QtVision *qtv, const QString& filename, const char *fmt = 0 );

    /**
     * Loads a channel file into the specified store. 
     */
    static bool load( QtVision *qtv, ChannelStore *store, const QString &filename, const char *fmt=0 );

    /**
     * Save the channels in the store to the specified file. 
     */
    static bool save( QtVision *qtv, ChannelStore *store, const QString &filename, const char *fmt=0 );

    /**
     * Registers the specified format.
     */
    static void registerFormat( QtVision *qtv, ChannelIOFormat *format );

    /**
     * Returns a list of all the known formats.
     */
    static ChannelIOFormatList *formats(QtVision *qtv);

    /**
     * Try to find a format handler for the specified format. The flags
     * indicate the facility we need, ie. reading or writing. If there
     * is no matching handler, 0 is returned.
     */
    static ChannelIOFormat *findFormat( QtVision *qtv, const char *fmt, int flags = ChannelIOFormat::FormatRead );

private:
    /**
     * Registers the built-in formats (happens automatically).
     */
    static void registerFormats(QtVision *qtv);

    static ChannelIOFormat* guessFormat( QtVision *qtv, const QString &filename, int flags );
};


#endif // CHANNELIO_H









