Add infos into target window
[ryzomcore.git] / ryzom / server / src / general_utilities_service / gus_module.h
blob971b0fd8c04241d40aaf45064f40724fdc3108c4
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 GUS_MODULE_H
18 #define GUS_MODULE_H
20 //-----------------------------------------------------------------------------
21 // includes
22 //-----------------------------------------------------------------------------
24 #include "nel/misc/types_nl.h"
25 #include "nel/misc/sstring.h"
26 #include "nel/misc/smart_ptr.h"
27 #include "nel/net/unified_network.h"
29 #include "gus_net_types.h"
32 //-----------------------------------------------------------------------------
33 // GUS namespace
34 //-----------------------------------------------------------------------------
36 namespace GUS
38 //-----------------------------------------------------------------------------
39 // class IModule
40 //-----------------------------------------------------------------------------
42 class IModule: public NLMISC::CRefCount
44 public:
45 // Derived classes should only be instanciated by the registerModule() routine
46 // the IModule ctor asserts at run time if called outside the context of the
47 // registerModule() routine
48 IModule();
50 // virtual dtor
51 virtual ~IModule();
53 // init and release methods
54 virtual bool initialiseModule(const NLMISC::CSString& rawArgs)=0;
55 virtual void release() {}
57 // methods called at the service update and tick update
58 virtual void tickUpdate(NLMISC::TGameCycle tickNumber) {}
59 virtual void serviceUpdate(NLMISC::TTime localTime) {}
61 // methods called on reception of serviceUp/ serviceDown messages from the naming service
62 virtual void serviceUp(NLNET::TServiceId serviceId,const std::string& serviceName) {}
63 virtual void serviceDown(NLNET::TServiceId serviceId,const std::string& serviceName) {}
65 // methods called as new modules are registered accross the GUSNET network
66 virtual void moduleUp(GUSNET::CRemoteModuleViaConnection* remoteModule) {}
67 virtual void moduleDown(GUSNET::CRemoteModuleViaConnection* remoteModule) {}
69 // method called to service incoming messages
70 virtual void receiveModuleMessage(GUSNET::CModuleMessage& msg) {}
72 // method to retrieve & display the name, description and state of the module
73 virtual NLMISC::CSString getState() const=0;
74 virtual NLMISC::CSString getName() const=0;
75 virtual NLMISC::CSString getParameters() const=0;
76 virtual void displayModule() const=0;
78 typedef NLMISC::CSmartPtr<IModule> TModulePtr;
81 //-----------------------------------------------------------------------------
82 // utility Routines
83 //-----------------------------------------------------------------------------
85 // extract a named parameter from a string
86 // input string is formated as: abc(def) ghi(123) klm("this is it:(") nop(a(),b())
87 // - extractNamedParameter("abc",s) returns: def
88 // - extractNamedParameter("ghi",s) returns: 123
89 // - extractNamedParameter("klm",s) returns: "this is it:("
90 // - extractNamedParameter("nop",s) returns: a(),b()
91 NLMISC::CSString extractNamedParameter(const NLMISC::CSString& argName,NLMISC::CSString rawArgs);
93 // extract a named path parameter from a string
94 // this is a wrapper round extractNamedParameter which looks after stripping quotes and normalising the
95 // path as required - the result is a linux-style path
96 // - extractNamedPathParameter("path","name(toto) path("c:\\abcd\\def.ghi") returns: c:/abcd/def.ghi
97 NLMISC::CSString extractNamedPathParameter(const NLMISC::CSString& argName,NLMISC::CSString rawArgs);
100 //-----------------------------------------------------------------------------
101 #endif