Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/dconfig/notifyCategory.h

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

Generated on Thu May 1 22:12:57 2003 for DTool by doxygen1.3