osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthFeatures/Session.cpp

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2008-2010 Pelican Mapping
00004  * http://osgearth.org
00005  *
00006  * osgEarth is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 
00020 #include <osgEarthFeatures/Session>
00021 #include <osgEarth/FileUtils>
00022 #include <osgEarth/HTTPClient>
00023 #include <osgEarth/StringUtils>
00024 #include <osg/AutoTransform>
00025 #include <osg/Depth>
00026 #include <osg/TextureRectangle>
00027 
00028 #define LC "[Session] "
00029 
00030 using namespace osgEarth;
00031 using namespace osgEarth::Features;
00032 
00033 //---------------------------------------------------------------------------
00034 
00035 Session::Session( const Map* map, StyleSheet* styles ) :
00036 osg::Referenced( true ),
00037 _map           ( map ),
00038 _mapInfo       ( map )
00039 //_resourceCache ( new ResourceCache(true) ) // make is thread-safe.
00040 {
00041     if ( styles )
00042         setStyles( styles );
00043     else
00044         _styles = new StyleSheet();
00045 }
00046 
00047 #if 0
00048 void
00049 Session::setReferenceURI( const std::string& referenceURI )
00050 {
00051     _referenceURI = referenceURI;
00052 }
00053 
00054 std::string
00055 Session::resolveURI( const std::string& inputURI ) const
00056 {
00057     return osgEarth::getFullPath( _referenceURI, inputURI );
00058 }
00059 #endif
00060 
00061 MapFrame
00062 Session::createMapFrame( Map::ModelParts parts ) const
00063 {
00064     return MapFrame( _map.get(), parts );
00065 }
00066 
00067 void
00068 Session::putObject( const std::string& key, osg::Referenced* object )
00069 {
00070     //if ( dynamic_cast<osg::Node*>( object ) )
00071     //{
00072     //    OE_INFO << LC << "*** usage warning: storing an osg::Node in the Session cache is bad news;"
00073     //        << " live graph iterators can be invalidated." 
00074     //        << std::endl;
00075     //}
00076 
00077     Threading::ScopedWriteLock lock( _objMapMutex );
00078     _objMap[key] = object;
00079 }
00080 
00081 void
00082 Session::removeObject( const std::string& key )
00083 {
00084     Threading::ScopedWriteLock lock( _objMapMutex );
00085     _objMap.erase( key );
00086 }
00087 
00088 void
00089 Session::setStyles( StyleSheet* value )
00090 {
00091     _styles = value ? value : new StyleSheet();
00092 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines