/*
 *    DBNFile.java
 *    Copyright (C) 2012-2013 Aristotle University of Thessaloniki, Greece
 */
package dbn.data;

import dbn.classifier.neural.DeepBeliefNetwork;
import com.syvys.jaRBM.IO.RBMNetFile;

/**
 * A file handler for {@link DeepBeliefNetwork} instances. It has some <code>static</code>
 * methods that help to save or load a {@link DeepBeliefNetwork} in an appropriate
 * file. Extends {@link RBMNetFile} class.
 * 
 * @see RBMNetFile
 * @see DeepBeliefNetwork
 * @author Evripidis Gkanias
 */
public class DBNFile extends RBMNetFile {
    private static final String DEFAULT_LOCATION = "DATA/mydbn.dbn";
    
    /**
     * Loads a {@link DeepBeliefNetwork} from the hard disk using the path parameter
     * 
     * @param filename the path to the file that contains all the information 
     * that the method needs to load the {@link DeepBeliefNetwork}
     * @return the saved {@link DeepBeliefNetwork}
     * @throws InvalidClassException
     */
    public static DeepBeliefNetwork GetFromFile(String filename) {
        return (DeepBeliefNetwork) RBMNetFile.GetFromFile(filename);
    }
    
    /**
     * Saves a {@link DeepBeliefNetwork} into a default location. You can load
     * this file using the <code>GetFromFile(String filename)</code> method.
     * 
     * @param someDBN the {@link DeepBeliefNetwork} object that you want to save
     */
    public static void SaveToFile(DeepBeliefNetwork someDBN) {
        SaveToFile(someDBN, DEFAULT_LOCATION);
    }
    
    /**
     * Saves a {@link DeepBeliefNetwork} into a location defined by the user.
     * You can load this file using the <code>GetFromFile(String filename)</code>
     * method.
     * 
     * @param someDBN the {@link DeepBeliefNetwork} object that you want to save
     * @param anotherfilename the location of the file you want to save the 
     * {@link DeepBeliefNetwork}
     */
    public static void SaveToFile(DeepBeliefNetwork someDBN, String anotherfilename) {
        RBMNetFile.SaveToFile(someDBN, anotherfilename);
    }
}
