NCBI C++ ToolKit
ncbi_toolkit.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef CORELIB___NCBI_TOOLKIT__HPP
2 #define CORELIB___NCBI_TOOLKIT__HPP
3 
4 /* $Id: ncbi_toolkit.hpp 50185 2011-06-23 16:58:27Z gouriano $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrei Gourianov, Denis Vakatov
30  *
31  *
32  */
33 
34 /// @file ncbi_toolkit.hpp
35 ///
36 /// This API provides an easy way to initialize NCBI C++ Toolkit internals
37 /// to use the Toolkit from other application frameworks.
38 ///
39 
40 /** @addtogroup AppFramework
41  *
42  * @{
43  */
44 
46 
47 namespace ncbi {
48 
49 
50 /////////////////////////////////////////////////////////////////////////////
51 ///
52 /// Initialialize NCBI C++ Toolkit internal infrastructure:
53 /// arguments, environment, diagnostics, logging
54 /// @note
55 /// This function may be called only once -- and, before calling any
56 /// other C++ Toolkit function.
57 ///
58 /// @param argc
59 /// Argument count [argc in a regular main(argc, argv)].
60 /// @param argv
61 /// Argument vector [argv in a regular main(argc, argv)].
62 /// @param envp
63 /// Environment pointer [envp in a regular main(argc, argv, envp)];
64 /// a null pointer (the default) corresponds to the standard system
65 /// array (environ on most Unix platforms).
66 /// @param log_handler
67 /// Handler for diagnostic messages that are emitted by the C++ Toolkit code
68 /// @sa
69 /// INcbiToolkit_LogHandler, NcbiToolkit_Fini
70 
72  (int argc,
73  const TNcbiToolkit_XChar* const* argv,
74  const TNcbiToolkit_XChar* const* envp = NULL,
75  INcbiToolkit_LogHandler* log_handler = NULL);
76 
77 
78 
79 /////////////////////////////////////////////////////////////////////////////
80 ///
81 /// Release resources allocated for NCBI C++ Toolkit
82 ///
83 /// @sa NcbiToolkit_Init
84 
86 
87 
88 
89 /////////////////////////////////////////////////////////////////////////////
90 ///
91 /// Logging message
92 ///
93 /// Diagnostic message that comes from the NCBI C++ Toolkit to the log handler
94 /// @sa
95 /// INcbiToolkit_LogHandler
96 
97 
99 {
100 public:
101  /// Log message severity
102  enum ESeverity {
103  eInfo = 0, ///< Informational message
104  eWarning, ///< Warning message
105  eError, ///< Error message
106  eCritical, ///< Critical error message
107  eFatal, ///< Fatal error
108  //
109  eTrace, ///< Trace message
110  };
111 
112  /// Get the message the way it is formatted by the Toolkit
113  operator std::string(void) const;
114 
115  /// Get text part of the message
116  std::string Message(void) const;
117 
118  /// Get message severity
119  ESeverity Severity(void) const;
120 
121  /// Get error code
122  int ErrCode(void) const;
123 
124  /// Get error subcode
125  int ErrSubCode(void) const;
126 
127  /// Get file name in which message was originated
128  std::string File(void) const;
129 
130  /// Get line number in which message was originated
131  size_t Line(void) const;
132 
133  /// Get all of the message's data -- as provided natively by the Toolkit
134  const SDiagMessage& GetNativeToolkitMessage(void) const;
135 
136 protected:
137  // this object is created and destroyed by the C++ Toolkit code only
139  virtual ~CNcbiToolkit_LogMessage(void);
140 private:
142  // prohibit copy ctor and assignment
145 };
146 
147 
148 
149 /////////////////////////////////////////////////////////////////////////////
150 ///
151 /// Logging interface
152 ///
153 /// Client application must provide implementation of this interface
154 /// and pass it to the Toolkit to receive diagnostic messages.
155 /// Message data is encapsulated into an CNcbiToolkit_LogMessage object.
156 /// @sa
157 /// CNcbiToolkit_LogMessage, NcbiToolkit_Init
158 
160 {
161 public:
163  virtual void Post(const CNcbiToolkit_LogMessage& msg) = 0;
164 };
165 
166 
167 } /* namespace ncbi */
168 
169 #endif /* CORELIB___NCBI_TOOLKIT__HPP */
Definition: svg.hpp:432
Severity –.
Definition: ncbidiag.hpp:833
CNcbiToolkit_LogMessage(const CNcbiToolkit_LogMessage &)
#define NCBI_TOOLKIT_EXPORT
void NcbiToolkit_Fini(void)
Release resources allocated for NCBI C++ Toolkit.
void NcbiToolkit_Init(int argc, const TNcbiToolkit_XChar *const *argv, const TNcbiToolkit_XChar *const *envp=NULL, INcbiToolkit_LogHandler *log_handler=NULL)
Initialialize NCBI C++ Toolkit internal infrastructure: arguments, environment, diagnostics,...
const SDiagMessage & m_Msg
virtual void Post(const CNcbiToolkit_LogMessage &msg)=0
char TNcbiToolkit_XChar
CNcbiToolkit_LogMessage & operator=(const CNcbiToolkit_LogMessage &)
ESeverity
Log message severity.
@ eCritical
Critical error message.
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define ErrCode()
Get the error code for the last failed system function.
Definition: mdb.c:377
Magic spell ;-) needed for some weird compilers... very empiric.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
SDiagMessage –.
Definition: ncbidiag.hpp:1599
Modified on Wed Sep 04 14:59:22 2024 by modify_doxy.py rev. 669887