Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / server / src / gameplay_module_lib / module_parent.cpp
blob17bf8d960d155bb629701d2245d0f9253d567dbb
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "module_core.h"
18 #include "module_parent.h"
19 #include "module.h"
21 //----------------------------------------------------------------------------
22 CModuleParent::~CModuleParent()
24 MODULE_INFO( "Module parent destruction : calling the Ondestruction handler for all modules" );
25 // as module could be removed from thi parent in IModule::onParentDestruction, we have do remove modules with this strange way
26 std::vector< NLMISC::CRefPtr<IModule> > modules = _Modules;
27 for (uint i = 0; i < modules.size(); i++ )
29 if ( modules[i] )
31 modules[i]->onParentDestruction();
36 //----------------------------------------------------------------------------
37 void CModuleParent::removeChildModule(IModule* module)
39 MODULE_INFO( "Module parent : simply removing a child module" );
40 MODULE_AST( module );
41 MODULE_AST(_Owner);
42 NLMISC::CRefPtr<IModule> ref(module);
43 std::vector< NLMISC::CRefPtr<IModule> >::iterator it( std::find( _Modules.begin(), _Modules.end(), ref ) );
44 if ( it == _Modules.end() )
46 nlwarning("<MODULE> cant find the module to remove");
47 return;
49 _Modules.erase(it);
52 //----------------------------------------------------------------------------
53 void CModuleParent::addChildModule(IModule* module)
55 MODULE_INFO( "Module parent : simply adding a child module" );
56 MODULE_AST( module );
57 #ifdef RY_MODULE_DEBUG
58 NLMISC::CRefPtr<IModule> ref(module);
59 std::vector< NLMISC::CRefPtr<IModule> >::iterator it( std::find( _Modules.begin(), _Modules.end(), ref ) );
60 if ( it != _Modules.end() )
61 nlerror("a module was added twice");
62 #endif
63 _Modules.push_back(module);