Extract util methods
This commit is contained in:
parent
51f3c16205
commit
ee813caaf1
5 changed files with 52 additions and 20 deletions
|
@ -158,7 +158,7 @@ void TRACEPOINT(
|
|||
void TRACEPOINT(
|
||||
rclcpp_callback_register,
|
||||
const void * callback,
|
||||
const void * function_target);
|
||||
const char * function_symbol);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
19
tracetools/include/tracetools/utils.hpp
Normal file
19
tracetools/include/tracetools/utils.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef __TRACETOOLS_UTILS_H_
|
||||
#define __TRACETOOLS_UTILS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
template<typename T, typename... U>
|
||||
size_t get_address(std::function<T(U...)> f) {
|
||||
typedef T(fnType)(U...);
|
||||
fnType ** fnPointer = f.template target<fnType*>();
|
||||
// Might be a lambda
|
||||
if (fnPointer == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return (size_t)*fnPointer;
|
||||
}
|
||||
|
||||
const char * get_symbol(void * funptr);
|
||||
|
||||
#endif /* __TRACETOOLS_UTILS_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue