osgEarth 2.1.1
Public Types | Public Member Functions | Protected Attributes

osgEarth::URI Class Reference

Collaboration diagram for osgEarth::URI:

List of all members.

Public Types

enum  ResultCode {
  RESULT_OK, RESULT_CANCELED, RESULT_NOT_FOUND, RESULT_SERVER_ERROR,
  RESULT_TIMEOUT, RESULT_NO_READER, RESULT_READER_ERROR, RESULT_UNKNOWN_ERROR
}

Public Member Functions

 URI ()
 URI (const std::string &location)
 URI (const std::string &location, const URIContext &context)
 URI (const char *location)
const std::string & base () const
const std::string & full () const
const std::string & operator* () const
const URIContextcontext () const
bool empty () const
URI append (const std::string &suffix) const
bool operator< (const URI &rhs) const
osg::Object * readObject (const osgDB::Options *options=0L, ResultCode *out_code=0L) const
osg::Image * readImage (const osgDB::Options *options=0L, ResultCode *out_code=0L) const
osg::Node * readNode (const osgDB::Options *options=0L, ResultCode *out_code=0L) const
std::string readString (ResultCode *out_code=0L) const
 URI (const URI &rhs)

Protected Attributes

std::string _baseURI
std::string _fullURI
URIContext _context

Detailed Description

Represents the location of a resource, providing the raw (original, possibly relative) and absolute forms.

Definition at line 114 of file URI.


Member Enumeration Documentation

Result codes for the read* methods. Call getLastResultCode() to fetch.

Enumerator:
RESULT_OK 
RESULT_CANCELED 
RESULT_NOT_FOUND 
RESULT_SERVER_ERROR 
RESULT_TIMEOUT 
RESULT_NO_READER 
RESULT_READER_ERROR 
RESULT_UNKNOWN_ERROR 

Definition at line 164 of file URI.


Constructor & Destructor Documentation

URI::URI ( )

Constructs an empty (and invalid) URI.

Definition at line 131 of file URI.cpp.

{
    //nop
}
URI::URI ( const std::string &  location)

Constructs a new URI from a location (typically an absolute url)

Definition at line 136 of file URI.cpp.

{
    _baseURI = location;
    _fullURI = location;
}
URI::URI ( const std::string &  location,
const URIContext context 
)

Constructs a new URI from a location and an existing context.

Definition at line 142 of file URI.cpp.

{
    _context = context;
    _baseURI = location;
    _fullURI = context.getOSGPath( _baseURI );
}

Here is the call graph for this function:

URI::URI ( const char *  location)

Constructs a new URI from a string.

Definition at line 149 of file URI.cpp.

{
    _baseURI = std::string(location);
    _fullURI = _baseURI;
}
osgEarth::URI::URI ( const URI rhs) [inline]

Copier

Definition at line 196 of file URI.

: _baseURI(rhs._baseURI), _fullURI(rhs._fullURI), _context(rhs._context) { }

Member Function Documentation

URI URI::append ( const std::string &  suffix) const

Returns a copy of this URI with the suffix appended

Definition at line 156 of file URI.cpp.

{
    URI result;
    result._baseURI = _baseURI + suffix;
    result._fullURI = _fullURI + suffix;
    result._context = _context;
    return result;
}

Here is the caller graph for this function:

const std::string& osgEarth::URI::base ( ) const [inline]

The base (possibly relative) location string.

Definition at line 140 of file URI.

{ return _baseURI; }
const URIContext& osgEarth::URI::context ( ) const [inline]

Context with which this URI was created.

Definition at line 149 of file URI.

{ return _context; }

Here is the caller graph for this function:

bool osgEarth::URI::empty ( ) const [inline]

Whether the URI is empty

Definition at line 152 of file URI.

{ return _baseURI.empty(); }

Here is the caller graph for this function:

const std::string& osgEarth::URI::full ( ) const [inline]

The fully qualified location string.

Definition at line 143 of file URI.

{ return _fullURI; }

Here is the caller graph for this function:

const std::string& osgEarth::URI::operator* ( ) const [inline]

The dereference operator also returns the fully qualified URI, since it's a common operation.

Definition at line 146 of file URI.

{ return _fullURI; }
bool osgEarth::URI::operator< ( const URI rhs) const [inline]

Definition at line 159 of file URI.

{ return _fullURI < rhs._fullURI; }
osg::Image * URI::readImage ( const osgDB::Options options = 0L,
ResultCode out_code = 0L 
) const

Reads an image from the URI.

Definition at line 183 of file URI.cpp.

{
    if ( empty() ) {
        if ( out_code ) *out_code = RESULT_NOT_FOUND;
        return 0L;
    }

    osg::ref_ptr<const osgDB::Options> myOptions = fixOptions(options);

    //OE_INFO << LC << "readImage: " << _fullURI << std::endl;

    osg::ref_ptr<osg::Image> image;
    ResultCode result = (ResultCode)HTTPClient::readImageFile( _fullURI, image, myOptions.get() );
    if ( out_code ) *out_code = result;

    return image.release();
}

Here is the call graph for this function:

Here is the caller graph for this function:

osg::Node * URI::readNode ( const osgDB::Options options = 0L,
ResultCode out_code = 0L 
) const

Reads a node from the URI.

Definition at line 202 of file URI.cpp.

{
    if ( empty() ) {
        if ( out_code ) *out_code = RESULT_NOT_FOUND;
        return 0L;
    }

    osg::ref_ptr<const osgDB::Options> myOptions = fixOptions(options);

    osg::ref_ptr<osg::Node> node;
    ResultCode result = (ResultCode)HTTPClient::readNodeFile( _fullURI, node, myOptions.get() );
    if ( out_code ) *out_code = result;
    return node.release();
}

Here is the call graph for this function:

Here is the caller graph for this function:

osg::Object * URI::readObject ( const osgDB::Options options = 0L,
ResultCode out_code = 0L 
) const

Reads an object from the URI.

Definition at line 166 of file URI.cpp.

{
    if ( empty() ) {
        if ( out_code ) *out_code = RESULT_NOT_FOUND;
        return 0L;
    }

    osg::ref_ptr<const osgDB::Options> myOptions = fixOptions(options);

    osg::ref_ptr<osg::Object> object;
    ResultCode result = (ResultCode)HTTPClient::readObjectFile( _fullURI, object, myOptions.get() );
    if ( out_code ) *out_code = result;

    return object.release();
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string URI::readString ( ResultCode out_code = 0L) const

Reads a string from the URI.

Definition at line 218 of file URI.cpp.

{
    if ( empty() ) {
        if ( out_code ) *out_code = RESULT_NOT_FOUND;
        return 0L;
    }

    std::string str;
    ResultCode result = (ResultCode)HTTPClient::readString( _fullURI, str );
    if ( out_code ) *out_code = result;
    return str;
}

Here is the call graph for this function:


Member Data Documentation

std::string osgEarth::URI::_baseURI [protected]

Definition at line 202 of file URI.

Definition at line 204 of file URI.

std::string osgEarth::URI::_fullURI [protected]

Definition at line 203 of file URI.


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