osgEarth 2.1.1

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

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 #ifndef OSGEARTH_FEATURES_SESSION_H
00021 #define OSGEARTH_FEATURES_SESSION_H 1
00022 
00023 #include <osgEarthFeatures/Common>
00024 #include <osgEarthSymbology/ResourceCache>
00025 #include <osgEarthSymbology/Style>
00026 #include <osgEarth/ThreadingUtils>
00027 #include <osgEarth/Map>
00028 
00029 namespace osgEarth { namespace Features
00030 {
00031     using namespace osgEarth;
00032     using namespace osgEarth::Symbology;
00033 
00047     class OSGEARTHFEATURES_EXPORT Session : public osg::Referenced
00048     {
00049     public:
00053         Session( const Map* map, StyleSheet* styles =0L );
00054 
00058         void setURIContext( const URIContext& value ) { _uriContext = value; }
00059         const URIContext& uriContext() const { return _uriContext; }
00060 
00064         MapFrame createMapFrame( Map::ModelParts parts =Map::TERRAIN_LAYERS ) const;
00065 
00069         const MapInfo& getMapInfo() const { return _mapInfo; }
00070 
00072         void setStyles( StyleSheet* value );
00073         StyleSheet* styles() const { return _styles.get(); }
00074 
00076         //ResourceCache* resourceCache() { return _resourceCache.get(); }
00077         //const ResourceCache* resourceCache() const { return _resourceCache.get(); }
00078 
00079     public: // URIResolver
00080         
00085         //std::string resolveURI( const std::string& inputURI ) const;
00086 
00087     public:
00094         void putObject( const std::string& key, osg::Referenced* object );
00095 
00099         template<typename T> T* getObject( const std::string& key ) {
00100             Threading::ScopedReadLock lock( _objMapMutex );
00101             ObjectMap::const_iterator i = _objMap.find(key);
00102             return i != _objMap.end() ? dynamic_cast<T*>( i->second.get() ) : 0L;
00103         }
00104 
00105         void removeObject( const std::string& key );
00106 
00107     private:
00108 
00109         //osg::ref_ptr<ResourceCache> _resourceCache;
00110 
00111         typedef std::map<std::string, osg::ref_ptr<osg::Referenced> > ObjectMap;
00112         ObjectMap                    _objMap;
00113         Threading::ReadWriteMutex    _objMapMutex;
00114 
00115         URIContext                     _uriContext;
00116         osg::ref_ptr<const Map>        _map;
00117         MapInfo                        _mapInfo;
00118         //std::string                    _referenceURI;
00119         osg::ref_ptr<StyleSheet>       _styles;
00120     };
00121 
00122 } }
00123 
00124 #endif // OSGEARTH_FEATURES_SESSION_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines