Loading...
Searching...
No Matches
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
41PXR_NAMESPACE_OPEN_SCOPE
42
44
53 public TfRefBase, public TfWeakBase {
54public:
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;
69protected:
71 TRACE_API void _Clear();
72
75 TRACE_API void _Update();
76
78 virtual void _ProcessCollection(const CollectionPtr&) = 0;
79
80private:
81 DataSourcePtr _dataSource;
82 tbb::concurrent_vector<CollectionPtr> _processedCollections;
83};
84
85PXR_NAMESPACE_CLOSE_SCOPE
86
87#endif // PXR_BASE_TRACE_REPORTER_BASE_H
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:73
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141
This class is a base class for report implementations.
Definition: reporterBase.h:53
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 TraceReporterBase(DataSourcePtr dataSource)
Constructor taking ownership of dataSource.
virtual void _ProcessCollection(const CollectionPtr &)=0
Called once per collection from _Update()
TRACE_API void _Clear()
Removes all references to TraceCollections.
TRACE_API bool SerializeProcessedCollections(std::ostream &ostr) const
Write all collections that were processed by this reporter to ostr.
Standard pointer typedefs.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89