class DjVuPortcaster

Maintains associations between ports.

Public Methods

[more]static DjVuPortcaster* get_portcaster(void)
Use this function to get a copy of the global DjVuPortcaster.
[more] DjVuPortcaster(void)
The default constructor.
[more]void del_port(const DjVuPort * port)
Removes the specified port from all routes.
[more]void add_route(const DjVuPort *src, DjVuPort *dst)
Adds route from src to dst.
[more]void del_route(const DjVuPort *src, DjVuPort *dst)
The opposite of add_route().
[more]void copy_routes(DjVuPort *dst, const DjVuPort *src)
Copies all incoming and outgoing routes from src to dst.
[more]GP<DjVuPort> is_port_alive(DjVuPort *port)
Returns a smart pointer to the port if port is a valid pointer to an existing DjVuPort.
[more]void add_alias(const DjVuPort * port, const char * alias)
Assigns one more alias for the specified DjVuPort.
[more]static void clear_all_aliases(void)
Removes all the aliases
[more]void clear_aliases(const DjVuPort * port)
Removes all aliases associated with the given DjVuPort.
[more]GP<DjVuPort> alias_to_port(const char * name)
Returns DjVuPort associated with the given alias.
[more]GPList<DjVuPort> prefix_to_ports(const char * prefix)
Returns a list of DjVuPorts with aliases starting with prefix.
[more]virtual GURL id_to_url(const DjVuPort * source, const char * id)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest until one of them returns non-empty GURL.
[more]virtual GPBase id_to_file(const DjVuPort * source, const char * id)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest until one of them returns non-zero pointer to DjVuFile.
[more]virtual GP<DataPool> request_data(const DjVuPort * source, const GURL & url)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest until one of them returns non-zero DataPool.
[more]virtual bool notify_error(const DjVuPort * source, const char * msg)
Computes destination list for source and calls the corresponding.
[more]virtual bool notify_status(const DjVuPort * source, const char * msg)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest until one of them returns 1.
[more]virtual void notify_redisplay(const class DjVuImage * source)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.
[more]virtual void notify_relayout(const class DjVuImage * source)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.
[more]virtual void notify_chunk_done(const DjVuPort * source, const char * name)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.
[more]virtual void notify_file_flags_changed(const class DjVuFile * source, long set_mask, long clr_mask)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.
[more]virtual void notify_doc_flags_changed(const class DjVuDocument * source, long set_mask, long clr_mask)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.
[more]virtual void notify_decode_progress(const DjVuPort * source, float done)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.


Documentation

Maintains associations between ports. It monitors the status of all ports (have they been destructed yet?), accepts requests and notifications from them and forwards them to destinations according to internally maintained map of routes.

The caller can modify the route map any way he likes (see add_route(), del_route(), copy_routes(), etc. functions). Any port can be either a sender of a message, an intermediary receiver or a final destination.

When a request is sent, the DjVuPortcaster computes the list of destinations by consulting with the route map. Notifications are only sent to ``alive'' ports. A port is alive if it is referenced by a valid GP smartpointer. As a consequence, a port usually becomes alive after running the constructor (since the returned pointer is then assigned to a smartpointer) and is no longer alive when the port is destroyed (because it would not be destroyed if a smartpointer was referencing it).

Destination ports are sorted according to their distance from the source. For example, if port A is connected to ports B and C directly, and port B is connected to D, then B and C are assumed to be one hop away from A, while D is two hops away from A.

In some cases the requests and notifications are sent to every possible destination, and the order is not significant (like it is for notify_file_flags_changed() request). Others should be sent to the closest destinations first, and only then to the farthest, in case if they have not been processed by the closest. The examples are request_data(), notify_error() and notify_status().

The user is not expected to create the DjVuPortcaster itself. He should use get_portcaster() global function instead.

ostatic DjVuPortcaster* get_portcaster(void)
Use this function to get a copy of the global DjVuPortcaster.

o DjVuPortcaster(void)
The default constructor.

ovoid del_port(const DjVuPort * port)
Removes the specified port from all routes. It will no longer be able to receive or generate messages and will be considered "dead" by is_port_alive() function.

ovoid add_route(const DjVuPort *src, DjVuPort *dst)
Adds route from src to dst. Whenever a request is sent or received by src, it will be forwarded to dst as well.
Parameters:
src - The source
dst - The destination

ovoid del_route(const DjVuPort *src, DjVuPort *dst)
The opposite of add_route(). Removes the association between src and dst

ovoid copy_routes(DjVuPort *dst, const DjVuPort *src)
Copies all incoming and outgoing routes from src to dst. This function should be called when a DjVuPort is copied, if you want to preserve the connectivity.

oGP<DjVuPort> is_port_alive(DjVuPort *port)
Returns a smart pointer to the port if port is a valid pointer to an existing DjVuPort. Returns a null pointer otherwise.

ovoid add_alias(const DjVuPort * port, const char * alias)
Assigns one more alias for the specified DjVuPort. Aliases are names, which can be used later to retrieve this DjVuPort, if it still exists. Any DjVuPort may have more than one alias. But every alias must correspond to only one DjVuPort. Thus, if the specified alias is already associated with another port, this association will be removed.

ostatic void clear_all_aliases(void)
Removes all the aliases

ovoid clear_aliases(const DjVuPort * port)
Removes all aliases associated with the given DjVuPort.

oGP<DjVuPort> alias_to_port(const char * name)
Returns DjVuPort associated with the given alias. If nothing is known about name alias, or the port associated with it has already been destroyed ZERO pointer will be returned.

oGPList<DjVuPort> prefix_to_ports(const char * prefix)
Returns a list of DjVuPorts with aliases starting with prefix. If no DjVuPorts have been found, empty list is returned.

ovirtual GURL id_to_url(const DjVuPort * source, const char * id)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest until one of them returns non-empty GURL.

ovirtual GPBase id_to_file(const DjVuPort * source, const char * id)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest until one of them returns non-zero pointer to DjVuFile.

ovirtual GP<DataPool> request_data(const DjVuPort * source, const GURL & url)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest until one of them returns non-zero DataPool.

ovirtual bool notify_error(const DjVuPort * source, const char * msg)
Computes destination list for source and calls the corresponding. function in each of the ports from the destination starting from the closest until one of them returns 1.

ovirtual bool notify_status(const DjVuPort * source, const char * msg)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest until one of them returns 1.

ovirtual void notify_redisplay(const class DjVuImage * source)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.

ovirtual void notify_relayout(const class DjVuImage * source)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.

ovirtual void notify_chunk_done(const DjVuPort * source, const char * name)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.

ovirtual void notify_file_flags_changed(const class DjVuFile * source, long set_mask, long clr_mask)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.

ovirtual void notify_doc_flags_changed(const class DjVuDocument * source, long set_mask, long clr_mask)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.

ovirtual void notify_decode_progress(const DjVuPort * source, float done)
Computes destination list for source and calls the corresponding function in each of the ports from the destination list starting from the closest.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java


DjVu is a trademark of LizardTech, Inc.
All other products mentioned are registered trademarks or trademarks of their respective companies.