stat_client.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright [2021] JD.com, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. #ifndef __STAT_MGR_H
  18. #define __STAT_MGR_H
  19. #include "stat_manager.h"
  20. class StatClient : public StatManager {
  21. public:
  22. int init_stat_info(const char *name, const char *index_file);
  23. typedef StatInfo *Iterator_;
  24. int check_point(void);
  25. inline Iterator_ get_begin_stat_info(void)
  26. {
  27. return stat_info_;
  28. }
  29. inline Iterator_ get_end_stat_info(void)
  30. {
  31. return stat_info_ + stat_num_info_;
  32. }
  33. int64_t read_counter_value(Iterator_ stat_info, unsigned int cat);
  34. int64_t read_sample_counter(Iterator_ stat_info, unsigned int cat,
  35. unsigned int count = 0);
  36. int64_t read_sample_average(Iterator_ stat_info, unsigned int cat);
  37. Iterator_ operator[](unsigned int id)
  38. {
  39. return id_map_[id];
  40. }
  41. public:
  42. // client/tools access
  43. StatClient();
  44. ~StatClient();
  45. private:
  46. int last_serial_number_;
  47. };
  48. #endif