Panda3D

notifyCategory.h

00001 // Filename: notifyCategory.h
00002 // Created by:  drose (29Feb00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef NOTIFYCATEGORY_H
00016 #define NOTIFYCATEGORY_H
00017 
00018 #include "dtoolbase.h"
00019 
00020 #include "notifySeverity.h"
00021 #include "configVariableEnum.h"
00022 #include "configFlags.h"
00023 #include "memoryBase.h"
00024 
00025 #include <vector>
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //       Class : NotifyCategory
00029 // Description : A particular category of error messages.  Typically
00030 //               there will be one of these per package, so that we
00031 //               can turn on or off error messages at least at a
00032 //               package level; further nested categories can be
00033 //               created within a package if a finer grain of control
00034 //               is required.
00035 ////////////////////////////////////////////////////////////////////
00036 class EXPCL_DTOOLCONFIG NotifyCategory : public MemoryBase, public ConfigFlags {
00037 private:
00038   NotifyCategory(const string &fullname, const string &basename,
00039                  NotifyCategory *parent);
00040 
00041 PUBLISHED:
00042   INLINE string get_fullname() const;
00043   INLINE string get_basename() const;
00044   INLINE NotifySeverity get_severity() const;
00045   INLINE void set_severity(NotifySeverity severity);
00046 
00047   INLINE bool is_on(NotifySeverity severity) const;
00048 
00049   // When NOTIFY_DEBUG is not defined, the categories will never be
00050   // set to "spam" or "debug" severities, and these methods are
00051   // redefined to be static to make it more obvious to the compiler.
00052   // However, we still want to present a consistent interface to our
00053   // scripting language, so during the interrogate pass (that is, when
00054   // CPPPARSER is defined), we still pretend they're nonstatic.
00055 #if defined(NOTIFY_DEBUG) || defined(CPPPARSER)
00056   INLINE bool is_spam() const;
00057   INLINE bool is_debug() const;
00058 #else
00059   INLINE static bool is_spam();
00060   INLINE static bool is_debug();
00061 #endif
00062   INLINE bool is_info() const;
00063   INLINE bool is_warning() const;
00064   INLINE bool is_error() const;
00065   INLINE bool is_fatal() const;
00066 
00067   ostream &out(NotifySeverity severity, bool prefix = true) const;
00068   INLINE ostream &spam(bool prefix = true) const;
00069   INLINE ostream &debug(bool prefix = true) const;
00070   INLINE ostream &info(bool prefix = true) const;
00071   INLINE ostream &warning(bool prefix = true) const;
00072   INLINE ostream &error(bool prefix = true) const;
00073   INLINE ostream &fatal(bool prefix = true) const;
00074 
00075   int get_num_children() const;
00076   NotifyCategory *get_child(int i) const;
00077 
00078   static void set_server_delta(long delta);
00079 
00080 private:
00081   string get_config_name() const;
00082   void update_severity_cache();
00083   static bool get_notify_timestamp();
00084   static bool get_check_debug_notify_protect();
00085 
00086   string _fullname;
00087   string _basename;
00088   NotifyCategory *_parent;
00089   ConfigVariableEnum<NotifySeverity> _severity;
00090   typedef vector<NotifyCategory *> Children;
00091   Children _children;
00092 
00093   static long _server_delta; // not a time_t because server delta may be signed.
00094 
00095   AtomicAdjust::Integer _local_modified;
00096   NotifySeverity _severity_cache;
00097 
00098   friend class Notify;
00099 };
00100 
00101 INLINE ostream &operator << (ostream &out, const NotifyCategory &cat);
00102 
00103 #include "notifyCategory.I"
00104 
00105 #endif
 All Classes Functions Variables Enumerations