xref: /trafficserver/plugins/esi/lib/Stats.h (revision be5d6920)
1 /** @file
2 
3   A brief file description
4 
5   @section license License
6 
7   Licensed to the Apache Software Foundation (ASF) under one
8   or more contributor license agreements.  See the NOTICE file
9   distributed with this work for additional information
10   regarding copyright ownership.  The ASF licenses this file
11   to you under the Apache License, Version 2.0 (the
12   "License"); you may not use this file except in compliance
13   with the License.  You may obtain a copy of the License at
14 
15       http://www.apache.org/licenses/LICENSE-2.0
16 
17   Unless required by applicable law or agreed to in writing, software
18   distributed under the License is distributed on an "AS IS" BASIS,
19   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   See the License for the specific language governing permissions and
21   limitations under the License.
22  */
23 
24 #pragma once
25 
26 #include "Utils.h"
27 
28 namespace EsiLib
29 {
30 /** interface that stat systems should implement */
31 class StatSystem
32 {
33 public:
34   virtual void create(int handle) = 0;
35   // FIXME step should be TSMgmtInt
36   virtual void increment(int handle, int step = 1) = 0;
~StatSystem()37   virtual ~StatSystem(){};
38 };
39 
40 namespace Stats
41 {
42   enum STAT {
43     N_OS_DOCS           = 0,
44     N_CACHE_DOCS        = 1,
45     N_PARSE_ERRS        = 2,
46     N_INCLUDES          = 3,
47     N_INCLUDE_ERRS      = 4,
48     N_SPCL_INCLUDES     = 5,
49     N_SPCL_INCLUDE_ERRS = 6,
50     MAX_STAT_ENUM       = 7
51   };
52 
53   extern const char *STAT_NAMES[MAX_STAT_ENUM];
54   extern int g_stat_indices[Stats::MAX_STAT_ENUM];
55   extern StatSystem *g_system;
56 
57   void init(StatSystem *system);
58 
59   void increment(STAT st, int step = 1);
60 }; // namespace Stats
61 }; // namespace EsiLib
62