WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
UsageReporting.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#ifdef __cplusplus
10#include <string_view>
11#endif
12
13#include <wpi/string.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/**
20 * Reports usage of a resource of interest. Repeated calls for the same
21 * resource name replace the previous report.
22 *
23 * @param resource the used resource name; convention is to suffix with
24 * "[instanceNum]" for multiple instances of the same
25 * resource
26 * @param data arbitrary associated data string
27 * @return a handle
28 */
29int32_t HAL_ReportUsage(const struct WPI_String* resource,
30 const struct WPI_String* data);
31
32#ifdef __cplusplus
33} // extern "C"
34#endif
35
36#ifdef __cplusplus
37/**
38 * Reports usage of a resource of interest. Repeated calls for the same
39 * resource name replace the previous report.
40 *
41 * @param resource the used resource name; convention is to suffix with
42 * "[instanceNum]" for multiple instances of the same
43 * resource
44 * @param data arbitrary associated data string
45 * @return a handle
46 */
47inline int32_t HAL_ReportUsage(std::string_view resource,
48 std::string_view data) {
49 WPI_String resourceStr = wpi::make_string(resource);
50 WPI_String dataStr = wpi::make_string(data);
51 return HAL_ReportUsage(&resourceStr, &dataStr);
52}
53
54/**
55 * Reports usage of a resource of interest. Repeated calls for the same
56 * resource name replace the previous report.
57 *
58 * @param resource the used resource name
59 * @param instanceNumber an index that identifies the resource instance
60 * @param data arbitrary associated data string
61 * @return a handle
62 */
63int32_t HAL_ReportUsage(std::string_view resource, int instanceNumber,
64 std::string_view data);
65
66#endif
int32_t HAL_ReportUsage(const struct WPI_String *resource, const struct WPI_String *data)
Reports usage of a resource of interest.
constexpr WPI_String make_string(std::string_view view)
Converts a string_view to a WPI_String.
Definition string.h:33
A const UTF8 string.
Definition string.h:14