osgEarth 2.1.1
Public Member Functions | Private Types | Private Attributes

osgEarth::Features::Session Class Reference

Inheritance diagram for osgEarth::Features::Session:
Collaboration diagram for osgEarth::Features::Session:

List of all members.

Public Member Functions

 Session (const Map *map, StyleSheet *styles=0L)
void setURIContext (const URIContext &value)
const URIContexturiContext () const
MapFrame createMapFrame (Map::ModelParts parts=Map::TERRAIN_LAYERS) const
const MapInfogetMapInfo () const
void setStyles (StyleSheet *value)
StyleSheetstyles () const
void putObject (const std::string &key, osg::Referenced *object)
template<typename T >
T * getObject (const std::string &key)
void removeObject (const std::string &key)

Private Types

typedef std::map< std::string,
osg::ref_ptr< osg::Referenced > > 
ObjectMap

Private Attributes

ObjectMap _objMap
Threading::ReadWriteMutex _objMapMutex
URIContext _uriContext
osg::ref_ptr< const Map_map
MapInfo _mapInfo
osg::ref_ptr< StyleSheet_styles

Detailed Description

Session is a state object that exists throughout the life of one or more related feature compilations.

A Session holds shared, re-usable data elements that can be accessed through a FilterContext.

Whereas a FilterContext exists thoughout the life of a single compilation, a Session exists one level above this and governs any number of "related" compilations (e.g., the compilation of many grid cells comprising a single feature layer).

Session implements the URIResolver interface to resolve relative URIs.

Definition at line 47 of file Session.


Member Typedef Documentation

typedef std::map<std::string, osg::ref_ptr<osg::Referenced> > osgEarth::Features::Session::ObjectMap [private]

Definition at line 111 of file Session.


Constructor & Destructor Documentation

Session::Session ( const Map map,
StyleSheet styles = 0L 
)

Constructs a new Session that is tied to a map

Definition at line 35 of file Session.cpp.

                                                     :
osg::Referenced( true ),
_map           ( map ),
_mapInfo       ( map )
//_resourceCache ( new ResourceCache(true) ) // make is thread-safe.
{
    if ( styles )
        setStyles( styles );
    else
        _styles = new StyleSheet();
}

Here is the call graph for this function:


Member Function Documentation

MapFrame Session::createMapFrame ( Map::ModelParts  parts = Map::TERRAIN_LAYERS) const

Gets the underlying map (frame) interface in this session

Definition at line 62 of file Session.cpp.

{
    return MapFrame( _map.get(), parts );
}

Here is the caller graph for this function:

const MapInfo& osgEarth::Features::Session::getMapInfo ( ) const [inline]

Gets the map information backing up this session.

Definition at line 69 of file Session.

{ return _mapInfo; }

Here is the caller graph for this function:

template<typename T >
T* osgEarth::Features::Session::getObject ( const std::string &  key) [inline]

Gets an object from the shared Session cache.

Definition at line 99 of file Session.

                                                                  {
            Threading::ScopedReadLock lock( _objMapMutex );
            ObjectMap::const_iterator i = _objMap.find(key);
            return i != _objMap.end() ? dynamic_cast<T*>( i->second.get() ) : 0L;
        }

Here is the caller graph for this function:

void Session::putObject ( const std::string &  key,
osg::Referenced *  object 
)

Session-global resource cache. Careful. Resolves a URI based on the reference URI. You can use this method to create an absolute URI from a relative one, for example. Stores an object in the shared Session cache.

WARNING! Don't store things like nodes in here unless you plan to clone them. This is a multi-threaded store.

Definition at line 68 of file Session.cpp.

{
    //if ( dynamic_cast<osg::Node*>( object ) )
    //{
    //    OE_INFO << LC << "*** usage warning: storing an osg::Node in the Session cache is bad news;"
    //        << " live graph iterators can be invalidated." 
    //        << std::endl;
    //}

    Threading::ScopedWriteLock lock( _objMapMutex );
    _objMap[key] = object;
}

Here is the caller graph for this function:

void Session::removeObject ( const std::string &  key)

Definition at line 82 of file Session.cpp.

{
    Threading::ScopedWriteLock lock( _objMapMutex );
    _objMap.erase( key );
}
void Session::setStyles ( StyleSheet value)

The style sheet governing this session.

Definition at line 89 of file Session.cpp.

{
    _styles = value ? value : new StyleSheet();
}

Here is the caller graph for this function:

void osgEarth::Features::Session::setURIContext ( const URIContext value) [inline]

URI Context for relative path resolution.

Definition at line 58 of file Session.

{ _uriContext = value; }
StyleSheet* osgEarth::Features::Session::styles ( ) const [inline]

Definition at line 73 of file Session.

{ return _styles.get(); }

Here is the caller graph for this function:

const URIContext& osgEarth::Features::Session::uriContext ( ) const [inline]

Definition at line 59 of file Session.

{ return _uriContext; }

Member Data Documentation

osg::ref_ptr<const Map> osgEarth::Features::Session::_map [private]

Definition at line 116 of file Session.

Definition at line 117 of file Session.

Definition at line 112 of file Session.

Definition at line 113 of file Session.

Definition at line 119 of file Session.

Definition at line 115 of file Session.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines