1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
19 /////////////////////////////////////////////////////////////////
20 // WARNING : this is a generated file, don't change it !
21 /////////////////////////////////////////////////////////////////
23 #ifndef RE_MODULE_ITF_H
24 #define RE_MODULE_ITF_H
25 #include "nel/net/message.h"
26 #include "nel/net/module.h"
27 #include "nel/net/module_message.h"
28 #include "nel/net/module_gateway.h"
29 #include "nel/misc/string_conversion.h"
31 #ifndef NLNET_INTERFACE_GET_MODULE
32 # define NLNET_INTERFACE_GET_MODULE NLNET::IModule *getModuleInstance() { return this; }
38 /////////////////////////////////////////////////////////////////
39 // WARNING : this is a generated file, don't change it !
40 /////////////////////////////////////////////////////////////////
41 class CRepositoryEmitterSkel
44 CRepositoryEmitterSkel()
46 // do early run time check for message table
49 virtual ~CRepositoryEmitterSkel()
56 typedef void (CRepositoryEmitterSkel::*TMessageHandler
)(NLNET::IModuleProxy
*sender
, const NLNET::CMessage
&message
);
57 typedef std::map
<std::string
, TMessageHandler
> TMessageHandlerMap
;
60 const TMessageHandlerMap
&getMessageHandlers() const
62 static TMessageHandlerMap handlers
;
63 static bool init
= false;
67 std::pair
< TMessageHandlerMap::iterator
, bool > res
;
69 res
= handlers
.insert(std::make_pair(std::string("RE_REQUEST"), &CRepositoryEmitterSkel::requestFile_skel
));
70 // if this assert, you have a doubly message name in your interface definition !
73 res
= handlers
.insert(std::make_pair(std::string("RE_DATA_ACK"), &CRepositoryEmitterSkel::fileDataAck_skel
));
74 // if this assert, you have a doubly message name in your interface definition !
77 res
= handlers
.insert(std::make_pair(std::string("RE_ERR_DUPMOD"), &CRepositoryEmitterSkel::duplicateModuleError_skel
));
78 // if this assert, you have a doubly message name in your interface definition !
88 bool onDispatchMessage(NLNET::IModuleProxy
*sender
, const NLNET::CMessage
&message
)
90 const TMessageHandlerMap
&mh
= getMessageHandlers();
92 TMessageHandlerMap::const_iterator
it(mh
.find(message
.getName()));
99 TMessageHandler cmd
= it
->second
;
100 (this->*cmd
)(sender
, message
);
107 void requestFile_skel(NLNET::IModuleProxy
*sender
, const NLNET::CMessage
&__message
)
109 std::string fileName
;
110 nlRead(__message
, serial
, fileName
);
111 requestFile(sender
, fileName
);
114 void fileDataAck_skel(NLNET::IModuleProxy
*sender
, const NLNET::CMessage
&__message
)
116 std::string fileName
;
117 nlRead(__message
, serial
, fileName
);
119 nlRead(__message
, serial
, status
);
120 fileDataAck(sender
, fileName
, status
);
123 void duplicateModuleError_skel(NLNET::IModuleProxy
*sender
, const NLNET::CMessage
&__message
)
125 duplicateModuleError(sender
);
129 /////////////////////////////////////////////////////////////////
130 // WARNING : this is a generated file, don't change it !
131 /////////////////////////////////////////////////////////////////
134 virtual void requestFile(NLNET::IModuleProxy
*sender
, const std::string
&fileName
) =0;
136 virtual void fileDataAck(NLNET::IModuleProxy
*sender
, const std::string
&fileName
, bool status
) =0;
138 virtual void duplicateModuleError(NLNET::IModuleProxy
*sender
) =0;
143 /////////////////////////////////////////////////////////////////
144 // WARNING : this is a generated file, don't change it !
145 /////////////////////////////////////////////////////////////////
146 class CRepositoryEmitterProxy
148 /// Smart pointer on the module proxy
149 NLNET::TModuleProxyPtr _ModuleProxy
;
151 // Pointer on the local module that implement the interface (if the proxy is for a local module)
152 NLNET::TModulePtr _LocalModule
;
153 // Direct pointer on the server implementation interface for collocated module
154 CRepositoryEmitterSkel
*_LocalModuleSkel
;
158 CRepositoryEmitterProxy(NLNET::IModuleProxy
*proxy
)
161 _ModuleProxy
= proxy
;
163 // initialize collocated servant interface
164 if (proxy
->getModuleDistance() == 0)
166 _LocalModule
= proxy
->getLocalModule();
167 nlassert(_LocalModule
!= NULL
);
168 _LocalModuleSkel
= dynamic_cast < CRepositoryEmitterSkel
* > (_LocalModule
.getPtr());
169 nlassert(_LocalModuleSkel
!= NULL
);
172 _LocalModuleSkel
= 0;
175 virtual ~CRepositoryEmitterProxy()
179 NLNET::IModuleProxy
*getModuleProxy()
185 void requestFile(NLNET::IModule
*sender
, const std::string
&fileName
)
187 if (_LocalModuleSkel
&& _LocalModule
->isImmediateDispatchingSupported())
189 // immediate local synchronous dispatching
190 _LocalModuleSkel
->requestFile(_ModuleProxy
->getModuleGateway()->getPluggedModuleProxy(sender
), fileName
);
194 // send the message for remote dispatching and execution or local queing
195 NLNET::CMessage __message
;
197 buildMessageFor_requestFile(__message
, fileName
);
199 _ModuleProxy
->sendModuleMessage(sender
, __message
);
203 void fileDataAck(NLNET::IModule
*sender
, const std::string
&fileName
, bool status
)
205 if (_LocalModuleSkel
&& _LocalModule
->isImmediateDispatchingSupported())
207 // immediate local synchronous dispatching
208 _LocalModuleSkel
->fileDataAck(_ModuleProxy
->getModuleGateway()->getPluggedModuleProxy(sender
), fileName
, status
);
212 // send the message for remote dispatching and execution or local queing
213 NLNET::CMessage __message
;
215 buildMessageFor_fileDataAck(__message
, fileName
, status
);
217 _ModuleProxy
->sendModuleMessage(sender
, __message
);
221 void duplicateModuleError(NLNET::IModule
*sender
)
223 if (_LocalModuleSkel
&& _LocalModule
->isImmediateDispatchingSupported())
225 // immediate local synchronous dispatching
226 _LocalModuleSkel
->duplicateModuleError(_ModuleProxy
->getModuleGateway()->getPluggedModuleProxy(sender
));
230 // send the message for remote dispatching and execution or local queing
231 NLNET::CMessage __message
;
233 buildMessageFor_duplicateModuleError(__message
);
235 _ModuleProxy
->sendModuleMessage(sender
, __message
);
239 // Message serializer. Return the message received in reference for easier integration
240 static const NLNET::CMessage
&buildMessageFor_requestFile(NLNET::CMessage
&__message
, const std::string
&fileName
)
242 __message
.setType("RE_REQUEST");
243 nlWrite(__message
, serial
, const_cast < std::string
& > (fileName
));
249 // Message serializer. Return the message received in reference for easier integration
250 static const NLNET::CMessage
&buildMessageFor_fileDataAck(NLNET::CMessage
&__message
, const std::string
&fileName
, bool status
)
252 __message
.setType("RE_DATA_ACK");
253 nlWrite(__message
, serial
, const_cast < std::string
& > (fileName
));
254 nlWrite(__message
, serial
, status
);
260 // Message serializer. Return the message received in reference for easier integration
261 static const NLNET::CMessage
&buildMessageFor_duplicateModuleError(NLNET::CMessage
&__message
)
263 __message
.setType("RE_ERR_DUPMOD");