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 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 
25 #ifndef PXR_BASE_TRACE_REPORTER_BASE_H
26 #define PXR_BASE_TRACE_REPORTER_BASE_H
27 
28 #include "pxr/pxr.h"
29 
30 #include "pxr/base/trace/api.h"
34 
36 
37 #include <tbb/concurrent_vector.h>
38 
39 #include <ostream>
40 
42 
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// \class TraceReporterBase
47 ///
48 /// This class is a base class for report implementations. It handles receiving
49 /// and processing of TraceCollections.
50 ///
51 ///
53  public TfRefBase, public TfWeakBase {
54 public:
56  using ThisPtr = TraceReporterBasePtr;
57  using ThisRefPtr = TraceReporterBaseRefPtr;
58  using CollectionPtr = std::shared_ptr<TraceCollection>;
59  using DataSourcePtr = std::unique_ptr<TraceReporterDataSourceBase>;
60 
61  /// Constructor taking ownership of \p dataSource.
63 
64  /// Destructor.
65  TRACE_API virtual ~TraceReporterBase();
66 
67  /// Write all collections that were processed by this reporter to \p ostr.
68  TRACE_API bool SerializeProcessedCollections(std::ostream& ostr) const;
69 protected:
70  /// Removes all references to TraceCollections.
71  TRACE_API void _Clear();
72 
73  /// Gets the latest data from the TraceCollector singleton and processes all
74  /// collections that have been received since the last call to _Update().
75  TRACE_API void _Update();
76 
77  /// Called once per collection from _Update()
78  virtual void _ProcessCollection(const CollectionPtr&) = 0;
79 
80 private:
81  DataSourcePtr _dataSource;
82  tbb::concurrent_vector<CollectionPtr> _processedCollections;
83 };
84 
86 
87 #endif // PXR_BASE_TRACE_REPORTER_BASE_H
std::unique_ptr< TraceReporterDataSourceBase > DataSourcePtr
Definition: reporterBase.h:59
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:58
TraceReporterBaseRefPtr ThisRefPtr
Definition: reporterBase.h:57
TRACE_API TraceReporterBase(DataSourcePtr dataSource)
Constructor taking ownership of dataSource.
TraceReporterBasePtr ThisPtr
Definition: reporterBase.h:56
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
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:40