13 #define INTERNAL_LOG_MSG(message) prepareLogMessage((message), \
14 __func__, m_private_class_name, \
18 const char *
function,
const char *container,
19 const char *filename,
int line_no)
22 std::stringstream ss_retval;
25 (filename && filename[0] !=
'\0') || (container && container[0] !=
'\0') || (
function &&
function[0] !=
'\0') || (line_no >= 0);
26 if (filename && filename[0] !=
'\0')
27 ss_retval << filename;
29 ss_retval <<
":" << line_no;
30 if (container && container[0] !=
'\0')
31 ss_retval <<
":" << container;
32 if (
function &&
function[0] !=
'\0')
33 ss_retval <<
"::" <<
function <<
"()";
34 if (bheader && message && message[0])
36 if (message && message[0])
39 return ss_retval.str();
43 const std::string &
function,
const std::string &container,
44 const std::string &filename,
int line_no)
47 function.c_str(), container.c_str(),
48 filename.c_str(), line_no);
86 m_lib_handle = src.m_lib_handle;
87 src.m_lib_handle =
nullptr;
96 m_lib_handle = src.m_lib_handle;
97 src.m_lib_handle =
nullptr;
128 std::vector<char> ch_retval;
131 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Unexpected error retrieving report header."));
133 if (
getReportHeader(m_lib_handle, ch_retval.data(), ch_retval.size()) <= 0)
134 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Unexpected error retrieving report header."));
135 return ch_retval.data();
158 std::vector<char> ch_retval;
161 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Unexpected error retrieving report footer."));
163 if (
getReportFooter(m_lib_handle, ch_retval.data(), ch_retval.size()) <= 0)
164 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Unexpected error retrieving report footer."));
165 return ch_retval.data();
170 bool retval = (is_main_event ?
175 std::string err_msg = (is_main_event ?
176 "Error adding main event type." :
177 "Error adding event.");
187 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Error querying for event type."));
194 std::vector<char> ch_retval;
197 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Unexpected error retrieving event type header."));
200 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Unexpected error retrieving event type header."));
201 return ch_retval.data();
212 if (retval == std::numeric_limits<decltype(retval)>::max())
222 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Error retrieving main event type."));
230 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Error adding new event to report."));
236 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Error retrieving event from report."));
252 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Error setting new capacity for events."));
264 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Error saving report to CSV file."));
269 char *p_tmp =
nullptr;
271 throw std::runtime_error(
INTERNAL_LOG_MSG(
"Error converting report to CSV format."));
272 std::shared_ptr<char> sp_csv_content = std::shared_ptr<char>(p_tmp,
277 std::string retval = sp_csv_content.get();
287 if (!retval.m_lib_handle)
299 if (!retval.m_lib_handle)
static void setTimingPrefix(TimingPrefixedSeconds &prefix, double seconds, char ch_prefix)
Converts the time in seconds to the specified time unit.
static void computeTimingPrefix(TimingPrefixedSeconds &prefix, double seconds)
Given a time interval in seconds, computes the timing prefix.
TimingReport & operator=(TimingReport &&)
bool hasEventType(uint32_t event_type_id) const
static TimingReport loadReportFromCSVFile(const std::string &filename)
void save2CSV(const std::string &filename)
static TimingReport loadReportFromCSV(const std::string &s_csv_content)
void setFooter(const std::string &new_footer)
uint32_t getMainEventType() const
std::string convert2CSV()
void addEvent(const TimingReportEventC &p_event)
std::string getFooter() const
void prependFooter(const std::string &new_header, bool new_line=true)
void setEventCapacity(uint64_t new_capacity)
uint64_t getEventTypeCount() const
void getEvent(TimingReportEventC &p_event, uint64_t index) const
void prependHeader(const std::string &new_header, bool new_line=true)
uint64_t getEventCount() const
uint64_t getEventCapacity() const
void addEventType(uint32_t event_type_id, const std::string &event_type_header, bool is_main_event=false)
Adds a new event type to the types of events.
std::string getHeader() const
std::string getEventTypeHeader(uint32_t event_type_id) const
void appendFooter(const std::string &new_header, bool new_line=true)
uint32_t getEventType(uint64_t index) const
Retrieve an event type ID.
TimingReport(const TimingReport &)=delete
void setHeader(const std::string &new_header)
void appendHeader(const std::string &new_header, bool new_line=true)
#define INTERNAL_LOG_MSG(message)
std::string prepareLogMessage(const char *message, const char *function, const char *container, const char *filename, int line_no)
#define MAX_DESCRIPTION_BUFFER_SIZE
uint32_t getEventType(void *p_report, uint64_t index)
Retrieve an event type ID.
void freeCSVContent(char *p_csv_content)
Releases resources allocated by functions that generate CSV formatted reports from a timing report.
int32_t setReportFooter(void *p_report, const char *new_footer)
int32_t addMainEventType(void *p_report, uint32_t event_type_id, const char *event_type_header)
Adds an event type and marks it as the main event.
void * loadReportFromCSVFile(const char *filename, char error_description[MAX_DESCRIPTION_BUFFER_SIZE])
int32_t appendReportHeader(void *p_report, const char *new_header, int32_t new_line)
Appends text to existing header.
int32_t prependReportHeader(void *p_report, const char *new_header, int32_t new_line)
Prepends text to existing header.
uint64_t getReportHeader(void *p_report, char *header, uint64_t size)
std::string to_string(const std::string_view &s)
int32_t getMainEventType(void *p_report, uint32_t *p_event_type_id)
getMainEventType
int32_t hasEventType(void *p_report, uint32_t event_type_id)
hasEventType
int32_t addEvent(void *p_report, const TimingReportEventC *p_event)
addEvent
uint64_t getEventCapacity(void *p_report)
int32_t save2CSV(void *p_report, const char *filename)
uint64_t getEventTypeCount(void *p_report)
void freeReport(void *p_report)
int32_t addEventType(void *p_report, uint32_t event_type_id, const char *event_type_header)
addEventType
uint64_t getReportFooter(void *p_report, char *footer, uint64_t size)
void * loadReportFromCSV(const char *p_csv_content, char error_description[MAX_DESCRIPTION_BUFFER_SIZE])
int32_t setTimingPrefix(TimingPrefixedSeconds *p_prefix, double seconds, char prefix)
Computes the value for the time unit based on a specified prefix.
int32_t setReportHeader(void *p_report, const char *new_header)
int32_t appendReportFooter(void *p_report, const char *new_footer, int32_t new_line)
Appends text to existing footer.
uint64_t getEventTypeHeader(void *p_report, uint32_t event_type_id, char *event_type_header, uint64_t size)
uint64_t getEventCount(void *p_report)
int32_t getEvent(void *p_report, TimingReportEventC *p_event, uint64_t index)
getEvent
int32_t convert2CSV(void *p_report, char **pp_csv_content)
convert2CSV
int32_t setEventCapacity(void *p_report, uint64_t new_capacity)
setEventCapacity
int32_t clearEvents(void *p_report)
int32_t prependReportFooter(void *p_report, const char *new_footer, int32_t new_line)
Prepends text to existing footer.
int32_t computeTimingPrefix(TimingPrefixedSeconds *p_prefix, double seconds)
Retrieves the prefix for the time unit.