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