HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_UniversalLogSource.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_UniversalLogSource.h ( FS Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UT_UniversalLogSource__
13 #define __UT_UniversalLogSource__
14 
15 #include "UT_API.h"
16 #include "UT_Lock.h"
17 #include "UT_StringArray.h"
18 #include "UT_StringHolder.h"
19 #include "UT_UniversalLogEntry.h"
20 #include <functional>
21 
24 
25 typedef std::function<UT_UniversalLogSource *()>
27 
28 /// Use this macro to register a log source class so it can be created by
29 /// and attached to a log sink object.
30 #define UT_REGISTERUNIVERSALLOGSOURCE(source_class) \
31  static UT_UniversalLogSourceRegistration theReg##source_class( \
32  source_class::staticName(), \
33  [] () { return new source_class(); })
34 
35 /// This class performs the registration of a log source class. It also holds
36 /// the static map of instantiated source objects.
38 {
39 public:
41  const UT_StringHolder &source_name,
44 
45  static bool connect(const UT_StringHolder &source_name,
47  static bool disconnect(const UT_StringHolder &source_name,
48  UT_UniversalLogSink *sink);
49 
50  static void getSourceNames(UT_StringArray &source_names);
51  static bool isSourceName(const UT_StringRef &source_name);
52  static UT_UniversalLogSource *getSource(const UT_StringRef &source_name);
53 };
54 
55 /// This class represents a logging data source. Each source is a singleton
56 /// created by the registration code the first time a sink asks to connect
57 /// to it. The Source is destroyed when the last sink disconnects from it.
58 /// The source's connection to its sinks is maintained by the base class, so
59 /// source subclasses simply need to call sendToSinks when they have a log
60 /// entry to broadcast.
62 {
63 public:
64  /// Sends a message to our associated log sinks.
65  void sendToSinks(const UT_UniversalLogEntry &entry);
66 
67 protected:
69  virtual ~UT_UniversalLogSource();
70 
73 
75 };
76 
77 #endif
int getSource() override
#define UT_API
Definition: UT_API.h:14
GLsizei GLenum GLboolean sink
Definition: glew.h:4996
std::function< UT_UniversalLogSource *()> UT_UniversalLogSourceCreator
UT_Array< UT_UniversalLogSink * > mySinks
Simple object to hold the data associated with a single log entry event.