From 97ce56cf5fa7d6f618eed4020dd7f98405740290 Mon Sep 17 00:00:00 2001 From: Manuel Traut Date: Fri, 8 Jun 2012 00:46:23 +0200 Subject: libdistrio_common: add helper for creating/filling Distrio::Error can be used after return ... Signed-off-by: Manuel Traut --- common/distrio_error.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/distrio_error.h b/common/distrio_error.h index 67ec5ea..36b6c93 100644 --- a/common/distrio_error.h +++ b/common/distrio_error.h @@ -9,6 +9,26 @@ #include +inline Distrio::Error *distrio_error (::Distrio::Error_code code, + ::Distrio::Error_level level, + long module_id, + std::string description) +{ + struct timespec ts; + Distrio::Error *e = new Distrio::Error; + + clock_gettime (CLOCK_REALTIME, &ts); + + e->code = code; + e->level = level; + e->time.seconds = ts.tv_sec; + e->time.nanoseconds = ts.tv_nsec; + e->module_id = module_id; + e->description = CORBA::string_dup (description.c_str ()); + + return e; +} + inline Distrio::Error *distrio_success (void) { struct timespec ts; Distrio::Error *e = new Distrio::Error; -- cgit v1.2.3