Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

HandlerLoader.h

00001 /* -*- C++ -*- */
00002 /*
00003  *   Copyright 2003-2004 The Apache Software Foundation.
00004  *
00005  *   Licensed under the Apache License, Version 2.0 (the "License");
00006  *   you may not use this file except in compliance with the License.
00007  *   You may obtain a copy of the License at
00008  *
00009  *       http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  *   Unless required by applicable law or agreed to in writing, software
00012  *   distributed under the License is distributed on an "AS IS" BASIS,
00013  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *   See the License for the specific language governing permissions and
00015  *   limitations under the License.
00016  *
00017  */
00018 
00019 #if !defined(__HANDLERLOADER_H_INCLUDED__)
00020 #define __HANDLERLOADER_H_INCLUDED__
00021 
00022 #include <axis/server/MessageData.h>
00023 #include <axis/server/GDefine.h>
00024 #include <axis/server/WrapperClassHandler.h>
00025 #include "SharedObject.h"
00026 
00027 #include <map>
00028 #include <string>
00029 
00030 using namespace std;
00031 
00032 #define CREATE_FUNCTION "GetClassInstance"
00033 #define DELETE_FUNCTION "DestroyInstance"
00034 
00035 typedef int (* CREATE_OBJECT) (BasicHandler** inst);
00036 typedef int (* DELETE_OBJECT) (BasicHandler* inst);
00037 
00038 #if defined(USE_LTDL)
00039 #include <ltdl.h>
00040 #define DLHandler lt_dlhandle
00041 #elif defined(WIN32)
00042 #include <windows.h>
00043 #define DLHandler HINSTANCE
00044 #define RTLD_LAZY 0
00045 #else //Linux
00046 #include <dlfcn.h>
00047 #define DLHandler void*
00048 #endif
00049 
00050 //status codes
00051 #define HANDLER_INIT_FAIL       1
00052 #define CREATION_FAILED         2
00053 #define LOADLIBRARY_FAILED      3
00054 #define LIBRARY_PATH_EMPTY      4
00055 #define HANDLER_NOT_LOADED      5
00056 #define HANDLER_BEING_USED      6
00057 #define GET_HANDLER_FAILED      7
00058 #define WRONG_HANDLER_TYPE      8
00059 #define NO_HANDLERS_CONFIGURED  9
00060 /*
00061  *   @class HandlerLoader
00062  *   @brief
00063  *
00064  *
00065  *
00066  *   @author Susantha Kumara (skumara@virtusa.com)
00067  */
00068 
00069 class HandlerLoader:protected SharedObject
00070 {
00071     private:
00072         class HandlerInformation
00073         {
00074             public:
00075                 string m_sLib;
00076                 int m_nLoadOptions;
00077                 DLHandler m_Handler;
00078                 CREATE_OBJECT m_Create;
00079                 DELETE_OBJECT m_Delete;
00080                 int m_nObjCount;
00081             public:
00082                 HandlerInformation ()
00083                 {
00084                     m_sLib = "";
00085                     m_nObjCount = 0;
00086                 }
00087             };
00088 
00089             map <int, HandlerInformation*>m_HandlerInfoList;
00090 
00091     public:
00092         int CreateHandler (BasicHandler** pHandler, int nLibId);
00093         int DeleteHandler (BasicHandler* pHandler, int nLibId);
00094         HandlerLoader ();
00095         ~HandlerLoader ();
00096     private:
00097         int LoadLib (HandlerInformation* pHandlerInfo);
00098         int UnloadLib (HandlerInformation* pHandlerInfo);
00099 };
00100 
00101 
00102 #endif 

Generated on Fri Apr 9 12:21:29 2004 for axiscpp by doxygen1.2.18