HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_UniversalLogInMemorySink.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_UniversalLogInMemorySink.h ( FS Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UT_UniversalLogInMemorySink__
13 #define __UT_UniversalLogInMemorySink__
14 
15 #include "UT_API.h"
16 #include "UT_Lock.h"
17 #include "UT_SharedPtr.h"
18 #include "UT_UniversalLogEntry.h"
19 #include "UT_UniversalLogSink.h"
21 #include <SYS/SYS_Types.h>
22 #include <SYS/SYS_AtomicInt.h>
23 
24 class UT_StringRef;
25 
26 /// This class is a universal log sync which stores all log entries in memory.
27 /// A maximum memory use threshold can be set, and excess messages are
28 /// automatically deleted.
30 {
31 public:
33  ~UT_UniversalLogInMemorySink() override;
34 
35  /// Returns the number of log entries currently in memory. An entry may
36  /// become "inactive" (i.e. flushed from memory) when this sink reaches
37  /// its maximum log count, or if someone steals our log entries.
38  exint activeLogCount();
39  /// Returns the number of log entries we have ever seen. It can be useful
40  /// to have this monotonically increasing number to look for changes and
41  /// insulate from the automated (or manual) purging of log entries.
42  exint allTimeLogCount();
43  /// Returns a copy of the log entry at a specific all-time index. If the
44  /// index is out of range, or is no longer active, an empty log entry is
45  /// returned.
46  UT_UniversalLogEntry allTimeLogEntry(exint all_time_idx);
47  /// Steals all current log entries into the supplied array. This object
48  /// will no longer have any record of these log entries after this call.
49  void stealLogEntries(UT_UniversalLogEntryArray &log);
50 
51 protected:
52  /// This override stores the log messages in memory.
53  void doLog(const UT_UniversalLogEntry &entry) override;
54 
55  /// Grab messages from the inbound log entries and add them to the
56  /// inspectable log entries. This function also enforces the maximum
57  /// total message size.
58  ///
59  /// NOTE: myDataLock MUST be locked before calling this method.
60  void adoptInboundLogEntries();
61 
62  /// The inbound message queue is where events get logged, but messages
63  /// on this queue cannot be inspected. We never want the addition of
64  /// new messages to be blocked by some (potentially slow) inspection of
65  /// the current set of messages.
69  /// These log entries are the ones that have been collected from the
70  /// inbound queue. And filtering and sorting happens during this
71  /// transition.
76  /// A counter that is increased any time a message is added.
78 };
79 
80 #endif
81 
int64 exint
Definition: SYS_Types.h:125
#define UT_API
Definition: UT_API.h:14
UT_UniversalLogEntryArray myLogEntries
SYS_AtomicCounter myAllTimeLogCount
A counter that is increased any time a message is added.
virtual void doLog(const UT_UniversalLogEntry &entry)=0
UT_UniversalLogEntryArray myInboundLogEntries
OIIO_FORCEINLINE T log(const T &v)
Definition: simd.h:7688
Simple object to hold the data associated with a single log entry event.