26 #ifndef GOBY_MIDDLEWARE_COMMON_H
27 #define GOBY_MIDDLEWARE_COMMON_H
31 #include <sys/syscall.h>
35 #include <boost/algorithm/string.hpp>
46 const int underscore_pos = 5;
53 inline std::string
thread_id(std::thread::id i = std::this_thread::get_id())
56 ss << std::hex << std::hash<std::thread::id>{}(i);
62 inline uint64_t gettid()
65 pthread_threadid_np(NULL, &tid);
68 #elif defined SYS_gettid
71 return syscall(SYS_gettid);
74 #error "SYS_gettid unavailable on this system, and this is not an Apple system."
80 std::ifstream hs(
"/etc/hostname");
83 std::string
hostname((std::istreambuf_iterator<char>(hs)),
84 std::istreambuf_iterator<char>());
97 static const std::string host_id =
hostname();
99 static const std::string full_pid = host_id + std::string(
"-p") + pid;
simple exception class for goby applications
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
const std::string & Layer_Name(T enum_t_value)
std::string full_process_and_thread_id(std::thread::id i=std::this_thread::get_id())
std::string to_string(goby::middleware::protobuf::Layer layer)
std::string full_process_id()
std::string thread_id(std::thread::id i=std::this_thread::get_id())
The global namespace for the Goby project.
std::pair< size_t, size_t > trim(const char *b, const char *e, size_t left, size_t right)
std::string to_lower(const char *beg, const char *end)