2 * Copyright (c) 2018 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef __VOM_STAT_CLIENT_H__
17 #define __VOM_STAT_CLIENT_H__
24 #include <vpp-api/client/stat_client.h>
30 * A representation of a stat client in VPP
36 * stat data representation
41 * stat data custom constructor
43 stat_data_t(const stat_segment_data_t& stat_seg_data);
48 const std::string& name() const;
53 const stat_directory_type_t& type() const;
56 * Get pointer to actual data
58 double get_stat_segment_scalar_data() const;
59 uint64_t* get_stat_segment_error_data() const;
60 uint64_t** get_stat_segment_simple_counter_data() const;
61 vlib_counter_t** get_stat_segment_combined_counter_data() const;
67 const std::string m_name;
72 const stat_directory_type_t m_type;
75 * union of pointers to actual stat data
79 double m_scalar_value;
80 counter_t* m_error_vec;
81 counter_t** m_simple_counter_vec;
82 vlib_counter_t** m_combined_counter_vec;
87 * vector of stat_data_t
89 typedef std::vector<stat_data_t> stat_data_vec_t;
92 * Stat Client constructor with custom socket name
94 stat_client(std::string& socket_name);
97 * Stat Client constructor with custom vector of patterns
99 stat_client(std::vector<std::string>& pattern);
102 * Stat Client constructor with custom socket name and vector of patterns
104 stat_client(std::string socket_name, std::vector<std::string> patterns);
107 * Stat Client constructor
112 * Stat Client destructor
117 * Stat Client copy constructor
119 stat_client(const stat_client& o);
122 * Connect to stat segment
127 * Disconnect to stat segment
132 * dump all the stats for given pattern
134 const stat_data_vec_t& dump();
137 * dump stats for given index in stat directory
139 const stat_data_vec_t& dump_entry(uint32_t index);
142 * Get vector length of VPP style vector
144 int vec_len(void* vec);
149 * get index to name of stat
151 std::string index_to_name(uint32_t index);
155 * Free VPP style vector
157 void vec_free(void* vec);
160 * Free stat segment data
165 * ls on the stat directory using given pattern
172 std::string m_socket_name;
175 * vector of patterns for stats
177 std::vector<std::string> m_patterns;
185 * Pointer to VPP style vector of stat indexes
187 uint32_t* m_counter_vec;
190 * Pointer to stat segment
192 stat_segment_data_t* m_stat_seg_data;
195 * Vector of stat data
197 stat_data_vec_t m_stat_data;
202 * fd.io coding-style-patch-verification: ON
205 * eval: (c-set-style "mozilla")