Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:43:50

0001 #ifndef LOGGER_PRINT_MODE_H
0002 #define LOGGER_PRINT_MODE_H
0003 
0004 /**
0005  * @file LoggerPrintMode.h
0006  * @author Bryan BERTHOU (SPhN / CEA Saclay)
0007  * @date 05 September 2014
0008  * @version 1.0
0009  */
0010 
0011 #include <string>
0012 
0013 #include "../string_utils/StringUtils.h"
0014 
0015 namespace ElemUtils {
0016 
0017 /**
0018  * @struct LoggerPrintMode
0019  * @brief
0020  */
0021 class LoggerPrintMode {
0022 public:
0023     enum Type {
0024         COUT, FILE, BOTH, DEFAULT
0025     };
0026 
0027     LoggerPrintMode(Type type) :
0028             m_type(type) {
0029     }
0030 
0031     std::string toString() {
0032         switch (m_type) {
0033         case COUT:
0034             return "COUT";
0035             break;
0036         case FILE:
0037             return "FILE";
0038             break;
0039         case BOTH:
0040             return "BOTH";
0041             break;
0042         default:
0043             return "DEFAULT";
0044         }
0045     }
0046 
0047     static LoggerPrintMode fromString(std::string printMode) {
0048         StringUtils::to_upperCase(printMode);
0049         if (printMode == "COUT") {
0050             return COUT;
0051         } else if (printMode == "FILE") {
0052             return FILE;
0053         } else if (printMode == "BOTH") {
0054             return BOTH;
0055         }
0056 
0057         return DEFAULT;
0058     }
0059 
0060     LoggerPrintMode::Type getType() const {
0061         return m_type;
0062     }
0063 
0064     void setType(Type type) {
0065         m_type = type;
0066     }
0067 
0068 private:
0069     LoggerPrintMode::Type m_type;
0070 };
0071 
0072 } // namespace ElemUtils
0073 
0074 #endif /* LOGGER_PRINT_MODE_H */