Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:52

0001 //------------------------------------------------------------------------------
0002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
0003 // Author: Lukasz Janyst <ljanyst@cern.ch>
0004 //------------------------------------------------------------------------------
0005 // XRootD is free software: you can redistribute it and/or modify
0006 // it under the terms of the GNU Lesser General Public License as published by
0007 // the Free Software Foundation, either version 3 of the License, or
0008 // (at your option) any later version.
0009 //
0010 // XRootD is distributed in the hope that it will be useful,
0011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 // GNU General Public License for more details.
0014 //
0015 // You should have received a copy of the GNU Lesser General Public License
0016 // along with XRootD.  If not, see <http://www.gnu.org/licenses/>.
0017 //------------------------------------------------------------------------------
0018 
0019 #ifndef __XRD_CL_DEFAULT_ENV_HH__
0020 #define __XRD_CL_DEFAULT_ENV_HH__
0021 
0022 #include "XrdSys/XrdSysPthread.hh"
0023 #include "XrdCl/XrdClEnv.hh"
0024 #include "XrdVersion.hh"
0025 
0026 class XrdOucPinLoader;
0027 struct EnvInitializer;
0028 
0029 namespace XrdCl
0030 {
0031   class PostMaster;
0032   class Log;
0033   class ForkHandler;
0034   class Monitor;
0035   class CheckSumManager;
0036   class TransportManager;
0037   class FileTimer;
0038   class PlugInManager;
0039   class PlugInFactory;
0040 
0041   //----------------------------------------------------------------------------
0042   //! Default environment for the client. Responsible for setting/importing
0043   //! defaults for the variables used by the client. And holding other
0044   //! global stuff.
0045   //----------------------------------------------------------------------------
0046   class DefaultEnv: public Env
0047   {
0048       friend struct ::EnvInitializer;
0049 
0050       //------------------------------------------------------------------------
0051       //! Constructor
0052       //------------------------------------------------------------------------
0053       DefaultEnv();
0054 
0055     public:
0056 
0057       //------------------------------------------------------------------------
0058       //! Get client version
0059       //------------------------------------------------------------------------
0060       inline static std::string GetVersion()
0061       {
0062         return XrdVERSION;
0063       }
0064 
0065       //------------------------------------------------------------------------
0066       //! Get default client environment
0067       //------------------------------------------------------------------------
0068       static Env *GetEnv();
0069 
0070       //------------------------------------------------------------------------
0071       //! Get default post master
0072       //------------------------------------------------------------------------
0073       static PostMaster *GetPostMaster();
0074 
0075       //------------------------------------------------------------------------
0076       //! Get default log
0077       //------------------------------------------------------------------------
0078       static Log *GetLog();
0079 
0080       //------------------------------------------------------------------------
0081       //! Set log level
0082       //!
0083       //! @param level Dump, Debug, Info, Warning or Error
0084       //------------------------------------------------------------------------
0085       static void SetLogLevel( const std::string &level );
0086 
0087       //------------------------------------------------------------------------
0088       //! Set log file
0089       //!
0090       //! @param filepath path to the log file
0091       //------------------------------------------------------------------------
0092       static bool SetLogFile( const std::string &filepath );
0093 
0094       //------------------------------------------------------------------------
0095       //! Set log mask.
0096       //! Determines which diagnostics topics should be printed. It's a
0097       //! "|" separated list of topics. The first element may be "All" in which
0098       //! case all the topics are enabled and the subsequent elements may turn
0099       //! them off, or "None" in which case all the topics are disabled and
0100       //! the subsequent flags may turn them on. If the topic name is prefixed
0101       //! with "^", then it means that the topic should be disabled. If the
0102       //! topic name is not prefixed, then it means that the topic should be
0103       //! enabled.
0104       //!
0105       //! The default for each level is "All", except for the "Dump" level,
0106       //! where the default is "All|^PollerMsg". This means that, at the
0107       //! "Dump" level, all the topics but "PollerMsg" are enabled.
0108       //!
0109       //! Available topics: AppMsg, UtilityMsg, FileMsg, PollerMsg,
0110       //! PostMasterMsg, XRootDTransportMsg, TaskMgrMsg, XRootDMsg,
0111       //! FileSystemMsg, AsyncSockMsg
0112       //!
0113       //! @param level log level or "All" for all levels
0114       //! @param mask  log mask
0115       //------------------------------------------------------------------------
0116       static void SetLogMask( const std::string &level,
0117                               const std::string &mask );
0118 
0119       //------------------------------------------------------------------------
0120       //! Get the fork handler
0121       //------------------------------------------------------------------------
0122       static ForkHandler *GetForkHandler();
0123 
0124       //------------------------------------------------------------------------
0125       //! Get file timer task
0126       //------------------------------------------------------------------------
0127       static FileTimer *GetFileTimer();
0128 
0129       //------------------------------------------------------------------------
0130       //! Get the monitor object
0131       //------------------------------------------------------------------------
0132       static Monitor *GetMonitor();
0133 
0134       //------------------------------------------------------------------------
0135       //! Get checksum manager
0136       //------------------------------------------------------------------------
0137       static CheckSumManager *GetCheckSumManager();
0138 
0139       //------------------------------------------------------------------------
0140       //! Get transport manager
0141       //------------------------------------------------------------------------
0142       static TransportManager *GetTransportManager();
0143 
0144       //------------------------------------------------------------------------
0145       //! Get plug-in manager
0146       //------------------------------------------------------------------------
0147       static PlugInManager *GetPlugInManager();
0148 
0149       //------------------------------------------------------------------------
0150       //! Retrieve the plug-in factory for the given URL
0151       //!
0152       //! @return you do not own the returned memory
0153       //------------------------------------------------------------------------
0154       static PlugInFactory *GetPlugInFactory( const std::string url );
0155 
0156       //------------------------------------------------------------------------
0157       //! Re-initialize the logging
0158       //------------------------------------------------------------------------
0159       static void ReInitializeLogging();
0160 
0161     private:
0162 
0163       //------------------------------------------------------------------------
0164       //! Initialize the environment
0165       //------------------------------------------------------------------------
0166       static void Initialize();
0167 
0168       //------------------------------------------------------------------------
0169       //! Finalize the environment
0170       //------------------------------------------------------------------------
0171       static void Finalize();
0172 
0173 
0174       static void SetUpLog();
0175 
0176       static XrdSysMutex        sInitMutex;
0177       static Env               *sEnv;
0178       static PostMaster        *sPostMaster;
0179       static Log               *sLog;
0180       static ForkHandler       *sForkHandler;
0181       static FileTimer         *sFileTimer;
0182       static Monitor           *sMonitor;
0183       static XrdOucPinLoader   *sMonitorLibHandle;
0184       static bool               sMonitorInitialized;
0185       static CheckSumManager   *sCheckSumManager;
0186       static TransportManager  *sTransportManager;
0187       static PlugInManager     *sPlugInManager;
0188   };
0189 
0190 }
0191 
0192 static struct EnvInitializer
0193 {
0194     EnvInitializer();
0195     ~EnvInitializer();
0196     static int counter;
0197 } initializer;
0198 
0199 
0200 #endif // __XRD_CL_DEFAULT_ENV_HH__