DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ers::Context Class Referenceabstract

An abstract interface to access an Issue context. More...

#include <Context.hpp>

Inheritance diagram for ers::Context:
[legend]

Public Member Functions

virtual ~Context ()
std::string position (int verbosity=ers::Configuration::instance().verbosity_level()) const
std::vector< std::string > stack () const
virtual Context * clone () const =0
virtual const char * cwd () const =0
virtual const char * file_name () const =0
virtual const char * function_name () const =0
virtual const char * host_name () const =0
virtual int line_number () const =0
virtual const char * package_name () const =0
virtual pid_t process_id () const =0
virtual pid_t thread_id () const =0
virtual void *const * stack_symbols () const =0
virtual int stack_size () const =0
virtual int user_id () const =0
virtual const char * user_name () const =0
virtual const char * application_name () const =0

Detailed Description

An abstract interface to access an Issue context.

This class provides an abstract interface to access the context of an issue.

Author
Serguei Kolos

Definition at line 39 of file Context.hpp.

Constructor & Destructor Documentation

◆ ~Context()

virtual ers::Context::~Context ( )
inlinevirtual

Definition at line 42 of file Context.hpp.

42{ ; }

Member Function Documentation

◆ application_name()

virtual const char * ers::Context::application_name ( ) const
pure virtual
Returns
application name

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ clone()

virtual Context * ers::Context::clone ( ) const
pure virtual
Returns
copy of the current context

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ cwd()

virtual const char * ers::Context::cwd ( ) const
pure virtual
Returns
current working directory of the process

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ file_name()

virtual const char * ers::Context::file_name ( ) const
pure virtual
Returns
name of the file which created the issue

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ function_name()

virtual const char * ers::Context::function_name ( ) const
pure virtual
Returns
name of the function which created the issue

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ host_name()

virtual const char * ers::Context::host_name ( ) const
pure virtual
Returns
host where the process is running

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ line_number()

virtual int ers::Context::line_number ( ) const
pure virtual
Returns
line number, in which the issue has been created

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ package_name()

virtual const char * ers::Context::package_name ( ) const
pure virtual
Returns
CMT package name

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ position()

std::string ers::Context::position ( int verbosity = ers::Configuration::instance().verbosity_level()) const
Returns
position in the code

Pretty printed code position format: package_name/file_name:line_number <function_name>

Returns
reference to string containing format

Definition at line 114 of file Context.cpp.

115{
116 std::ostringstream out;
117 print_function(out, function_name(), verbosity);
118 out << " at ";
119
120 const char* file = file_name();
121 if (file[0] == '.' && file[1] == '.' && file[2] == '/') // file name starts with "../"
122 {
123 out << package_name() << (file + 2);
124 } else {
125 out << file;
126 }
127 out << ":" << line_number();
128 return out.str();
129}
virtual int line_number() const =0
virtual const char * package_name() const =0
virtual const char * file_name() const =0
virtual const char * function_name() const =0
FELIX Initialization std::string initerror FELIX queue timed out

◆ process_id()

virtual pid_t ers::Context::process_id ( ) const
pure virtual
Returns
process id

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ stack()

std::vector< std::string > ers::Context::stack ( ) const
Returns
stack frames vector

Definition at line 93 of file Context.cpp.

94{
95 std::vector<std::string> stack;
96 stack.reserve(stack_size());
97 char** symbols = backtrace_symbols((void**)stack_symbols(), stack_size());
98
99 if (symbols) {
100 for (int i = 1; i < stack_size(); i++) {
101 stack.push_back(demangle(symbols[i]));
102 }
103 free(symbols);
104 }
105
106 return stack;
107}
virtual void *const * stack_symbols() const =0
virtual int stack_size() const =0
std::vector< std::string > stack() const
Definition Context.cpp:93

◆ stack_size()

virtual int ers::Context::stack_size ( ) const
pure virtual
Returns
number of frames in stack

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ stack_symbols()

virtual void *const * ers::Context::stack_symbols ( ) const
pure virtual
Returns
stack frames

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ thread_id()

virtual pid_t ers::Context::thread_id ( ) const
pure virtual
Returns
thread id

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ user_id()

virtual int ers::Context::user_id ( ) const
pure virtual
Returns
user id

Implemented in ers::LocalContext, and ers::RemoteContext.

◆ user_name()

virtual const char * ers::Context::user_name ( ) const
pure virtual
Returns
user name

Implemented in ers::LocalContext, and ers::RemoteContext.


The documentation for this class was generated from the following files: