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

Go to the SVN repository for this file.

1 
2 /* $Id: listener.hpp 89636 2020-04-13 12:14:53Z foleyjp $
3  * ===========================================================================
4  *
5  * PUBLIC DOMAIN NOTICE
6  * National Center for Biotechnology Information
7  *
8  * This software/database is a "United States Government Work" under the
9  * terms of the United States Copyright Act. It was written as part of
10  * the author's official duties as a United States Government employee and
11  * thus cannot be copyrighted. This software/database is freely available
12  * to the public for use. The National Library of Medicine and the U.S.
13  * Government have not placed any restriction on its use or reproduction.
14  *
15  * Although all reasonable efforts have been taken to ensure the accuracy
16  * and reliability of the software and data, the NLM and the U.S.
17  * Government do not and cannot warrant the performance or results that
18  * may be obtained by using this software or data. The NLM and the U.S.
19  * Government disclaim all warranties, express or implied, including
20  * warranties of performance, merchantability or fitness for any particular
21  * purpose.
22  *
23  * Please cite the author in any work or product based on this material.
24  *
25  * ===========================================================================
26  *
27  * Author: Justin Foley
28  *
29  * File Description:
30  * Objtools message listener classes - based on ILineErrorListener
31  *
32  */
33 
34 #ifndef _OBJTOOLS_LISTENER_HPP_
35 #define _OBJTOOLS_LISTENER_HPP_
36 
37 #include <corelib/ncbistd.hpp>
39 
42 
43 
44 // ============================================================================
46 // ============================================================================
47 {
48 public:
49  virtual ~IObjtoolsListener(void) = default;
50 
51  virtual bool SevEnabled(EDiagSev severity) const;
52 
53  virtual bool PutMessage(const IObjtoolsMessage& message) = 0;
54 };
55 
56 
57 // ============================================================================
59 // ============================================================================
60 {
61 protected:
62  using TMessages = vector<unique_ptr<IObjtoolsMessage>>;
63 private:
64  using TBaseIterator = TMessages::const_iterator;
65 
66 public:
67  CObjtoolsListener() = default;
68 
70 
72 
73  virtual ~CObjtoolsListener(void);
74 
75  virtual bool PutMessage(const IObjtoolsMessage& message);
76 
77  virtual void PutProgress(const string& message,
78  const Uint8 iNumDone,
79  const Uint8 iNumTotal);
80 
81  virtual const IObjtoolsMessage& GetMessage(size_t index) const;
82 
83  virtual size_t Count(void) const;
84 
85  virtual void ClearAll(void);
86 
87  virtual size_t LevelCount(EDiagSev severity) const;
88 
89  virtual void Dump(CNcbiOstream& ostr) const;
90 
91  virtual void DumpAsXML(CNcbiOstream& ostr) const;
92 
93  virtual void SetProgressOstream(CNcbiOstream* pProgressOstream);
94 
95  class CConstIterator : public TBaseIterator {
96  public:
97  using value_type = TBaseIterator::value_type::element_type;
98  using pointer = value_type*;
100 
101  CConstIterator(const TBaseIterator& base_it) : TBaseIterator(base_it) {}
102 
103  reference operator*() const { return *(this->TBaseIterator::operator*()); }
104  pointer operator->() const { return this->TBaseIterator::operator*().get(); }
105  };
106 
108  TConstIterator begin(void) const;
109  TConstIterator end(void) const;
110 protected:
112  CNcbiOstream* m_pProgressOstrm = nullptr;
113 };
114 
115 
116 // ============================================================================
118 // ============================================================================
119 {
120 public:
121  CObjtoolsListenerLevel(int accept_level);
122  virtual ~CObjtoolsListenerLevel(void);
123 
124  bool PutMessage(const IObjtoolsMessage& message) override;
125 private:
127 };
128 
129 
130 // =================================================================================
132 // =================================================================================
133 {
134 public:
136 };
137 
138 
139 // =================================================================================
141 // =================================================================================
142 {
143 public:
145 };
146 
149 
150 
151 #endif // _OBJTOOLS_LISTENER_HPP_
152 
virtual ~CObjtoolsListenerLevel(void)
CConstIterator(const TBaseIterator &base_it)
Definition: listener.hpp:101
TBaseIterator::value_type::element_type value_type
Definition: listener.hpp:97
TMessages m_Messages
Definition: listener.hpp:111
CObjtoolsListener()=default
vector< unique_ptr< IObjtoolsMessage > > TMessages
Definition: listener.hpp:62
CObjtoolsListener(const CObjtoolsListener &)=delete
virtual ~CObjtoolsListener(void)
TMessages::const_iterator TBaseIterator
Definition: listener.hpp:64
CObjtoolsListener & operator=(const CObjtoolsListener &)=delete
virtual ~IObjtoolsListener(void)=default
virtual bool PutMessage(const IObjtoolsMessage &message)=0
Include a standard set of the NCBI C++ Toolkit most basic headers.
EDiagSev
Severity level for the posted diagnostics.
Definition: ncbidiag.hpp:650
CVect2< NCBI_PROMOTE(int,U) > operator*(int v1, const CVect2< U > &v2)
Definition: globals.hpp:371
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
#define NCBI_XOBJUTIL_EXPORT
Definition: ncbi_export.h:1339
void Dump(CSplitCacheApp *app, const C &obj, ESerialDataFormat format, const string &key, const string &suffix=kEmptyStr)
Modified on Mon Mar 04 05:14:26 2024 by modify_doxy.py rev. 669887