1/* -*-c++-*- */
2/* osgEarth - Geospatial SDK for OpenSceneGraph
3 * Copyright 2019 Pelican Mapping
4 * http://osgearth.org
5 *
6 * osgEarth is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program.  If not, see <http://www.gnu.org/licenses/>
18 */
19
20#ifndef OSGEARTH_NOTIFY_H
21#define OSGEARTH_NOTIFY_H 1
22
23#include <osgEarth/Export>
24#include <osg/Notify>
25#include <osg/Timer>
26#include <string>
27
28namespace osgEarth
29{
30    /** set the notify level, overriding the default or the value set by
31      * the environmental variable OSGNOTIFYLEVEL.
32      */
33    extern OSGEARTH_EXPORT void setNotifyLevel(osg::NotifySeverity severity);
34
35    /** get the notify level. */
36    extern OSGEARTH_EXPORT osg::NotifySeverity getNotifyLevel();
37
38    /** is notification enabled, given the current setNotifyLevel() setting? */
39    extern OSGEARTH_EXPORT bool isNotifyEnabled(osg::NotifySeverity severity);
40
41    /** initialize notify level. */
42    extern OSGEARTH_EXPORT bool initNotifyLevel();
43
44    extern OSGEARTH_EXPORT std::ostream& notify(const osg::NotifySeverity severity);
45
46    inline std::ostream& notify(void) { return osgEarth::notify(osg::INFO); }
47
48#define OE_NOTIFY( X,Y ) if(osgEarth::isNotifyEnabled( X )) osgEarth::notify( X ) << Y
49#define OE_FATAL OE_NOTIFY(osg::FATAL,"[osgEarth]* ")
50#define OE_WARN OE_NOTIFY(osg::WARN,"[osgEarth]* ")
51#define OE_NOTICE OE_NOTIFY(osg::NOTICE,"[osgEarth]  ")
52#define OE_INFO OE_NOTIFY(osg::INFO,"[osgEarth]  ")
53#define OE_INFO_CONTINUE OE_NOTIFY(osg::INFO, "")
54#define OE_DEBUG OE_NOTIFY(osg::DEBUG_INFO,"[osgEarth]  ")
55#define OE_NULL if(false) osgEarth::notify(osg::ALWAYS)
56
57#define OE_START_TIMER(VAR) osg::Timer_t VAR##_oe_timer = osg::Timer::instance()->tick()
58#define OE_STOP_TIMER(VAR) osg::Timer::instance()->delta_s( VAR##_oe_timer, osg::Timer::instance()->tick() )
59#define OE_GET_TIMER(VAR) osg::Timer::instance()->delta_s( VAR##_oe_timer, osg::Timer::instance()->tick() )
60
61#define OE_DEPRECATED(A, B) OE_WARN << #A << " is deprecated; please use " << #B << std::endl
62
63extern OSGEARTH_EXPORT void setNotifyHandler(osg::NotifyHandler *handler);
64
65/** Get currrent notification handler. */
66extern OSGEARTH_EXPORT osg::NotifyHandler *getNotifyHandler();
67
68}
69
70#endif // OSGEARTH_NOTIFY_H
71