0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00
mongodb/db/module.cpp

69 lines
1.8 KiB
C++
Raw Normal View History

2009-11-18 18:53:56 +01:00
// module.cpp
/*
* Copyright (C) 2010 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2009-11-18 18:53:56 +01:00
2010-04-27 21:27:52 +02:00
#include "pch.h"
2009-11-18 18:53:56 +01:00
#include "module.h"
namespace mongo {
std::list<Module*> * Module::_all;
2009-11-18 18:53:56 +01:00
2009-11-25 16:14:08 +01:00
Module::Module( const string& name )
2009-11-18 18:53:56 +01:00
: _name( name ) , _options( (string)"Module " + name + " options" ){
if ( ! _all )
_all = new list<Module*>();
_all->push_back( this );
2009-11-18 18:53:56 +01:00
}
Module::~Module(){}
2009-11-25 16:14:08 +01:00
2009-11-18 18:53:56 +01:00
void Module::addOptions( program_options::options_description& options ){
2009-11-25 16:14:08 +01:00
if ( ! _all ) {
return;
}
for ( list<Module*>::iterator i=_all->begin(); i!=_all->end(); i++ ){
2009-11-18 18:53:56 +01:00
Module* m = *i;
options.add( m->_options );
}
}
void Module::configAll( program_options::variables_map& params ){
2009-11-25 16:14:08 +01:00
if ( ! _all ) {
return;
}
for ( list<Module*>::iterator i=_all->begin(); i!=_all->end(); i++ ){
2009-11-18 18:53:56 +01:00
Module* m = *i;
m->config( params );
}
}
void Module::initAll(){
2009-11-25 16:14:08 +01:00
if ( ! _all ) {
return;
}
for ( list<Module*>::iterator i=_all->begin(); i!=_all->end(); i++ ){
2009-11-18 18:53:56 +01:00
Module* m = *i;
m->init();
}
}
}