\doxysection{stat\+\_\+item.\+h}
\label{stat__item_8h_source}\index{include/osmocom/core/stat\_item.h@{include/osmocom/core/stat\_item.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{2 }
\DoxyCodeLine{7 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{8 }
\DoxyCodeLine{9 \textcolor{preprocessor}{\#include <osmocom/core/defs.h>}}
\DoxyCodeLine{10 \textcolor{preprocessor}{\#include <osmocom/core/linuxlist.h>}}
\DoxyCodeLine{11 }
\DoxyCodeLine{12 \textcolor{keyword}{struct }osmo\_stat\_item\_desc;}
\DoxyCodeLine{13 }
\DoxyCodeLine{14 \textcolor{preprocessor}{\#define OSMO\_STAT\_ITEM\_NOVALUE\_ID 0}}
\DoxyCodeLine{15 \textcolor{preprocessor}{\#define OSMO\_STAT\_ITEM\_NO\_UNIT NULL}}
\DoxyCodeLine{16 }
\DoxyCodeLine{19 \textcolor{keyword}{struct }osmo\_stat\_item;}
\DoxyCodeLine{20 }
\DoxyCodeLine{22 \textcolor{keyword}{struct }osmo\_stat\_item\_desc \{}
\DoxyCodeLine{23         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name;   }
\DoxyCodeLine{24         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *description;}
\DoxyCodeLine{25         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *unit;   }
\DoxyCodeLine{26         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} num\_values;}
\DoxyCodeLine{27         int32\_t default\_value;     }
\DoxyCodeLine{28 \};}
\DoxyCodeLine{29 }
\DoxyCodeLine{31 \textcolor{keyword}{struct }osmo\_stat\_item\_group\_desc \{}
\DoxyCodeLine{33         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *group\_name\_prefix;}
\DoxyCodeLine{35         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *group\_description;}
\DoxyCodeLine{37         \textcolor{keywordtype}{int} class\_id;}
\DoxyCodeLine{39         \textcolor{keyword}{const} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} num\_items;}
\DoxyCodeLine{41         \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_stat\_item\_desc *item\_desc;}
\DoxyCodeLine{42 \};}
\DoxyCodeLine{43 }
\DoxyCodeLine{45 \textcolor{keyword}{struct }osmo\_stat\_item\_group \{}
\DoxyCodeLine{47         \textcolor{keyword}{struct }llist\_head list;}
\DoxyCodeLine{49         \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_stat\_item\_group\_desc *desc;}
\DoxyCodeLine{51         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} idx;}
\DoxyCodeLine{53         \textcolor{keywordtype}{char} *name;}
\DoxyCodeLine{55         \textcolor{keyword}{struct }osmo\_stat\_item *items[0];}
\DoxyCodeLine{56 \};}
\DoxyCodeLine{57 }
\DoxyCodeLine{58 \textcolor{keyword}{struct }osmo\_stat\_item\_group *osmo\_stat\_item\_group\_alloc(}
\DoxyCodeLine{59         \textcolor{keywordtype}{void} *ctx,}
\DoxyCodeLine{60         \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_stat\_item\_group\_desc *group\_desc,}
\DoxyCodeLine{61         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} idx);}
\DoxyCodeLine{62 }
\DoxyCodeLine{63 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{void} osmo\_stat\_item\_group\_udp\_idx(}
\DoxyCodeLine{64         \textcolor{keyword}{struct} osmo\_stat\_item\_group *grp, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} idx)}
\DoxyCodeLine{65 \{}
\DoxyCodeLine{66         grp-\/>idx = idx;}
\DoxyCodeLine{67 \}}
\DoxyCodeLine{68 \textcolor{keyword}{struct }osmo\_stat\_item *osmo\_stat\_item\_group\_get\_item(\textcolor{keyword}{struct} osmo\_stat\_item\_group *grp, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} idx);}
\DoxyCodeLine{69 \textcolor{keywordtype}{void} osmo\_stat\_item\_group\_set\_name(\textcolor{keyword}{struct} osmo\_stat\_item\_group *statg, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{70 \textcolor{keywordtype}{void} osmo\_stat\_item\_group\_free(\textcolor{keyword}{struct} osmo\_stat\_item\_group *statg);}
\DoxyCodeLine{71 }
\DoxyCodeLine{72 \textcolor{keywordtype}{void} osmo\_stat\_item\_inc(\textcolor{keyword}{struct} osmo\_stat\_item *item, int32\_t value);}
\DoxyCodeLine{73 \textcolor{keywordtype}{void} osmo\_stat\_item\_dec(\textcolor{keyword}{struct} osmo\_stat\_item *item, int32\_t value);}
\DoxyCodeLine{74 \textcolor{keywordtype}{void} osmo\_stat\_item\_set(\textcolor{keyword}{struct} osmo\_stat\_item *item, int32\_t value);}
\DoxyCodeLine{75 }
\DoxyCodeLine{76 \textcolor{keywordtype}{int} osmo\_stat\_item\_init(\textcolor{keywordtype}{void} *tall\_ctx);}
\DoxyCodeLine{77 }
\DoxyCodeLine{78 \textcolor{keyword}{struct }osmo\_stat\_item\_group *osmo\_stat\_item\_get\_group\_by\_name\_idx(}
\DoxyCodeLine{79         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name, \textcolor{keyword}{const} \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} idx);}
\DoxyCodeLine{80 \textcolor{keyword}{struct }osmo\_stat\_item\_group *osmo\_stat\_item\_get\_group\_by\_name\_idxname(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *group\_name, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *idx\_name);}
\DoxyCodeLine{81 }
\DoxyCodeLine{82 \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_stat\_item *osmo\_stat\_item\_get\_by\_name(}
\DoxyCodeLine{83         \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_stat\_item\_group *statg, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{84 }
\DoxyCodeLine{85 int32\_t osmo\_stat\_item\_get\_last(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_stat\_item *item);}
\DoxyCodeLine{86 }
\DoxyCodeLine{87 \textcolor{keywordtype}{void} osmo\_stat\_item\_flush(\textcolor{keyword}{struct} osmo\_stat\_item *item);}
\DoxyCodeLine{88 }
\DoxyCodeLine{89 \textcolor{keyword}{typedef} int (*osmo\_stat\_item\_handler\_t)(}
\DoxyCodeLine{90         \textcolor{keyword}{struct }osmo\_stat\_item\_group *, \textcolor{keyword}{struct }osmo\_stat\_item *, \textcolor{keywordtype}{void} *);}
\DoxyCodeLine{91 }
\DoxyCodeLine{92 \textcolor{keyword}{typedef} int (*osmo\_stat\_item\_group\_handler\_t)(\textcolor{keyword}{struct }osmo\_stat\_item\_group *, \textcolor{keywordtype}{void} *);}
\DoxyCodeLine{93 }
\DoxyCodeLine{94 \textcolor{keywordtype}{int} osmo\_stat\_item\_for\_each\_item(\textcolor{keyword}{struct} osmo\_stat\_item\_group *statg,}
\DoxyCodeLine{95         osmo\_stat\_item\_handler\_t handle\_item, \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{96 }
\DoxyCodeLine{97 \textcolor{keywordtype}{int} osmo\_stat\_item\_for\_each\_group(osmo\_stat\_item\_group\_handler\_t handle\_group, \textcolor{keywordtype}{void} *data);}
\DoxyCodeLine{98 }
\DoxyCodeLine{99 \textcolor{keywordtype}{void} osmo\_stat\_item\_reset(\textcolor{keyword}{struct} osmo\_stat\_item *item);}
\DoxyCodeLine{100 \textcolor{keywordtype}{void} osmo\_stat\_item\_group\_reset(\textcolor{keyword}{struct} osmo\_stat\_item\_group *statg);}
\DoxyCodeLine{101 }
\DoxyCodeLine{102 \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_stat\_item\_desc *osmo\_stat\_item\_get\_desc(\textcolor{keyword}{struct} osmo\_stat\_item *item);}
\DoxyCodeLine{103 }
\DoxyCodeLine{104 \textcolor{comment}{/* DEPRECATION: up until libosmocore 1.5.1, this API also defined}}
\DoxyCodeLine{105 \textcolor{comment}{ * -\/ struct osmo\_stat\_item\_value}}
\DoxyCodeLine{106 \textcolor{comment}{ * -\/ osmo\_stat\_item\_get\_next()}}
\DoxyCodeLine{107 \textcolor{comment}{ * -\/ osmo\_stat\_item\_discard()}}
\DoxyCodeLine{108 \textcolor{comment}{ * -\/ osmo\_stat\_item\_discard\_all()}}
\DoxyCodeLine{109 \textcolor{comment}{ * Despite our principle of never breaking API compatibility, we have decided to remove these, because there are no}}
\DoxyCodeLine{110 \textcolor{comment}{ * known users. These items were never practically used/usable outside of libosmocore since the generic stats reporter}}
\DoxyCodeLine{111 \textcolor{comment}{ * (stats.c) was introduced.}}
\DoxyCodeLine{112 \textcolor{comment}{ * We also decided to make struct osmo\_stat\_item opaque to allow future changes of the struct without API breakage.}}
\DoxyCodeLine{113 \textcolor{comment}{ */}}
\DoxyCodeLine{114 }

\end{DoxyCode}
