LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-analytics/contrail-collector - usrdef_counters.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 13 0.0 %
Date: 2026-08-03 02:19:58 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : #ifndef __USER_DEFINED_COUNTER_H__
       5             : #define __USER_DEFINED_COUNTER_H__
       6             : 
       7             : 
       8             : #include <map>
       9             : #include <boost/shared_ptr.hpp>
      10             : #include "http/client/vncapi.h"
      11             : #include "parser_util.h"
      12             : #include <analytics/analytics_types.h>
      13             : #include "base/regex.h"
      14             : #include "config_client_collector.h"
      15             : 
      16             : using contrail::regex;
      17             : using contrail::regex_match;
      18             : using contrail::regex_search;
      19             : 
      20             : class Options;
      21             : 
      22             : class UserDefinedCounterData {
      23             :     public:
      24           0 :         explicit UserDefinedCounterData(std::string name, std::string pat):
      25           0 :             refreshed_(true), name_(name) {
      26           0 :             SetPattern(pat);
      27           0 :         }
      28           0 :         void SetPattern(std::string pat) {
      29           0 :             regexp_ = contrail::regex(pat);
      30           0 :             regexp_str_ = pat;
      31           0 :         }
      32             :         bool operator==(const UserDefinedCounterData &rhs) {
      33             :             return rhs.IsMe(name_) &&  rhs.pattern() == regexp_str_;
      34             :         }
      35           0 :         const contrail::regex& regexp() const { return regexp_; }
      36           0 :         const std::string name() { return name_; }
      37             :         bool IsMe(std::string name) const { return name == name_; }
      38           0 :         const std::string pattern() const { return regexp_str_; }
      39           0 :         void Refresh() { refreshed_ = true; }
      40           0 :         bool IsRefreshed() { bool r = refreshed_; refreshed_ = false; return r;}
      41             :     private:
      42             :         bool                   refreshed_;
      43             :         std::string            name_;
      44             :         std::string            regexp_str_;
      45             :         contrail::regex        regexp_;
      46             : };
      47             : 
      48             : typedef std::map<std::string, boost::shared_ptr<UserDefinedCounterData> > Cfg_t;
      49             : 
      50             : class UserDefinedCounters {
      51             :     public:
      52             :         UserDefinedCounters();
      53             :         virtual ~UserDefinedCounters();
      54             :         virtual void MatchFilter(std::string text, LineParser::WordListType *words);
      55             :         void SendUVEs();
      56             :         void AddConfig(std::string name, std::string pattern);
      57             :         bool FindByName(std::string name);
      58             :         void UDCHandler(const contrail_rapidjson::Document &jdoc, bool add_change);
      59             :         void GetUDCConfig(std::vector<LogStatisticConfigInfo> *config_info);
      60             :     private:
      61             :         Cfg_t config_;
      62             : };
      63             : 
      64             : 
      65             : #endif

Generated by: LCOV version 1.14