HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
reporterBase.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 
8 #ifndef PXR_BASE_TRACE_REPORTER_BASE_H
9 #define PXR_BASE_TRACE_REPORTER_BASE_H
10 
11 #include "pxr/pxr.h"
12 
13 #include "pxr/base/trace/api.h"
17 
19 
20 #include <tbb/concurrent_vector.h>
21 
22 #include <ostream>
23 
25 
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 /// \class TraceReporterBase
30 ///
31 /// This class is a base class for report implementations. It handles receiving
32 /// and processing of TraceCollections.
33 ///
34 ///
36  public TfRefBase, public TfWeakBase {
37 public:
39  using ThisPtr = TraceReporterBasePtr;
40  using ThisRefPtr = TraceReporterBaseRefPtr;
41  using CollectionPtr = std::shared_ptr<TraceCollection>;
42  using DataSourcePtr = std::unique_ptr<TraceReporterDataSourceBase>;
43 
44  /// Constructor taking ownership of \p dataSource.
46 
47  /// Destructor.
48  TRACE_API virtual ~TraceReporterBase();
49 
50  /// Write all collections that were processed by this reporter to \p ostr.
51  TRACE_API bool SerializeProcessedCollections(std::ostream& ostr) const;
52 protected:
53  /// Removes all references to TraceCollections.
54  TRACE_API void _Clear();
55 
56  /// Gets the latest data from the TraceCollector singleton and processes all
57  /// collections that have been received since the last call to _Update().
58  TRACE_API void _Update();
59 
60  /// Called once per collection from _Update()
61  virtual void _ProcessCollection(const CollectionPtr&) = 0;
62 
63 private:
64  DataSourcePtr _dataSource;
65  tbb::concurrent_vector<CollectionPtr> _processedCollections;
66 };
67 
69 
70 #endif // PXR_BASE_TRACE_REPORTER_BASE_H
std::unique_ptr< TraceReporterDataSourceBase > DataSourcePtr
Definition: reporterBase.h:42
virtual TRACE_API ~TraceReporterBase()
Destructor.
TRACE_API bool SerializeProcessedCollections(std::ostream &ostr) const
Write all collections that were processed by this reporter to ostr.
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_AND_REF_PTRS(TraceReporterBase)
std::shared_ptr< TraceCollection > CollectionPtr
Definition: reporterBase.h:41
TraceReporterBaseRefPtr ThisRefPtr
Definition: reporterBase.h:40
TRACE_API TraceReporterBase(DataSourcePtr dataSource)
Constructor taking ownership of dataSource.
TraceReporterBasePtr ThisPtr
Definition: reporterBase.h:39
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
virtual void _ProcessCollection(const CollectionPtr &)=0
Called once per collection from _Update()
TRACE_API void _Update()
TRACE_API void _Clear()
Removes all references to TraceCollections.
#define TRACE_API
Definition: api.h:23