Add infos into target window
[ryzomcore.git] / ryzom / server / src / gameplay_module_lib / module.h
blobd5acb482d4aa21de6e65cfd101bee26eadfcc322
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 #ifndef RY_MODULE_H
18 #define RY_MODULE_H
20 #include "nel/misc/types_nl.h"
21 #include "nel/misc/smart_ptr.h"
22 #include "module_utils.h"
23 #include "module_parent.h"
25 class IModuleCore;
27 /**
28 * A gameplay module. Implements the actions done by an element of a system ( e.g. : a player ) on an element of another system ( e.g. : a guild )
29 * A module is responsible of cleaning himself.
30 * \author Nicolas Brigand
31 * \author Nevrax France
32 * \date 2004
34 class IModule : public NLMISC::CRefCount
36 public:
37 /// ctor. Is in charge of registering the module on the parent and referenced core
38 IModule( CModuleParent* parent, IModuleCore* referencedCore);
39 virtual ~IModule(){}
40 /// callback called when parent is deleted. It calls the onParentDestructionHandler virtual method
41 void onParentDestruction();
42 /// reference is destroyed. It destroys this module and remove it from parent
43 void onReferencedDestruction();
44 /// retrieve a "proxy" on the parent owner ( e.g. : the player )
45 template <class T>
46 void getProxy(T & proxy)const
48 MODULE_AST( _Parent );
49 MODULE_AST( _Parent->getOwner() );
50 // build the proxy on the fly : it only contains a pointer
51 proxy = T(_Parent->getOwner());
54 protected:
55 /// pointer on the container containing this module
56 NLMISC::CRefPtr<CModuleParent> _Parent;
57 /// virtual handler that you have to implement in your module.
58 /// e.g. :in case of a pet module, destroy the pet.
59 /// e. g. : in case of a guild call CGuild::removeReferencingModule(this);
60 virtual void onParentDestructionHandler() = 0;
63 //#include "module_parent.h"
64 //#include "module_core.h"
65 //#include "module_inline.h"
67 #endif // RY_MODULE_H
69 /* End of module.h */