00001 //------------------------------------------------------------------------------ 00002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN) 00003 // Author: Lukasz Janyst <ljanyst@cern.ch> 00004 //------------------------------------------------------------------------------ 00005 // XRootD is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU Lesser General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // XRootD is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00017 //------------------------------------------------------------------------------ 00018 00019 #ifndef __XRD_CL_DEFAULT_ENV_HH__ 00020 #define __XRD_CL_DEFAULT_ENV_HH__ 00021 00022 #include "XrdSys/XrdSysPthread.hh" 00023 #include "XrdCl/XrdClEnv.hh" 00024 00025 class XrdOucPinLoader; 00026 struct EnvInitializer; 00027 00028 namespace XrdCl 00029 { 00030 class PostMaster; 00031 class Log; 00032 class ForkHandler; 00033 class Monitor; 00034 class CheckSumManager; 00035 class TransportManager; 00036 class FileTimer; 00037 class PlugInManager; 00038 class PlugInFactory; 00039 00040 //---------------------------------------------------------------------------- 00044 //---------------------------------------------------------------------------- 00045 class DefaultEnv: public Env 00046 { 00047 friend struct ::EnvInitializer; 00048 00049 //------------------------------------------------------------------------ 00051 //------------------------------------------------------------------------ 00052 DefaultEnv(); 00053 00054 public: 00055 00056 //------------------------------------------------------------------------ 00058 //------------------------------------------------------------------------ 00059 static Env *GetEnv(); 00060 00061 //------------------------------------------------------------------------ 00063 //------------------------------------------------------------------------ 00064 static PostMaster *GetPostMaster(); 00065 00066 //------------------------------------------------------------------------ 00068 //------------------------------------------------------------------------ 00069 static Log *GetLog(); 00070 00071 //------------------------------------------------------------------------ 00075 //------------------------------------------------------------------------ 00076 static void SetLogLevel( const std::string &level ); 00077 00078 //------------------------------------------------------------------------ 00082 //------------------------------------------------------------------------ 00083 static bool SetLogFile( const std::string &filepath ); 00084 00085 //------------------------------------------------------------------------ 00106 //------------------------------------------------------------------------ 00107 static void SetLogMask( const std::string &level, 00108 const std::string &mask ); 00109 00110 //------------------------------------------------------------------------ 00112 //------------------------------------------------------------------------ 00113 static ForkHandler *GetForkHandler(); 00114 00115 //------------------------------------------------------------------------ 00117 //------------------------------------------------------------------------ 00118 static FileTimer *GetFileTimer(); 00119 00120 //------------------------------------------------------------------------ 00122 //------------------------------------------------------------------------ 00123 static Monitor *GetMonitor(); 00124 00125 //------------------------------------------------------------------------ 00127 //------------------------------------------------------------------------ 00128 static CheckSumManager *GetCheckSumManager(); 00129 00130 //------------------------------------------------------------------------ 00132 //------------------------------------------------------------------------ 00133 static TransportManager *GetTransportManager(); 00134 00135 //------------------------------------------------------------------------ 00137 //------------------------------------------------------------------------ 00138 static PlugInManager *GetPlugInManager(); 00139 00140 //------------------------------------------------------------------------ 00144 //------------------------------------------------------------------------ 00145 static PlugInFactory *GetPlugInFactory( const std::string url ); 00146 00147 //------------------------------------------------------------------------ 00149 //------------------------------------------------------------------------ 00150 static void ReInitializeLogging(); 00151 00152 private: 00153 00154 //------------------------------------------------------------------------ 00156 //------------------------------------------------------------------------ 00157 static void Initialize(); 00158 00159 //------------------------------------------------------------------------ 00161 //------------------------------------------------------------------------ 00162 static void Finalize(); 00163 00164 00165 static void SetUpLog(); 00166 00167 static XrdSysMutex sInitMutex; 00168 static Env *sEnv; 00169 static PostMaster *sPostMaster; 00170 static Log *sLog; 00171 static ForkHandler *sForkHandler; 00172 static FileTimer *sFileTimer; 00173 static Monitor *sMonitor; 00174 static XrdOucPinLoader *sMonitorLibHandle; 00175 static bool sMonitorInitialized; 00176 static CheckSumManager *sCheckSumManager; 00177 static TransportManager *sTransportManager; 00178 static PlugInManager *sPlugInManager; 00179 }; 00180 00181 } 00182 00183 static struct EnvInitializer 00184 { 00185 EnvInitializer(); 00186 ~EnvInitializer(); 00187 static int counter; 00188 } initializer; 00189 00190 00191 #endif // __XRD_CL_DEFAULT_ENV_HH__