Show
Ignore:
Timestamp:
02/12/10 12:45:00 (5 years ago)
Author:
robert
Message:

Introduced OSG_WARN, OSG_NOTICE, OSG_INFO, OSG_DEBUG convinience macros that map to OSG_NOTIFY(osg::WARN) etc.

Introduced the OSG_NOTIFY_DISABLE Cmake variable + include/osg/Config #define to control whether the OpenSceneGraph build
should disable the notification system completely. By setting OSG_NOTIFY_DISABLE to ON in CMake and then rebuilding the
the OSG you can get a slightly smaller (~1%) and more slightly efficient library which can be good for shipping applications,
but with downside of reduced ability to detect runtime problems and their causes.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osg/Notify.cpp

    r10764 r11057  
    115115static osg::ApplicationUsageProxy Notify_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE, "OSG_NOTIFY_LEVEL <mode>", "FATAL | WARN | NOTICE | DEBUG_INFO | DEBUG_FP | DEBUG | INFO | ALWAYS"); 
    116116 
     117static bool s_NeedNotifyInit = true; 
    117118static osg::NotifySeverity g_NotifyLevel = osg::NOTICE; 
    118119static osg::NullStream *g_NullStream; 
     
    121122void osg::setNotifyLevel(osg::NotifySeverity severity) 
    122123{ 
    123     osg::initNotifyLevel(); 
     124    if (s_NeedNotifyInit) osg::initNotifyLevel(); 
    124125    g_NotifyLevel = severity; 
    125126} 
     
    128129osg::NotifySeverity osg::getNotifyLevel() 
    129130{ 
    130     osg::initNotifyLevel(); 
     131    if (s_NeedNotifyInit) osg::initNotifyLevel(); 
    131132    return g_NotifyLevel; 
    132133} 
     
    141142osg::NotifyHandler* osg::getNotifyHandler() 
    142143{ 
    143     osg::initNotifyLevel(); 
     144    if (s_NeedNotifyInit) osg::initNotifyLevel(); 
    144145    osg::NotifyStreamBuffer *buffer = static_cast<osg::NotifyStreamBuffer *>(g_NotifyStream->rdbuf()); 
    145146    return buffer ? buffer->getNotifyHandler() : 0; 
     
    148149bool osg::initNotifyLevel() 
    149150{ 
    150     static bool s_NotifyInit = false; 
    151151    static osg::NullStream s_NullStream; 
    152152    static osg::NotifyStream s_NotifyStream; 
    153  
    154     if (s_NotifyInit) return true; 
    155153 
    156154    g_NullStream = &s_NullStream; 
     
    194192        buffer->setNotifyHandler(new StandardNotifyHandler); 
    195193 
    196     s_NotifyInit = true; 
     194    s_NeedNotifyInit = false; 
    197195 
    198196    return true; 
     
    200198} 
    201199 
     200#ifndef OSG_NOTIFY_DISABLED 
    202201bool osg::isNotifyEnabled( osg::NotifySeverity severity ) 
    203202{ 
     203    if (s_NeedNotifyInit) osg::initNotifyLevel(); 
    204204    return severity<=g_NotifyLevel; 
    205205} 
     206#endif 
    206207 
    207208std::ostream& osg::notify(const osg::NotifySeverity severity) 
    208209{ 
    209     static bool initialized = false; 
    210     if (!initialized)  
    211     { 
    212         initialized = osg::initNotifyLevel(); 
    213     } 
    214  
    215     if (severity<=g_NotifyLevel) 
     210    if (s_NeedNotifyInit) osg::initNotifyLevel(); 
     211 
     212    if (osg::isNotifyEnabled(severity)) 
    216213    { 
    217214        g_NotifyStream->setCurrentSeverity(severity);