DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
LocalContext.hpp
Go to the documentation of this file.
1/*
2 * DUNE DAQ modification notice:
3 * This file has been modified from the original ATLAS ers source for the DUNE DAQ project.
4 * Fork baseline commit: 8267df82a4f6fe6bf02c4014923eba19eddc4614 (2020-04-14).
5 * Renamed since fork: yes (from ers/LocalContext.h to include/ers/LocalContext.hpp).
6 *
7 * Original copyright:
8 * Copyright (C) 2001-2020 CERN for the benefit of the ATLAS collaboration.
9 * Licensed under the Apache License, Version 2.0.
10 */
11
12/*
13 * LocalContext.h
14 * ers
15 *
16 * Created by Serguei Kolos on 26.11.05.
17 * Copyright 2004 CERN. All rights reserved.
18 *
19 */
20
21#ifndef ERS_LOCAL_CONTEXT_H
22#define ERS_LOCAL_CONTEXT_H
23
28
29#include <sys/types.h>
30#include <unistd.h>
31
32#include <ers/Context.hpp>
33
34#ifdef DUNEDAQ_PACKAGE_NAME
35#define ERS_PACKAGE DUNEDAQ_PACKAGE_NAME
36#else
37#define ERS_PACKAGE "unknown"
38#endif
39
40namespace ers
41{
43 {
44 LocalProcessContext( const char * const host_name,
45 const char * const cwd,
46 int uid,
47 const char * const uname )
48 : m_host_name( host_name ),
49 m_cwd( cwd ),
50 m_uid( uid ),
51 m_uname( uname )
52 { ; }
53
54 const char * const m_host_name;
55 const char * const m_cwd;
56 const int m_uid;
57 const char * const m_uname;
58 };
59
60 class LocalContext : public Context
61 {
62 public:
63
71 LocalContext( const char * package_name,
72 const char * filename,
73 int line_number,
74 const char * function_name,
75 bool debug = false);
76
77 virtual ~LocalContext()
78 { ; }
79
80 virtual Context * clone() const
81 { return new LocalContext( *this ); }
82
83 const char * cwd() const
84 { return c_process.m_cwd; }
85
86 const char * file_name() const
87 { return m_file_name; }
88
89 const char * function_name() const
90 { return m_function_name; }
91
92 const char * host_name() const
93 { return c_process.m_host_name; }
94
95 int line_number() const
96 { return m_line_number; }
97
98 const char * package_name() const
99 { return m_package_name; }
100
101 pid_t process_id() const
102 { return ::getpid(); }
103
104 pid_t thread_id() const
105 { return m_thread_id; }
106
107 void * const * stack_symbols() const
108 { return m_stack; }
109
110 int stack_size() const
111 { return m_stack_size; }
112
113 int user_id() const
114 { return c_process.m_uid; }
115
116 const char * user_name() const
117 { return c_process.m_uname; }
118
119 const char * application_name() const;
120
121 static void resetProcessContext();
122
123 private:
125
126 const char * const m_package_name;
127 const char * const m_file_name;
128 const char * const m_function_name;
129 const int m_line_number;
130 const pid_t m_thread_id;
131 void * m_stack[64];
132 const int m_stack_size;
133 };
134}
135
138#define ERS_HERE_DEBUG ers::LocalContext( ERS_PACKAGE, __FILE__, __LINE__, __PRETTY_FUNCTION__, true )
139
140#ifndef ERS_NO_DEBUG
141#define ERS_HERE ERS_HERE_DEBUG
142#else
143#define ERS_HERE ers::LocalContext( ERS_PACKAGE, __FILE__, __LINE__, __PRETTY_FUNCTION__, false)
144#endif
145
146#endif
147
An abstract interface to access an Issue context.
Definition Context.hpp:41
const char * application_name() const
const char * function_name() const
int line_number() const
const char *const m_file_name
const char * user_name() const
int stack_size() const
const char * host_name() const
const char * file_name() const
virtual ~LocalContext()
pid_t process_id() const
const char *const m_function_name
const char * package_name() const
virtual Context * clone() const
pid_t thread_id() const
LocalContext(const char *package_name, const char *filename, int line_number, const char *function_name, bool debug=false)
const pid_t m_thread_id
const char * cwd() const
static void resetProcessContext()
static const LocalProcessContext c_process
const char *const m_package_name
void *const * stack_symbols() const
void debug(const Issue &issue, int level=debug_level())
Definition ers.hpp:85
const char *const m_cwd
const char *const m_host_name
const char *const m_uname
LocalProcessContext(const char *const host_name, const char *const cwd, int uid, const char *const uname)