00001 00011 // SOAPDispatcher.h: interface for the SOAPDispatcher class. 00012 // 00013 // $Log: SOAPDispatcher.h,v $ 00014 // Revision 1.1 2005/03/22 22:22:14 gjpc 00015 // This is the intial check in of the Simple SOAP library. 00016 // 00017 // The code compiles and executes under MSVC .NET and GNU 3.3 00018 // 00019 // It has been run under Debian, SUSE, CYGWIN and WinXP 00020 // 00021 // Revision 1.2 2004/04/23 16:59:26 gjpc 00022 // expanded the Simple SOAP package to allow RPC's within RPC's 00023 // 00024 // 00026 /* 00027 #if !defined(SOAPDISPATCHER_H) 00028 #include "SOAPDispatcher.h" 00029 #endif // !defined(SOAPDISPATCHER_H) 00030 */ 00031 #if !defined(SOAPDISPATCHER_H) 00032 #define SOAPDISPATCHER_H 00033 00034 #if _MSC_VER > 1000 00035 #pragma once 00036 #endif // _MSC_VER > 1000 00037 00038 #ifndef _STRING_ 00039 #include <string> 00040 #endif // _STRING_ 00041 #if !defined(SOAPELEMENT_H) 00042 #include "SOAPElement.h" 00043 #endif // !defined(SOAPELEMENT_H) 00044 #ifndef _MAP_ 00045 #include <map> 00046 #endif // _MAP_ 00047 #ifndef SINGLETON_H 00048 #include "singleton.h" 00049 #endif //SINGLETON_H 00050 #ifndef _MEMORY_ 00051 #include <memory> 00052 #endif // _MEMORY_ 00053 #if !defined(SOAPOBJECTCREATOR_H) 00054 #include "SOAPObjectCreator.h" 00055 #endif // !defined(SOAPOBJECTCREATOR_H) 00056 00057 #include "SOAPObject.h" 00058 00059 class SOAPDispatcher : private Singleton< SOAPDispatcher > 00060 { 00061 public: 00062 // Instance 00063 // Description: 00064 // Returns the single instance of this object within the 00065 // program. 00066 // Arugments: 00067 // N/A 00068 // Return Value: 00069 // Reference to the SOAPDispatcher instance. 00070 static SOAPDispatcher& Instance(); 00071 00072 // processMessage 00073 // Description: 00074 // Given a SOAPElement, object name, and method name, this calls 00075 // the appropriate SOAPMethod on the appropriate SOAPObject. 00076 // If this fails, ask for a SOAPFault. 00077 // Arugments: 00078 // KszObjectName: Name of the SOAPObject 00079 // (SOAPObjectCreator.createdObjectName()). 00080 // KszMethodName: Name of the SOAPMethod 00081 // (SOAPMethod.methodName()). 00082 // theCall: Pre-parsed message. 00083 // bContainsFault: Indicates if the returned string 00084 // contains a fault. 00085 // Return Value: 00086 // Returns a SOAP. send-ready response. 00087 std::string processMessage( const std::string& KszObjectName, 00088 const std::string& KszMethodName, 00089 SOAPElement& theCall, 00090 bool& bContainsFault ); 00091 00092 // registerObject 00093 // Description: 00094 // Adds an object creator to the list of objects the dispatcher 00095 // can call. 00096 // Arugments: 00097 // pCreator: Pointer to an allocated SOAPObjectCreator. The 00098 // object assumes ownership of the object and will destroy 00099 // it at program termination. 00100 // Return Value: 00101 // true: Object successfully registered. 00102 // false: Object already in registry. You need to delete 00103 // the memory yourself in this case (the dispatcher didn't 00104 // take ownership of the object). 00105 bool registerObject( SOAPObjectCreator* pCreator ); 00106 00107 // used while within a dispatch to allow fellow methods to 00108 // reference each other 00109 SOAPMethod *GetMethod( const char* methodName ); 00110 00111 private: 00112 // Allow these two to create and destroy this class. 00113 // The file singleton.h explains why this is necessary. 00114 friend class Singleton< SOAPDispatcher >; 00115 friend class std::auto_ptr<SOAPDispatcher>; 00116 // Constructor/ Destructor 00117 SOAPDispatcher(); 00118 virtual ~SOAPDispatcher(); 00119 00120 // CreatorContainer 00121 // Description: Makes typing easier for the container. 00122 typedef std::map<std::string, SOAPObjectCreator*> 00123 CreatorContainer; 00124 00125 // m_creatorContainer 00126 // Description: The dispatcher's registry. 00127 CreatorContainer m_creatorContainer; 00128 00129 // hold the curretn list 00130 SOAPObject::MethodList *currentMethodList; 00131 }; 00132 00133 #endif // !defined(SOAPDISPATCHER_H)