/** @file  pmConfig.h
 *
 *  @author PAP, IfA
 *
 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2005-10-20 23:06:24 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
 *
 */
#ifndef PM_CONFIG_H
#define PM_CONFIG_H

#include "pslib.h"



/** pmConfigRead
 * 
 * pmConfigRead shall load the site configuration (according to the above rule
 * for determining the source). The camera configuration shall also be loaded if
 * it is specified on the command line (argc, argv); otherwise it shall be set to
 * NULL. The recipe shall also be loaded from the command line (if specified) or,
 * if the camera configuration has been loaded, from the camera configuration and
 * recipe specification therein (see below). In dealing with the command line
 * parameters, the functions shall use the appropriate functions in psLib to
 * retrieve and remove the relevant options from the argument list; this
 * simplifies assignment of the mandatory arguments, since all the optional
 * command line arguments are removed leaving only the mandatory arguments. The
 * following psLib setups shall also be performed if they are specified in the
 * site configuration:
 *
 */
bool pmConfigRead(
    psMetadata **site,
    psMetadata **camera,
    psMetadata **recipe,
    int *argc,
    char **argv,
    const char *recipeName
);



/** pmConfigValidateCamera
 * 
 * This function, used by pmConfigCameraFromHeader, shall return true if the
 * FITS header matches the rule contained in the camera configuration (see
 * x2.2.2.3); otherwise it shall return false.
 * 
 */
bool pmConfigValidateCamera(
    const psMetadata *camera,
    const psMetadata *header
);



/** pmConfigCameraFromHeader
 * 
 * pmConfigCameraFromHeader shall load the camera configuration based on the
 * contents of the FITS header, using the list of known cameras contained in the
 * site configuration. If more than one camera matches the FITS header, a warning
 * shall be generated and the first matching camera returned.
 * 
 */
psMetadata *pmConfigCameraFromHeader(
    const psMetadata *site,
    const psMetadata *header
);



/** pmConfigRecipeFromCamera
 * 
 * pmConfigRecipeFromCamera shall load the recipe configuration based on the
 * recipeName and the list of known recipes contained in the camera 
 * configuration.
 * 
 */
psMetadata *pmConfigRecipeFromCamera(
    const psMetadata *camera,
    const char *recipeName
);

/** pmConfigDB
 * 
 * pmConfigDB shall use the site configuration data to open a database handle.
 * This is fairly straightforward at the moment, but will change when we beef up
 * security. (TBD)
 * 
 */
psDB *pmConfigDB(
    psMetadata *site
);


#endif
