Changeset 10263 for OpenSceneGraph/trunk/src/osg/Notify.cpp
- Timestamp:
- 05/25/09 12:46:37 (4 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osg/Notify.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osg/Notify.cpp
r10229 r10263 36 36 public: 37 37 NullStream(): 38 std::ostream(&_buffer) {} 38 std::ostream(new NullStreamBuffer) 39 { _buffer = dynamic_cast<NullStreamBuffer *>(rdbuf()); } 40 41 ~NullStream() 42 { 43 rdbuf(0); 44 delete _buffer; 45 } 39 46 40 47 protected: 41 NullStreamBuffer _buffer;48 NullStreamBuffer* _buffer; 42 49 }; 43 50 … … 77 84 public: 78 85 NotifyStream(): 79 std::ostream(&_buffer) {} 86 std::ostream(new NotifyStreamBuffer) 87 { _buffer = dynamic_cast<NotifyStreamBuffer *>(rdbuf()); } 80 88 81 89 void setCurrentSeverity(osg::NotifySeverity severity) 82 90 { 83 _buffer .setCurrentSeverity(severity);91 _buffer->setCurrentSeverity(severity); 84 92 } 85 93 86 94 osg::NotifySeverity getCurrentSeverity() const 87 95 { 88 return _buffer.getCurrentSeverity(); 96 return _buffer->getCurrentSeverity(); 97 } 98 99 ~NotifyStream() 100 { 101 rdbuf(0); 102 delete _buffer; 89 103 } 90 104 91 105 protected: 92 NotifyStreamBuffer _buffer;106 NotifyStreamBuffer* _buffer; 93 107 }; 94 108 … … 99 113 static osg::ApplicationUsageProxy Notify_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE, "OSG_NOTIFY_LEVEL <mode>", "FATAL | WARN | NOTICE | DEBUG_INFO | DEBUG_FP | DEBUG | INFO | ALWAYS"); 100 114 101 osg::NotifySeverity g_NotifyLevel = osg::NOTICE;102 osg::NullStreamg_NullStream;103 osg::NotifyStreamg_NotifyStream;115 static osg::NotifySeverity g_NotifyLevel = osg::NOTICE; 116 static osg::NullStream *g_NullStream; 117 static osg::NotifyStream *g_NotifyStream; 104 118 105 119 void osg::setNotifyLevel(osg::NotifySeverity severity) … … 118 132 void osg::setNotifyHandler(osg::NotifyHandler *handler) 119 133 { 120 osg::NotifyStreamBuffer *buffer = static_cast<osg::NotifyStreamBuffer *>(g_NotifyStream .rdbuf());134 osg::NotifyStreamBuffer *buffer = static_cast<osg::NotifyStreamBuffer *>(g_NotifyStream->rdbuf()); 121 135 if (buffer) 122 136 buffer->setNotifyHandler(handler); 123 137 } 124 138 125 osg::NotifyHandler *getNotifyHandler()139 osg::NotifyHandler* osg::getNotifyHandler() 126 140 { 127 141 osg::initNotifyLevel(); 128 osg::NotifyStreamBuffer *buffer = static_cast<osg::NotifyStreamBuffer *>(g_NotifyStream .rdbuf());142 osg::NotifyStreamBuffer *buffer = static_cast<osg::NotifyStreamBuffer *>(g_NotifyStream->rdbuf()); 129 143 return buffer ? buffer->getNotifyHandler() : 0; 130 144 } … … 133 147 { 134 148 static bool s_NotifyInit = false; 149 static osg::NullStream s_NullStream; 150 static osg::NotifyStream s_NotifyStream; 135 151 136 152 if (s_NotifyInit) return true; 153 154 g_NullStream = &s_NullStream; 155 g_NotifyStream = &s_NotifyStream; 137 156 138 157 // g_NotifyLevel … … 169 188 170 189 // Setup standard notify handler 171 osg::NotifyStreamBuffer *buffer = dynamic_cast<osg::NotifyStreamBuffer *>(g_NotifyStream .rdbuf());190 osg::NotifyStreamBuffer *buffer = dynamic_cast<osg::NotifyStreamBuffer *>(g_NotifyStream->rdbuf()); 172 191 if (buffer && !buffer->getNotifyHandler()) 173 192 buffer->setNotifyHandler(new StandardNotifyHandler); … … 194 213 if (severity<=g_NotifyLevel) 195 214 { 196 g_NotifyStream .setCurrentSeverity(severity);197 return g_NotifyStream;198 } 199 return g_NullStream;215 g_NotifyStream->setCurrentSeverity(severity); 216 return *g_NotifyStream; 217 } 218 return *g_NullStream; 200 219 } 201 220
