Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
d107478789
3 changed files with 39 additions and 0 deletions
  1. 1 0
      dtool/src/dconfig/configTable.cxx
  2. 35 0
      dtool/src/dconfig/notify.cxx
  3. 3 0
      dtool/src/dconfig/notify.h

+ 1 - 0
dtool/src/dconfig/configTable.cxx

@@ -590,6 +590,7 @@ ConfigTable* ConfigTable::Instance(void) {
     _instance = new ConfigTable;
     _instance = new ConfigTable;
     _instance->GetData();
     _instance->GetData();
     _instance->_initializing = false;
     _instance->_initializing = false;
+    Notify::ptr()->config_initialized();
   }
   }
   return _instance;
   return _instance;
 }
 }

+ 35 - 0
dtool/src/dconfig/notify.cxx

@@ -7,6 +7,8 @@
 #include "config_notify.h"
 #include "config_notify.h"
 #include "dconfig.h"
 #include "dconfig.h"
 
 
+#include <filename.h>
+
 #include <ctype.h>
 #include <ctype.h>
 
 
 Notify *Notify::_global_ptr = (Notify *)NULL;
 Notify *Notify::_global_ptr = (Notify *)NULL;
@@ -436,3 +438,36 @@ string_severity(const string &str) {
     return NS_unspecified;
     return NS_unspecified;
   }
   }
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: Notify::config_initialized
+//       Access: Public
+//  Description: Intended to be called only by Config, this is a
+//               callback that indicated to Notify when Config has
+//               done initializing and Notify can safely set up some
+//               internal state variables that depend on Config
+//               variables.
+////////////////////////////////////////////////////////////////////
+void Notify::
+config_initialized() {
+  static bool already_initialized = false;
+  if (already_initialized) {
+    nout << "Notify::config_initialized() called more than once.\n";
+    return;
+  }
+  already_initialized = true;
+
+  if (_ostream_ptr == &cerr) {
+    Filename notify_output = config_notify.GetString("notify-output", "");
+    if (!notify_output.empty()) {
+      notify_output.set_text();
+      ofstream *out = new ofstream;
+      if (!notify_output.open_write(*out)) {
+	nout << "Unable to open file " << notify_output << " for output.\n";
+	delete out;
+      } else {
+	set_ostream_ptr(out, true);
+      }
+    }
+  }
+}

+ 3 - 0
dtool/src/dconfig/notify.h

@@ -61,6 +61,7 @@ PUBLISHED:
   static void write_string(const string &str);
   static void write_string(const string &str);
   static Notify *ptr();
   static Notify *ptr();
 
 
+public:
   static long get_literal_flag();
   static long get_literal_flag();
 
 
   bool assert_failure(const char *expression, int line,
   bool assert_failure(const char *expression, int line,
@@ -68,6 +69,8 @@ PUBLISHED:
 
 
   static NotifySeverity string_severity(const string &string);
   static NotifySeverity string_severity(const string &string);
 
 
+  void config_initialized();
+
 private:
 private:
   ostream *_ostream_ptr;
   ostream *_ostream_ptr;
   bool _owns_ostream_ptr;
   bool _owns_ostream_ptr;