Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Cabal::Line Class Reference

Client connection set abstraction. More...

#include <cabal_line.h>

Inheritance diagram for Cabal::Line:

Inheritance graph
[legend]
Collaboration diagram for Cabal::Line:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Line (const long band, int arraySize)
 Creates an unnamed connection semantic Line.

 Line (const long band)
 Creates a named connection semantic Line.

 ~Line ()
 Destroys the line object and all its connections.

Connectionset (const int conId, Connection *con)
 Sets a certain connection ID to a determined connection object.

Connectionget (const int conId) const
 Retreives a certain connection given its ID.

Connectionset (const std::string &conName, Connection *con)
 Sets a certain named connection to a determined connection object.

Connectionget (const std::string &conName) const
 Retreives a certain connection given its name.

Connectionset (const char *conName, Connection *con)
 Sets the connection by name.

Connectionget (const char *conName) const
 Gets the connection by name.

void remove (Connection *con)
 Removed a connection given it's pointer.

void bandwidth (const long int bw)
 Sets the bandwidth assigned to this line.

double bandwidth () const
 Gets the bandwidth assigned to this line.


Detailed Description

Client connection set abstraction.

This class abstracts a "line" of communication from the local system to the remote host. A line may be formed up by one or more connections. A connection is a single logical communcation stream which the remote host is able to distinguish among the others.

The most important function of a Line is the ability to limit the total bandwidth that is assigned to a remote host. The throughput of all the connections in a line are guaranteed not to break the limit that has been set in the line.

Connections held in a line may be sending data on different sockets, or even on different channels; if they insist on the same socket, the remote host must have a way to understand which data is coming from which connection. In example, you may have two connection that are sending two different files alltogether on the same socket; in this case, you must provovide a protocol that makes the other side able to understand which connection was sending the data (i.e. with a combination of id-lenght at the head of each transmission data sending).

Line can be created to hold named and unnamed connections. Named connections are held in a map, so that they can be accessed by their name, and new connections can be freely added or removed as needed; this makes access to a signle connection slighly slower though (anyhow, you may fetch a named connection pointer and use this fetched address).

Unnamed connections are held in a memory table (old C array), and access to them is done via a number. Accessing them with the get( const int ID) method is equivalent to a pointer dereference. When the lines have a fixed amount of possible connections.

Lines must be created either for named or unnamed access; trying to access named connections in an unnamed accessed Line or viceversa will make an assertion to fail.

As a rule of thumb, when the application protocol can host any number of connections per client (i.e. any number of concurrent file transfer, data connections, command connection and so on), use named access semantic, while if the application has a fixed set of possible connections (i.e. a command stream and a data stream), use unnamed access semantic.

Unnamed access semantic use can be easier if the final application provides a set of defines or an enum to access each specific connection.

Author:
Giancarlo Niccolai

Definition at line 93 of file cabal_line.h.


Constructor & Destructor Documentation

Cabal::Line::Line const long  band,
int  arraySize
 

Creates an unnamed connection semantic Line.

This constructor creates a line that will use integer indexes to identify connections. Application must declare a set of IDs with defines or enums that identify different connections per line; the size (and semantic) of each line is fixed.

Parameters:
band the bandwidth that is assigned to the remote host represented by this line
arraySize Maximum quantity of the connections available in this line. Must be greater than 0.

Definition at line 28 of file ltlib/cabal_line.cpp.

Cabal::Line::Line const long  band  ) 
 

Creates a named connection semantic Line.

This constructor creates a Line that will use strings to identify connections. Allows flexible access to the channels so that the channels inside a line may greatly vary.

Parameters:
band the bandwidth that is assigned to the remote host represented by this line

Definition at line 43 of file ltlib/cabal_line.cpp.

Cabal::Line::~Line  ) 
 

Destroys the line object and all its connections.

All the connections that are still inside the line are destroyed, and their attacched transmission objects are destroyed with them. All cleanup actions and terminate() methods must have been already called before the Line is destroyed.

Definition at line 53 of file ltlib/cabal_line.cpp.


Member Function Documentation

Connection* Cabal::Line::get const char *  conName  )  const [inline]
 

Gets the connection by name.

Inline to get( std::string & ).

Note:
You can use this method only if the line has named semantic, that is if was created with Line( int ) constructor.

Definition at line 210 of file cabal_line.h.

References get().

Connection * Cabal::Line::get const std::string &  conName  )  const
 

Retreives a certain connection given its name.

May return 0 if there isn't any connection with the given name.

Note:
You can use this method only if the line has named semantic, that is if was created with Line( int ) constructor.
Parameters:
conName the connection to be retreived.
Returns:
get()

Definition at line 108 of file ltlib/cabal_line.cpp.

Connection * Cabal::Line::get const int  conId  )  const
 

Retreives a certain connection given its ID.

May return 0 if the connection object for given ID is not mapped.

Note:
You can use this method only if the line has unnamed semantic, that is if was created with Line( int, int ) constructor.
Parameters:
conId the connection ID to be retreived; must be between 0 and the ID array size (that is the number passed in the constructor).

Definition at line 101 of file ltlib/cabal_line.cpp.

Referenced by get().

void Cabal::Line::remove Connection con  ) 
 

Removed a connection given it's pointer.

The connection is also deleted, so every cleanup action must be already taken.

Definition at line 124 of file ltlib/cabal_line.cpp.

Referenced by Cabal::Channel::process().

Connection* Cabal::Line::set const char *  conName,
Connection con
[inline]
 

Sets the connection by name.

Inline to set( std::string &, Connection * ).

Note:
You can use this method only if the line has named semantic, that is if was created with Line( int ) constructor.

Definition at line 197 of file cabal_line.h.

References set().

Connection * Cabal::Line::set const std::string &  conName,
Connection con
 

Sets a certain named connection to a determined connection object.

If the connection with the same name was previously referencing another connection, it is deleted.

Note:
You can use this method only if the line has named semantic, that is if was created with Line( int ) constructor.
Parameters:
conName the ID that must be mapped to the given connection; must be between 0 and the ID array size (that is the number passed in the constructor).
con the connection object that is mapped into ID.
Returns:
con (passing the pointer forward for expression evaluation).

Definition at line 84 of file ltlib/cabal_line.cpp.

References Cabal::Connection::line().

Connection * Cabal::Line::set const int  conId,
Connection con
 

Sets a certain connection ID to a determined connection object.

If the connection ID was previously referencing another connection, this is deleted.

Note:
You can use this method only if the line has unnamed semantic, that is if was created with Line( int, int ) constructor.
Parameters:
conId the ID that must be mapped to the given connection; must be between 0 and the ID array size (that is the number passed in the constructor).
con the connection object that is mapped into ID.
Returns:
con (passing the pointer forward for expression evaluation).

Definition at line 73 of file ltlib/cabal_line.cpp.

References Cabal::Connection::line().

Referenced by set().


The documentation for this class was generated from the following files:
Generated on Sat Apr 10 17:41:49 2004 for Cabal by doxygen 1.3.5