HawkTracer  0.10.0
feature.h
Go to the documentation of this file.
1 #ifndef HAWKTRACER_FEATURE_H
2 #define HAWKTRACER_FEATURE_H
3 
4 #include <hawktracer/macros.h>
6 #include <hawktracer/alloc.h>
7 
9 
13 typedef struct _HT_Feature HT_Feature;
14 
20 typedef void (*HT_FeatureDestroy)(HT_Feature* feature);
21 
28 typedef struct
29 {
36 
37  /* <private readonly> */
44  uint32_t id;
46 
54 {
57 };
58 
71 #define HT_FEATURE_DEFINE(TYPE_NAME, DESTROY_FNC) \
72  static HT_FeatureKlass* TYPE_NAME ## _get_class(void) { \
73  static HT_FeatureKlass feature_klass = { DESTROY_FNC, HT_INVALID_FEATURE_ID }; \
74  return &feature_klass; \
75  } \
76  static TYPE_NAME* TYPE_NAME ## _alloc(void) { \
77  TYPE_NAME* feature = HT_CREATE_TYPE(TYPE_NAME); \
78  if (feature) { \
79  ((HT_Feature*)feature)->klass = TYPE_NAME ## _get_class(); \
80  } \
81  return feature; \
82  } \
83  static HT_INLINE TYPE_NAME* TYPE_NAME ## _from_timeline(HT_Timeline* timeline) { \
84  return ((TYPE_NAME*)ht_timeline_get_feature(timeline, TYPE_NAME ## _get_class())); \
85  } \
86  HT_ErrorCode TYPE_NAME ## _register(void) { \
87  return ht_registry_register_feature(TYPE_NAME ## _get_class()); \
88  }
89 
91 
92 #endif /* HAWKTRACER_FEATURE_H */
typedefHT_DECLS_BEGIN struct _HT_Feature HT_Feature
Definition: feature.h:13
#define HT_DECLS_END
Defines an end of C linkage block.
Definition: macros.h:17
The struct is a base class for all the user-defined features.
Definition: feature.h:53
uint32_t id
Stores identifier of the feature class.
Definition: feature.h:44
HT_FeatureDestroy destroy
Destroy calback.
Definition: feature.h:35
void(* HT_FeatureDestroy)(HT_Feature *feature)
A type of the destroy feature callback.
Definition: feature.h:20
HT_FeatureKlass * klass
A pointer to a class of the feature.
Definition: feature.h:56
#define HT_DECLS_BEGIN
Defines a beginning of C linkage block.
Definition: macros.h:16
The struct represents a feature class.
Definition: feature.h:28