EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
locationException.h
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * SPDX-License-Identifier: EPICS
7 * EPICS Base is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 
11 //
12 // Author: Jeff Hill
13 //
14 
15 #ifndef locationException_h
16 #define locationException_h
17 
18 #include <stdio.h>
19 
20 #include "cantProceed.h"
21 #include "errlog.h"
22 
23 template <class T>
24 class sourceFileLocation : public T {
25 public:
26  sourceFileLocation (const T &parm, const char *fileName, unsigned lineNumber);
28  sourceFileLocation & operator = ( const sourceFileLocation & );
29  const char *fileName () const;
30  unsigned lineNumber () const;
31 private:
32  const char *pFileName;
33  unsigned lineNumberCopy;
34 };
35 
36 template <class T>
37 inline sourceFileLocation<T>::sourceFileLocation (const T &parm, const char *fileName, unsigned lineNumber) :
38  T ( parm ), pFileName ( fileName ) , lineNumberCopy ( lineNumber ) {}
39 
40 template <class T>
42  T ( in ), pFileName ( in.pFileName ), lineNumberCopy ( in.lineNumberCopy )
43 {
44 }
45 
46 template < class T >
48 {
49  this->pFileName = in.pFileName;
50  this->lineNumberCopy = in.lineNumberCopy;
51  return *this;
52 }
53 
54 template < class T >
55 inline unsigned sourceFileLocation<T>::lineNumber () const
56 {
57  return this->lineNumberCopy;
58 }
59 
60 template <class T>
61 inline const char * sourceFileLocation<T>::fileName () const
62 {
63  return this->pFileName;
64 }
65 
66 #define throwWithLocation(parm) throwExceptionWithLocation (parm, __FILE__, __LINE__);
67 
68 template <class T>
69 inline void throwExceptionWithLocation (const T &parm, const char *pFileName, unsigned lineNo)
70 {
71  throw sourceFileLocation<T> (parm, pFileName, lineNo);
72 }
73 
74 #endif // ifdef locationException_h
75 
Functions for interacting with the errlog task.
Routines for code that can&#39;t continue or return after an error.