@LICENCE@

#include "@EXTENSIONCLASSNAME@.h"

@IF_NO_SUFFIX@
@ELSE_IF_ONLY_ONE_SUFFIX@
@ELSE_IF_SEVERAL_SUFFIX@
#include <QFileInfo>
@END_IF_NO_SUFFIX@

// include generated components headers
@INCLUDECOMPONENTSHEADERS@

// for CAMITK_... log macros
#include <Log.h>

using namespace camitk;


// --------------- GetFileExtensions -------------------
QStringList @EXTENSIONCLASSNAME@::getFileExtensions() const { 
    QStringList ext;
    @EXTENSIONSDEF@
    
    return ext;
}

// --------------- Open -------------------
Component * @EXTENSIONCLASSNAME@::open(const QString & fileName) {
@IF_NO_SUFFIX@
   // Complete this function by creating a component responding to the fileName suffix.
   return nullptr;
@ELSE_IF_ONLY_ONE_SUFFIX@
    return new @TOPLEVELCOMPONENTCLASSNAME@(fileName);
@ELSE_IF_SEVERAL_SUFFIX@
    Component * component;
    QStringList ext;
    @EXTENSIONSDEF@
    
    // Get the fileName suffix
    QFileInfo fileInfo(fileName);
    QString suffix = fileInfo.suffix();
    
    // Open the right component according to the suffix
    switch (ext.indexOf(suffix))
    {
    @CASES@
    default:
        CAMITK_WARNING(tr("The file extension: \"%1\" is not handled by @EXTENSIONCLASSNAME@ extension.").arg(suffix))
        component = nullptr;
        break;
    }
    return component;
@END_IF_NO_SUFFIX@
}

// --------------- Save --------------------
bool @EXTENSIONCLASSNAME@::save(Component * component) const { 
    // depending on the components managed by @EXTENSIONCLASSNAME@, use
    // component->getPointSet() (for a MeshComponent derived class)
    // or component->getImageData() (for a ImageComponent derived class)
    // and save the data in the managed format in the file component->getFileName()

    return false;
}
