AGXDynamics  2.35.0.3
LoggerSubscriber.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agx/Notify.h>
20 #include <deque>
21 
22 namespace agx {
23 
34  {
35  public:
36 
37  // agx::Notify::NOTIFY_DEBUG | agx::Notify::NOTIFY_INFO | agx::Notify::NOTIFY_WARNING | agx::Notify::NOTIFY_ERROR;
38  static int ALL_LEVELS;
39 
40 
47 
53  std::string pop(int levelMask = ALL_LEVELS);
54 
61  size_t pop(agx::StringVector& outMessages, int levelMask = ALL_LEVELS);
62 
67  bool empty(int levelMask = ALL_LEVELS) const;
68 
73  void clear(int levelMask = ALL_LEVELS);
74 
79  void setEnable(bool flag);
80 
84  bool getEnable() const;
85 
86 
87  typedef std::pair<int, agx::String> Message;
97  bool getMessages(MessageVector& messages, bool clearMessages, int levelMask = ALL_LEVELS);
98 
99  protected:
100 
104  void message(const agx::String& msg, int notifyLevel);
105 
107  virtual ~LoggerSubscriber();
108 
110  {
111  public:
112  LogCallback(LoggerSubscriber* subscriber);
113  ~LogCallback();
114 
115  protected:
117 
118  void message(const agx::String& msg, int notifyLevel) override;
119  };
120 
121  friend class LogCallback;
122 
123  private:
124  typedef std::deque<Message> MessageQueue;
125  MessageQueue m_messageQueue;
126 
127  agx::ref_ptr<LogCallback> m_callback;
128 
129  int m_levelMask;
130  bool m_enabled;
131  mutable agx::ReentrantMutex m_mutex;
132  };
133 }
agx::LoggerSubscriber::ALL_LEVELS
static int ALL_LEVELS
Definition: LoggerSubscriber.h:38
agx::Vector< AgXString< std::string > >
agx::LoggerSubscriber::Message
std::pair< int, agx::String > Message
Definition: LoggerSubscriber.h:87
agx::LoggerSubscriber
Class for polling messages from the LOGGER system in a Subscriber pattern.
Definition: LoggerSubscriber.h:33
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agx::NotifyCallback
Callback class, derive from this and Register to the notify singleton to get callbacks.
Definition: Notify.h:48
agx::LoggerSubscriber::LogCallback::m_subscriber
LoggerSubscriber * m_subscriber
Definition: LoggerSubscriber.h:116
agx::LoggerSubscriber::LogCallback
Definition: LoggerSubscriber.h:109
agx::LoggerSubscriber::MessageVector
agx::Vector< Message > MessageVector
Definition: LoggerSubscriber.h:88
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
agx::ReentrantMutex
std::recursive_mutex ReentrantMutex
Definition: Object.h:49
agx::Notify::NOTIFY_ERROR
@ NOTIFY_ERROR
ERROR (highest) level.
Definition: Notify.h:69
agx::AgXString< std::string >
agx::Notify::NOTIFY_INFO
@ NOTIFY_INFO
INFO level.
Definition: Notify.h:67
agxTerrain::Profiler::clear
AGXTERRAIN_EXPORT void clear()
Notify.h
agx::Notify::NOTIFY_WARNING
@ NOTIFY_WARNING
WARNING level.
Definition: Notify.h:68