/** \file
 *
 *  Contains the BehaviorRegistry class implementation.
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 */

#include "BehaviorRegistry.h"

/// The map of MissionComponentRegistryEntries
BehaviorRegistryMap* BehaviorRegistry::Map_;

/// Initializes the map.
void BehaviorRegistry::Initialize()
{
    Map_ = new BehaviorRegistryMap();
}

/// Uninitializes the map.
void BehaviorRegistry::Uninitialize()
{
    while( Map_->size() > 0 )
    {
        delete Map_->popIndexed( Map_->size() - 1 );
    }
    delete Map_;
}

/// Add the base name and BehaviorCreator to the map.
void BehaviorRegistry::Insert( const Str& baseName,
                               BehaviorCreator behaviorCreator,
                               const Module* module )
{
    Map_->put( baseName,
               new BehaviorRegistryEntry( behaviorCreator, module ) );
}

/// Add the base name and BehaviorCreator to the map.
BehaviorRegistryEntry* BehaviorRegistry::Find( const Str& baseName )
{
    return Map_->get( baseName );
}
