All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
reporterBase.h
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"
31 #include "pxr/base/trace/collectionNotice.h"
32 #include "pxr/base/trace/collection.h"
33 #include "pxr/base/trace/reporterDataSourceBase.h"
34 
36 
37 #include <tbb/concurrent_vector.h>
38 
39 #include <ostream>
40 
41 PXR_NAMESPACE_OPEN_SCOPE
42 
44 
53  public TfRefBase, public TfWeakBase {
54 public:
55  using This = TraceReporterBase;
56  using ThisPtr = TraceReporterBasePtr;
57  using ThisRefPtr = TraceReporterBaseRefPtr;
58  using CollectionPtr = std::shared_ptr<TraceCollection>;
59  using DataSourcePtr = std::unique_ptr<TraceReporterDataSourceBase>;
60 
62  TRACE_API TraceReporterBase(DataSourcePtr dataSource);
63 
65  TRACE_API virtual ~TraceReporterBase();
66 
68  TRACE_API bool SerializeProcessedCollections(std::ostream& ostr) const;
69 protected:
71  TRACE_API void _Clear();
72 
75  TRACE_API void _Update();
76 
78  virtual void _ProcessCollection(const CollectionPtr&) = 0;
79 
80 private:
81  DataSourcePtr _dataSource;
82  tbb::concurrent_vector<CollectionPtr> _processedCollections;
83 };
84 
85 PXR_NAMESPACE_CLOSE_SCOPE
86 
87 #endif // PXR_BASE_TRACE_REPORTER_BASE_H
Standard pointer typedefs.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
This class is a base class for report implementations.
Definition: reporterBase.h:52
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:71
virtual void _ProcessCollection(const CollectionPtr &)=0
Called once per collection from _Update()
TRACE_API TraceReporterBase(DataSourcePtr dataSource)
Constructor taking ownership of dataSource.
TRACE_API void _Update()
Gets the latest data from the TraceCollector singleton and processes all collections that have been r...
virtual TRACE_API ~TraceReporterBase()
Destructor.
TRACE_API bool SerializeProcessedCollections(std::ostream &ostr) const
Write all collections that were processed by this reporter to ostr.
TRACE_API void _Clear()
Removes all references to TraceCollections.
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141