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

#ifndef BEHAVIORREGISTRY_H_
#define BEHAVIORREGISTRY_H_

#include "utils/FastMap.h"
#include "utils/Str.h"

#include "component/Behavior.h"

struct BehaviorRegistryEntry
{
    BehaviorCreator behaviorCreator_;
    const Module* module_;
    BehaviorRegistryEntry( BehaviorCreator behaviorCreator,
                           const Module* module )
        : behaviorCreator_( behaviorCreator ),
          module_( module )
    {};
};

typedef FastMap<const Str, BehaviorRegistryEntry*> BehaviorRegistryMap;

/**
*  Keeps track of all MissionComponents that could be created and loaded.
*
*  \ingroup supervisor
*/
class BehaviorRegistry
{
public:

    /// Initializes the map.
    static void Initialize( );

    /// Uninitializes the map.
    static void Uninitialize();

    /// Add the base name and BehaviorCreator to the map.
    static void Insert( const Str& baseName,
                        BehaviorCreator behaviorCreator,
                        const Module* module );

    /// Get the BehaviorCreator from the map.
    static BehaviorRegistryEntry* Find( const Str& baseName );

private:

    /// Private Constructor for static class.
    BehaviorRegistry()
    {};

    /// The map of MissionComponentRegistryEntries
    static BehaviorRegistryMap* Map_;

};


#endif /*BLOCKMAP_H_*/
