Environment.h

Go to the documentation of this file.
00001 /*
00002 * Copyright 2005-2009 WSO2, Inc. http://wso2.com
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 * http://www.apache.org/licenses/LICENSE-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 
00017 #ifndef  ENVIRONMENT_H
00018 #define  ENVIRONMENT_H
00019 
00020 #include <axutil_platform_auto_sense.h>
00021 #include <WSFDefines.h>
00022 #include <axutil_env.h>
00023 #include <string>
00024 #include <map>
00025 
00034 namespace wso2wsf
00035 {
00045         class TLSKey
00046         {
00047                 private:        
00048 #ifdef WIN32
00049                 DWORD tls_key;
00050 #else                           
00051                 pthread_key_t tls_key;
00052 #endif          
00053                 public:
00057                 TLSKey()
00058                 {
00059 #ifdef WIN32
00060                          if ((tls_key = TlsAlloc()) == TLS_OUT_OF_INDEXES) 
00061                                  ExitProcess(0);
00062 #else
00063                         pthread_key_create(&tls_key, NULL);
00064 #endif
00065                 }
00069 #ifdef WIN32 
00070                 DWORD getTLSKey()
00071 #else
00072                 pthread_key_t getTLSKey()
00073 #endif
00074                 {
00075                         return tls_key;
00076                 }
00080                 ~TLSKey()
00081                 {
00082 #ifdef WIN32
00083                         TlsFree(tls_key);
00084 #else
00085                         pthread_key_delete(tls_key);
00086 #endif
00087                 }
00088         };
00089 
00097         class Environment
00098         {
00099 
00100         private:
00104                 static TLSKey key;
00105         public:
00109                 static std::string _logFileName;
00113                 static axutil_log_levels_t _logLevel;
00117                 Environment();
00122                 static WSF_EXTERN void WSF_CALL setEnv(const axutil_env_t *env);
00126                 static WSF_EXTERN const axutil_env_t* WSF_CALL getEnv();
00130                 static WSF_EXTERN void WSF_CALL removeEnv();
00134                 static WSF_EXTERN void WSF_CALL switchToGlobalPool();
00138                 static WSF_EXTERN void WSF_CALL switchToLocalPool();
00151                 static WSF_EXTERN void WSF_CALL initialize(std::string logFileName,  axutil_log_levels_t logLevel);
00155                 WSF_CALL ~Environment(); 
00156         };
00158 }
00159 
00160 #endif // ENVIRONMENT_H

Generated on Wed Oct 14 00:43:25 2009 for WSF/CPP by  doxygen 1.5.7.1