LCOV - code coverage report
Current view: top level - oks/src - oks_utils.hpp (source / functions) Coverage Total Hit
Test: code.result Lines: 16.7 % 12 2
Test Date: 2026-07-12 15:23:06 Functions: 9.1 % 11 1

            Line data    Source code
       1              : // DUNE DAQ modification notice:
       2              : // This file has been modified from the original ATLAS oks source for the DUNE DAQ project.
       3              : // Fork baseline commit: oks-08-03-04 (2022-04-14).
       4              : // Renamed since fork: yes (from src/oks_utils.h to src/oks_utils.hpp).
       5              : 
       6              : #ifndef OKS_KERNEL_UTILS_H
       7              : #define OKS_KERNEL_UTILS_H
       8              : 
       9              : #include "oks/exceptions.hpp"
      10              : 
      11              : #include <boost/date_time/posix_time/posix_time_types.hpp>
      12              : #include <boost/date_time/gregorian/gregorian_types.hpp>
      13              : 
      14              : #include <map>
      15              : #include <string>
      16              : 
      17              : namespace dunedaq {
      18              : namespace oks {
      19              : 
      20              : class OksClass;
      21              : class OksObject;
      22              : class OksXmlInputStream;
      23              : class OksFile;
      24              : struct OksAliasTable;
      25              : class OksKernel;
      26              : 
      27              :     // read date and time strings from OKS files (oks::Date, oks::Time or Boost ISO strings)
      28              : 
      29              :   boost::posix_time::ptime str2time(const char * value, size_t len, const char * file_name = nullptr);
      30              :   boost::gregorian::date str2date(const char * value, size_t len);
      31              : 
      32              : 
      33              :     // the structure for efficient search of objects to be re-read or to be deleted during reload
      34              : 
      35              :   struct ReloadObjects {
      36              : 
      37              : 
      38              :     template<typename T>
      39              :     using map_str_t = std::map<std::string, T>;
      40              : 
      41              :     std::map< const OksClass *, map_str_t<OksObject *> * > data;
      42              :     std::vector<OksObject *> created;
      43              : 
      44              :     ~ReloadObjects();
      45              :     void put(OksObject * obj);
      46              :     OksObject * pop(const OksClass* c, const std::string& id);
      47              :   };
      48              : 
      49              : 
      50              :     // the structure to pass common parameters to various read() methods of OksData and OksObject class
      51              : 
      52              :   struct ReadFileParams {
      53              :     OksFile* f;
      54              :     OksXmlInputStream& s;
      55              :     OksAliasTable * alias_table;
      56              :     OksKernel * oks_kernel;
      57              :     char format;
      58              :     ReloadObjects * reload_objects;
      59              :     const char * object_tag;
      60              :     size_t object_tag_len;
      61              :     OksObject * owner;
      62              :     std::string tmp;
      63              : 
      64          125 :     ReadFileParams(OksFile* f_, OksXmlInputStream& s_, OksAliasTable * t_, OksKernel * k_, char m_, ReloadObjects * l_) :
      65          125 :       f(f_), s(s_), alias_table(t_), oks_kernel(k_), format(m_), reload_objects(l_) { init(); }
      66              : 
      67              :     void init();
      68              :   };
      69              : 
      70              : 
      71              :   // 17-SEP-2009: for compatibility with previous OKS versions
      72              :   // FIXME: remove later ...
      73              : 
      74              :   class Date {
      75              : 
      76              :     public:
      77              : 
      78            0 :       Date              (const char * s) {set(s);} // dd/mm/[yy]yy
      79              : 
      80            0 :       virtual ~Date() { ; }
      81              : 
      82              :       void              set(const char *);
      83              : 
      84            0 :       long              year() const {return p_tm.tm_year;}
      85            0 :       unsigned short    month() const {return p_tm.tm_mon;}
      86            0 :       unsigned short    day() const {return p_tm.tm_mday;}
      87              : 
      88              :       virtual std::string str() const;
      89              : 
      90              : 
      91              :     protected:
      92              : 
      93              :       struct tm p_tm;
      94              : 
      95              :   };
      96              : 
      97              :   std::ostream& operator<<(std::ostream&, const Date&);
      98              : 
      99              : 
     100              :   class Time : public Date {
     101              : 
     102              :     public:
     103              : 
     104            0 :       Time              (const char * s) : Date(s) {/*set(s);*/} // dd/mm/[yy]yy hh:mm[:ss]
     105              : 
     106            0 :       virtual ~Time() { ; }
     107              : 
     108            0 :       unsigned short    hour() const {return  p_tm.tm_hour;}
     109            0 :       unsigned short    min() const {return  p_tm.tm_min;}
     110            0 :       unsigned short    sec() const {return  p_tm.tm_sec;}
     111              : 
     112              :       virtual std::string str() const;
     113              :   };
     114              : 
     115              :   std::ostream& operator<<(std::ostream&, const Time&);
     116              : 
     117              : 
     118              : } // namespace oks
     119              : } // namespace dunedaq
     120              : 
     121              : #endif
        

Generated by: LCOV version 2.0-1