AGX Dynamics  2.37.2.0
LoggerSubscriber.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 }
ERROR (highest) level.
Definition: Notify.h:70
AGXTERRAIN_EXPORT void clear()
INFO level.
Definition: Notify.h:68
std::pair< int, agx::String > Message
#define AGXPHYSICS_EXPORT
Base class providing referencing counted objects.
Definition: Referenced.h:119
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Class for polling messages from the LOGGER system in a Subscriber pattern.
Callback class, derive from this and Register to the notify singleton to get callbacks.
Definition: Notify.h:49
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agx::Vector< Message > MessageVector
WARNING level.
Definition: Notify.h:69
std::recursive_mutex ReentrantMutex
Definition: Object.h:48