ModuleContext.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2006-2009 Savarese Software Research Corporation 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * https://www.savarese.com/software/ApacheLicense-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00021 #ifndef __SSRC_WSPR_WS_LUA_MODULE_CONTEXT_H 00022 #define __SSRC_WSPR_WS_LUA_MODULE_CONTEXT_H 00023 00024 #include <ssrc/wisp/protocol.h> 00025 #include <ssrc/wispers/ws/protocol.h> 00026 #include <ssrc/wispers/utility/ToString.h> 00027 00028 __BEGIN_NS_SSRC_WSPR_WS_LUA 00029 00030 using std::string; 00031 using ssrc::wisp::protocol::MessageInfo; 00032 using NS_SSRC_WSPR::sid_type; 00033 using NS_SSRC_WSPR_WS::WebServiceCall; 00034 using NS_SSRC_WSPR_UTILITY::ToString; 00035 00036 // We place the import here to trick SWIG into recognizing nested class. 00037 WISP_IMPORT(NS_SSRC_WSPR_WS::WebServiceProtocol, MessageResponse); 00038 00039 class ModuleContext { 00040 const WebServiceCall *_call; 00041 const MessageInfo *_msginfo; 00042 MessageResponse *_response; 00043 ToString _string_cast; 00044 const string _empty_string; 00045 const string _zero_string; 00046 00047 public: 00048 00049 ModuleContext() : 00050 _call(0), _msginfo(0), _response(0), _string_cast(), 00051 _empty_string(), _zero_string("0") 00052 { } 00053 00054 void start_call(const WebServiceCall *call, 00055 const MessageInfo *msginfo, 00056 MessageResponse *response) 00057 { 00058 _call = call; 00059 _msginfo = msginfo; 00060 _response = response; 00061 } 00062 00063 void end_call() { 00064 _call = 0; 00065 _msginfo = 0; 00066 _response = 0; 00067 } 00068 00069 void clear_session() { 00070 if(_response->session) 00071 _response->session.reset(); 00072 } 00073 00074 // Macro namespace qualification for return type is for SWIG. 00075 const NS_SSRC_WSPR_SESSION::session_ptr & session() { 00076 return _response->session; 00077 } 00078 00079 // Macro namespace qualification for return type is for SWIG. 00080 NS_SSRC_WSPR_WS_LUA::MessageResponse * response() { 00081 return _response; 00082 } 00083 00084 string call_name() const { return _call->call; } 00085 00086 string sender() const { return _msginfo->sender(); } 00087 }; 00088 00089 __END_NS_SSRC_WSPR_WS_LUA 00090 00091 #endif
Copyright © 2006-2011 Savarese Software Research Corporation. All rights reserved.