/*
 * 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 "segment_factory.h"

#include "longest_segment.h"
#include "independent_segment.h"

INITIALIZE_SINGLETON_BASE(SegmentProbabilityFactory);

const SegmentProbabilityFactory::choice_type
SegmentProbabilityFactory::LONGEST = "longest";

const SegmentProbabilityFactory::choice_type
SegmentProbabilityFactory::INDEPENDENT = "independent";

auto_ptr<SegmentProbability>
SegmentProbabilityFactory::Make(choice_type segment, bool verbose) const
{
    if (segment == LONGEST) {
	return auto_ptr<SegmentProbability>(
	    new LongestRunsProbability(verbose));
    } else if (segment == INDEPENDENT) {
	return auto_ptr<SegmentProbability>(
	    new IndependentProbability(verbose));
    } else {
	return auto_ptr<SegmentProbability>(0);
    }
}
