Loading...
Searching...
No Matches
reporterDataSourceCollector.h
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_DATA_SOURCE_COLLECTOR_H
9#define PXR_BASE_TRACE_REPORTER_DATA_SOURCE_COLLECTOR_H
10
11#include "pxr/pxr.h"
12
13#include "pxr/base/trace/api.h"
14#include "pxr/base/trace/collection.h"
15#include "pxr/base/trace/collectionNotice.h"
16#include "pxr/base/trace/reporterDataSourceBase.h"
17
19
20#include <tbb/concurrent_queue.h>
21
22#include <vector>
23
24PXR_NAMESPACE_OPEN_SCOPE
25
27
36public:
38 using ThisPtr = TraceReporterDataSourceCollectorPtr;
39 using ThisRefPtr = std::unique_ptr<This>;
40
42 static ThisRefPtr New() {
43 return ThisRefPtr(new This());
44 }
45
49 static ThisRefPtr New(std::function<bool()> accept) {
50 return ThisRefPtr(new This(std::move(accept)));
51 }
52
54 TRACE_API void Clear() override;
55
57 TRACE_API std::vector<CollectionPtr> ConsumeData() override;
58
59private:
61 TRACE_API TraceReporterDataSourceCollector(std::function<bool()> accept);
62
63 // Add the new collection to the pending queue.
64 void _OnTraceCollection(const TraceCollectionAvailable&);
65
66 std::function<bool()> _accept;
67 tbb::concurrent_queue<CollectionPtr> _pendingCollections;
68};
69
70PXR_NAMESPACE_CLOSE_SCOPE
71
72#endif // PXR_BASE_TRACE_REPORTER_DATA_SOURCE_COLLECTOR_H
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:124
A TfNotice that is sent when the TraceCollector creates a TraceCollection.
This class is a base class for TraceReporterBase data sources.
This class is an implementation of TraceReporterDataSourceBase which retrieves TraceCollections from ...
TRACE_API std::vector< CollectionPtr > ConsumeData() override
Returns the next TraceCollections which need to be processed.
static ThisRefPtr New()
Creates a new TraceReporterDataSourceCollector.
TRACE_API void Clear() override
Removes all references to TraceCollections.
static ThisRefPtr New(std::function< bool()> accept)
Creates a new TraceReporterDataSourceCollector which will only listen to the TraceCollectionAvailable...
Standard pointer typedefs.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:45