#include "Module.h"

#include "User_interface.h"

//#include <vector>
#include "Array.h"

namespace
{
//std::vector <MM::Module*> & 
MM::Array <MM::Module *> & 
module_list ()
{
    static MM::Array <MM::Module*> singleton;
    return singleton;
}

void register_module (MM::Module &module)
{
    module_list().push_back (&module);
}
}//namespace

namespace MM
{

Module::
Module (Text const & name)
:
    name_(name)
{
    register_module (*this);
}

void Module::
init_all ()
{
    for (int i=0;  i<module_list().size();  ++i)
        module_list()[i]->init();
}

Module_void_handle Module::
adopt_command (Command * cmd)
{
    return Module_void_handle (*this, cmd);
}

Module_bool_handle Module::
adopt_command (Command_1 <bool> * cmd)
{
    return Module_bool_handle (*this, cmd);
}

void Module::
insert_menu_separator (Text const& menu)
{
    User_interface::insert_menu_separator (menu);
}

}//MM


