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 Contextclone () 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 29 of file Context.hpp.

Constructor & Destructor Documentation

◆ ~Context()

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

Definition at line 33 of file Context.hpp.

33{ ; }

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 105 of file Context.cpp.

106{
107 std::ostringstream out;
108 print_function( out, function_name(), verbosity );
109 out << " at ";
110
111 const char * file = file_name();
112 if ( file[0] == '.'
113 && file[1] == '.'
114 && file[2] == '/' ) // file name starts with "../"
115 {
116 out << package_name() << (file + 2);
117 } else {
118 out << file;
119 }
120 out << ":" << line_number();
121 return out.str();
122}
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 84 of file Context.cpp.

85{
86 std::vector<std::string> stack;
87 stack.reserve( stack_size() );
88 char ** symbols = backtrace_symbols( (void**)stack_symbols(), stack_size() );
89
90 if (symbols) {
91 for (int i = 1; i < stack_size(); i++) {
92 stack.push_back( demangle(symbols[i]) );
93 }
94 free(symbols);
95 }
96
97 return stack;
98}
virtual void *const * stack_symbols() const =0
virtual int stack_size() const =0
std::vector< std::string > stack() const
Definition Context.cpp:84

◆ 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: