Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:10

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef FUN4ALL_FUN4ALLBASE_H
0004 #define FUN4ALL_FUN4ALLBASE_H
0005 
0006 #include <cstdint>
0007 #include <limits>  // std::numeric_limits
0008 #include <string>
0009 
0010 /** Base class for all Fun4All Classes
0011  *
0012  *  It implements the Name, the Verbosity and the print method
0013  */
0014 
0015 class Fun4AllBase
0016 {
0017  public:
0018   /** dtor.
0019       Does nothing as this is a base class only.
0020   */
0021   virtual ~Fun4AllBase();
0022 
0023   /// Returns the name of this module.
0024   virtual const std::string Name() const { return m_ThisName; }
0025 
0026   /// Sets the name of this module.
0027   virtual void Name(const std::string &name) { m_ThisName = name; }
0028 
0029   /** Print out some info about this module.
0030       @param what can be used to specify what to print exactly.
0031   */
0032   virtual void Print(const std::string &what = "ALL") const;
0033 
0034   enum enu_Verbosity
0035   {
0036 
0037     //! Quiet mode. Only output critical messages. Intended for batch production mode.
0038     VERBOSITY_QUIET = 0,
0039 
0040     //! Output some useful messages during manual command line running
0041     VERBOSITY_SOME = 1,
0042 
0043     //! Output more messages
0044     VERBOSITY_MORE = 2,
0045 
0046     //! Output even more messages
0047     VERBOSITY_EVEN_MORE = 3,
0048 
0049     //! Output a lot of messages
0050     VERBOSITY_A_LOT = 4,
0051 
0052     // ... use your imagination ...
0053 
0054     //! Show all messages. Useful for step-by-step debugging
0055     VERBOSITY_MAX = std::numeric_limits<int>::max() - 10
0056 
0057   };
0058 
0059   /// Sets the verbosity of this module (0 by default=quiet).
0060   virtual void Verbosity(const uint64_t ival) { m_Verbosity = ival; }
0061 
0062   /// Sets the verbosity of this module (0 by default=quiet).
0063   virtual void Verbosity(enu_Verbosity ival) { m_Verbosity = ival; }
0064 
0065   /// Gets the verbosity of this module.
0066   virtual uint64_t Verbosity() const { return m_Verbosity; }
0067 
0068   /// Gets the downscale of printouts for this module.
0069   virtual uint32_t VerbosityDownscale() const { return m_VerbosityDownscale; }
0070 
0071   /// Sets the downscale of printouts for this module.
0072   /// Use (cnt%VerbosityDownscale()) in the code to apply
0073   virtual void VerbosityDownscale(uint32_t ival) { m_VerbosityDownscale = std::max(1U, ival); }
0074 
0075  protected:
0076   /** ctor.
0077    */
0078   Fun4AllBase(const std::string &name = "NONAME");
0079 
0080  private:
0081   std::string m_ThisName;
0082 
0083   /// The verbosity level. 0 means not verbose at all.
0084   uint64_t m_Verbosity{VERBOSITY_QUIET};
0085   /// The frequency of printouts
0086   uint32_t m_VerbosityDownscale{1};
0087 };
0088 
0089 #endif