source: XIOS3/trunk/src/log_type.cpp

Last change on this file was 2628, checked in by jderouillat, 3 months ago

New timers integration/reporting

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#include "log_type.hpp"
2#include "cxios.hpp"
3
4namespace xios
5{
6  using namespace std ;
7  CLogType logProtocol("log_protocol") ;
8  CLogType logTimers("log_timers") ;
9  CLogType logProfile("log_profile") ;
10 
11  int CLogType::globalBitPos_ = 0 ;
12
13  CLogType::CLogType(const std::string& name)
14  {
15    bitPos_ = CSetLog::registerLog(name, globalBitPos_) ;
16    if (bitPos_==-1) 
17    { 
18       bitPos_ = globalBitPos_ ;
19       globalBitPos_++ ;
20       if (globalBitPos_>63) ERROR("CLogType::CLogType(const std::string& name)",<<"max registred Log must be <64, need to modify CLogTyPe class algorithm") ;
21    }
22    type_ = (uint64_t)1 << bitPos_ ;
23  }
24
25  CSetLog::CSetLog(void)
26  {
27    std::string strIds = CXios::getin<std::string>("log_type","") ;
28    std::vector<std::string> names = splitRegex(strIds,"\\s* \\s*") ;
29   
30    auto& registredLog=getRegistredLog() ;
31
32    for(auto& name : names) 
33    {
34      auto it = registredLog.find(name) ;
35      if (it != registredLog.end()) CLogType::bitSet(logType_, it->second) ;
36    }
37  }
38
39  int CSetLog::registerLog(const std::string& name, int bitPos) 
40  { 
41    auto& registredLog = getRegistredLog() ;
42    auto it = registredLog.find(name) ;
43    if (it == registredLog.end()) 
44    {
45      registredLog.insert(pair<string, int>(name, bitPos)) ;
46      return -1 ;
47    }
48    else return it->second ;
49  }
50 
51  std::map<std::string, int>& CSetLog::getRegistredLog(void)
52  {
53    static std::map<std::string, int> registredLog ;
54    return registredLog ;
55  }
56
57}
Note: See TracBrowser for help on using the repository browser.