HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
coalescingDiagnosticDelegate.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_USD_UTILS_COALESCING_DIAGNOSTIC_DELEGATE_H
25 #define PXR_USD_USD_UTILS_COALESCING_DIAGNOSTIC_DELEGATE_H
26 
27 /// \file usdUtils/coalescingDiagnosticDelegate.h
28 ///
29 /// A class which provides aggregation of warnings and statuses
30 /// emitted from Tf's diagnostic management system. These diagnostic
31 /// notifications can be coalesced by invocation point,
32 /// currently defined as the source file, line number and function name,
33 /// to recieve a more concise output.
34 
35 #include "pxr/pxr.h"
36 #include "pxr/usd/usdUtils/api.h"
38 
39 #include <ostream>
40 #include <memory>
41 #include <string>
42 #include <vector>
43 
44 #include <tbb/concurrent_queue.h>
45 
47 
48 /// The shared component in a coalesced result
49 /// This type can be thought of as the key by which we
50 /// coalesce our diagnostics.
55 };
56 
57 /// The unshared component in a coalesced result
61 };
62 
63 /// An item used in coalesced results, containing a shared component:
64 /// the file/function/line number, and a set of unshared components: the
65 /// call context and commentary.
68  std::vector<UsdUtilsCoalescingDiagnosticDelegateUnsharedItem> unsharedItems;
69 };
70 
71 /// A vector of coalesced results, each containing a shared component,
72 /// the file/function/line number, and a set of unshared components, the
73 /// call context and commentary.
74 typedef std::vector<UsdUtilsCoalescingDiagnosticDelegateItem>
76 
77 /// A class which collects warnings and statuses from the
78 /// Tf diagnostic manager system in a thread safe manner.
79 ///
80 /// This class allows clients to get both the unfiltered
81 /// results, as well as a compressed view which deduplicates
82 /// diagnostic events by their source line number, function and file
83 /// from which they occurred.
85 public:
88 
91 
92  /// Methods that implement the interface provided in TfDiagnosticMgr::Delegate
93 
95  virtual void IssueError(const TfError&) override;
96 
98  virtual void IssueStatus(const TfStatus&) override;
99 
101  virtual void IssueWarning(const TfWarning&) override;
102 
104  virtual void IssueFatalError(const TfCallContext&, const std::string &) override;
105 
106  // Methods that provide collection of diagnostics as well as sending
107  // them to a stream(stderr, stdout, a file, etc).
108 
109  /// Print all pending diagnostics in a coalesced form to \p ostr
110  /// \note This method clears the pending diagnostics.
112  void DumpCoalescedDiagnostics(std::ostream& ostr);
113 
114  /// Print all pending diagnostics without any coalescing to \p ostr
115  /// \note This method clears the pending diagnostics.
117  void DumpUncoalescedDiagnostics(std::ostream& ostr);
118 
119  /// Get all pending diagnostics in a coalesced form.
120  /// \note This method clears the pending diagnostics.
123 
124  /// Get all pending diagnostics without any coalescing.
125  /// \note This method clears the pending diagnostics.
127  std::vector<std::unique_ptr<TfDiagnosticBase>> TakeUncoalescedDiagnostics();
128 
129 private:
130  tbb::concurrent_queue<TfDiagnosticBase*> _diagnostics;
131 };
132 
134 
135 #endif // PXR_USD_USD_UTILS_COALESCING_DIAGNOSTIC_DELEGATE_H
The unshared component in a coalesced result.
virtual USDUTILS_API void IssueFatalError(const TfCallContext &, const std::string &) override
virtual USDUTILS_API ~UsdUtilsCoalescingDiagnosticDelegate()
std::vector< UsdUtilsCoalescingDiagnosticDelegateUnsharedItem > unsharedItems
USDUTILS_API void DumpUncoalescedDiagnostics(std::ostream &ostr)
virtual USDUTILS_API void IssueStatus(const TfStatus &) override
Called when a TF_STATUS() is issued.
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
virtual USDUTILS_API void IssueError(const TfError &) override
Methods that implement the interface provided in TfDiagnosticMgr::Delegate.
USDUTILS_API std::vector< std::unique_ptr< TfDiagnosticBase > > TakeUncoalescedDiagnostics()
UsdUtilsCoalescingDiagnosticDelegateSharedItem sharedItem
Definition: error.h:49
USDUTILS_API UsdUtilsCoalescingDiagnosticDelegateVector TakeCoalescedDiagnostics()
virtual USDUTILS_API void IssueWarning(const TfWarning &) override
Called when a TF_WARNING() is issued.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
std::vector< UsdUtilsCoalescingDiagnosticDelegateItem > UsdUtilsCoalescingDiagnosticDelegateVector
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
USDUTILS_API void DumpCoalescedDiagnostics(std::ostream &ostr)
#define USDUTILS_API
Definition: api.h:40
USDUTILS_API UsdUtilsCoalescingDiagnosticDelegate()