s11n::io::url_stream_factory Class Reference

A factory type intended to be subclassed to provide protocol-specific i/o streams. More...

#include <url.hpp>

Inheritance diagram for s11n::io::url_stream_factory:

s11n::io::file_stream_factory

List of all members.

Public Member Functions

virtual ~url_stream_factory ()
std::ostream * get_ostream (url_parser const &url) const
 See do_get_ostream().
std::istream * get_istream (url_parser const &url) const
 See do_get_istream().

Static Public Member Functions

static
url_stream_factory
create_factory_for_scheme (std::string const &scheme)
 Classloads an instance of url_stream_factory associated with the given scheme.
template<typename SubclassT>
static void register_factory_for_scheme (std::string const &scheme)
 Registers SubclassT as a subclass of url_stream_factory such that calling create_factory_for_scheme(scheme) will return an instance of SubclassT.

Protected Member Functions

 url_stream_factory ()
virtual std::ostream * do_get_ostream (url_parser const &url) const
 Default implementation returns 0.
virtual std::istream * do_get_istream (url_parser const &url) const
 Default implementation returns 0.


Detailed Description

A factory type intended to be subclassed to provide protocol-specific i/o streams.

Subclasses must reimplement the virtual functions and register with the classloader like so:

define S11N_FACREG_TYPE my_subclass_type
define S11N_FACREG_INTERFACE_TYPE s11n::io::url_stream_factory
define S11N_FACREG_TYPE_NAME "my_subclass_type"
include <s11n.net/s11n/factory_reg.hpp>

They may also want to set up classloader aliases during the static initialization phase, as demonstrated for the file:// protocol in url.cpp.

Note for subclasser: NEVER EVER call s11n::io::get_i/ostream() from this class, because those functions dispatch to url_stream_factory when possible, and callint those from here can cause an endless loop.

Definition at line 153 of file url.hpp.


Constructor & Destructor Documentation

s11n::io::url_stream_factory::url_stream_factory (  )  [inline, protected]

Definition at line 156 of file url.hpp.

virtual s11n::io::url_stream_factory::~url_stream_factory (  )  [inline, virtual]

Definition at line 182 of file url.hpp.


Member Function Documentation

virtual std::ostream* s11n::io::url_stream_factory::do_get_ostream ( url_parser const &  url  )  const [inline, protected, virtual]

Default implementation returns 0.

Subclasses.should return an instance of a stream capable of writing to the given URL. On error they should return 0 or throw an exception.

The caller owns the returned pointer, which may be 0.

Reimplemented in s11n::io::file_stream_factory.

Definition at line 165 of file url.hpp.

virtual std::istream* s11n::io::url_stream_factory::do_get_istream ( url_parser const &  url  )  const [inline, protected, virtual]

Default implementation returns 0.

Subclasses.should return an instance of a stream capable of reading from the given URL. On error they should return 0 or throw an exception.

The caller owns the returned pointer, which may be 0.

Reimplemented in s11n::io::file_stream_factory.

Definition at line 176 of file url.hpp.

std::ostream* s11n::io::url_stream_factory::get_ostream ( url_parser const &  url  )  const [inline]

See do_get_ostream().

Definition at line 187 of file url.hpp.

std::istream* s11n::io::url_stream_factory::get_istream ( url_parser const &  url  )  const [inline]

See do_get_istream().

Definition at line 194 of file url.hpp.

static url_stream_factory* s11n::io::url_stream_factory::create_factory_for_scheme ( std::string const &  scheme  )  [static]

Classloads an instance of url_stream_factory associated with the given scheme.

Caller owns the returned pointer, which may be 0.

Subclass authors are responsible for registering their subclasses with the url_stream_factory classloader.

template<typename SubclassT>
static void s11n::io::url_stream_factory::register_factory_for_scheme ( std::string const &  scheme  )  [inline, static]

Registers SubclassT as a subclass of url_stream_factory such that calling create_factory_for_scheme(scheme) will return an instance of SubclassT.

SubclassT must be-a url_stream_factory and must be compatible with the s11n::fac factory layer.

Definition at line 218 of file url.hpp.


The documentation for this class was generated from the following file:
Generated on Sun Apr 27 13:16:05 2008 for libs11n by  doxygen 1.5.3