Panda3D
 All Classes Functions Variables Enumerations
notifyCategory.h
1 // Filename: notifyCategory.h
2 // Created by: drose (29Feb00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef NOTIFYCATEGORY_H
16 #define NOTIFYCATEGORY_H
17 
18 #include "dtoolbase.h"
19 
20 #include "notifySeverity.h"
21 #include "configVariableEnum.h"
22 #include "configFlags.h"
23 #include "memoryBase.h"
24 
25 #include <vector>
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : NotifyCategory
29 // Description : A particular category of error messages. Typically
30 // there will be one of these per package, so that we
31 // can turn on or off error messages at least at a
32 // package level; further nested categories can be
33 // created within a package if a finer grain of control
34 // is required.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_DTOOLCONFIG NotifyCategory : public MemoryBase, public ConfigFlags {
37 private:
38  NotifyCategory(const string &fullname, const string &basename,
39  NotifyCategory *parent);
40 
41 PUBLISHED:
42  INLINE string get_fullname() const;
43  INLINE string get_basename() const;
44  INLINE NotifySeverity get_severity() const;
45  INLINE void set_severity(NotifySeverity severity);
46 
47  INLINE bool is_on(NotifySeverity severity) const;
48 
49  // When NOTIFY_DEBUG is not defined, the categories will never be
50  // set to "spam" or "debug" severities, and these methods are
51  // redefined to be static to make it more obvious to the compiler.
52  // However, we still want to present a consistent interface to our
53  // scripting language, so during the interrogate pass (that is, when
54  // CPPPARSER is defined), we still pretend they're nonstatic.
55 #if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
56  INLINE bool is_spam() const;
57  INLINE bool is_debug() const;
58 #else
59  CONSTEXPR static bool is_spam();
60  CONSTEXPR static bool is_debug();
61 #endif
62  INLINE bool is_info() const;
63  INLINE bool is_warning() const;
64  INLINE bool is_error() const;
65  INLINE bool is_fatal() const;
66 
67  ostream &out(NotifySeverity severity, bool prefix = true) const;
68  INLINE ostream &spam(bool prefix = true) const;
69  INLINE ostream &debug(bool prefix = true) const;
70  INLINE ostream &info(bool prefix = true) const;
71  INLINE ostream &warning(bool prefix = true) const;
72  INLINE ostream &error(bool prefix = true) const;
73  INLINE ostream &fatal(bool prefix = true) const;
74 
75  int get_num_children() const;
76  NotifyCategory *get_child(int i) const;
77 
78  static void set_server_delta(long delta);
79 
80 private:
81  string get_config_name() const;
82  void update_severity_cache();
83  static bool get_notify_timestamp();
84  static bool get_check_debug_notify_protect();
85 
86  string _fullname;
87  string _basename;
88  NotifyCategory *_parent;
90  typedef vector<NotifyCategory *> Children;
91  Children _children;
92 
93  static long _server_delta; // not a time_t because server delta may be signed.
94 
95  AtomicAdjust::Integer _local_modified;
96  NotifySeverity _severity_cache;
97 
98  friend class Notify;
99 };
100 
101 INLINE ostream &operator << (ostream &out, const NotifyCategory &cat);
102 
103 #include "notifyCategory.I"
104 
105 #endif
static ostream & out()
A convenient way to get the ostream that should be written to for a Notify-type message.
Definition: notify.cxx:301
A particular category of error messages.
This class is the base class of both ConfigVariable and ConfigVariableCore.
Definition: configFlags.h:29
This class is intended to be the base class of all objects in Panda that might be allocated and delet...
Definition: memoryBase.h:73
An object that handles general error reporting to the user.
Definition: pnotify.h:38