/*
 * Copyright (c) 1999 Johnny C. Lam.
 * All rights reserved.
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  The author makes no representations
 * about the suitability of this software for any purpose.  It is
 * provided "as is" without express or implied warranty.
 */

#include "path_strategy_factory.h"

#include "no_latents.h"
#include "no_latent_recomb_strategy.h"
#include "latent_recomb_strategy.h"

INITIALIZE_SINGLETON_BASE(PathStrategyFactory);

const PathStrategyFactory::choice_type
PathStrategyFactory::NO_LATENTS = "no_latents";

const PathStrategyFactory::choice_type
PathStrategyFactory::NO_LATENT_RECOMB = "no_latent_recomb";

const PathStrategyFactory::choice_type
PathStrategyFactory::LATENT_RECOMB = "latent_recomb";

auto_ptr<PathStrategy>
PathStrategyFactory::Make(choice_type path_strategy,
			  unsigned int max_latent_depth,
			  bool verbose) const
{
    if (path_strategy == NO_LATENTS) {
	return auto_ptr<PathStrategy>(
	    new NoLatentsPathStrategy(max_latent_depth, verbose));
    } else if (path_strategy == NO_LATENT_RECOMB) {
	return auto_ptr<PathStrategy>(
	    new NoLatentRecombStrategy(max_latent_depth, verbose));
    } else if (path_strategy == LATENT_RECOMB) {
	return auto_ptr<PathStrategy>(
	    new LatentRecombStrategy(max_latent_depth, verbose));
    } else {
	return auto_ptr<PathStrategy>(0);
    }
}
