#include <cabal_line.h>
Inheritance diagram for Cabal::Line:
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. | |
Connection * | set (const int conId, Connection *con) |
Sets a certain connection ID to a determined connection object. | |
Connection * | get (const int conId) const |
Retreives a certain connection given its ID. | |
Connection * | set (const std::string &conName, Connection *con) |
Sets a certain named connection to a determined connection object. | |
Connection * | get (const std::string &conName) const |
Retreives a certain connection given its name. | |
Connection * | set (const char *conName, Connection *con) |
Sets the connection by name. | |
Connection * | get (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. |
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.
Definition at line 93 of file cabal_line.h.
|
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.
Definition at line 28 of file ltlib/cabal_line.cpp. |
|
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.
Definition at line 43 of file ltlib/cabal_line.cpp. |
|
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. |
|
Gets the connection by name. Inline to get( std::string & ).
Definition at line 210 of file cabal_line.h. References get(). |
|
Retreives a certain connection given its name. May return 0 if there isn't any connection with the given name.
Definition at line 108 of file ltlib/cabal_line.cpp. |
|
Retreives a certain connection given its ID. May return 0 if the connection object for given ID is not mapped.
Definition at line 101 of file ltlib/cabal_line.cpp. Referenced by get(). |
|
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(). |
|
Sets the connection by name. Inline to set( std::string &, Connection * ).
Definition at line 197 of file cabal_line.h. References set(). |
|
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.
Definition at line 84 of file ltlib/cabal_line.cpp. References Cabal::Connection::line(). |
|
Sets a certain connection ID to a determined connection object. If the connection ID was previously referencing another connection, this is deleted.
Definition at line 73 of file ltlib/cabal_line.cpp. References Cabal::Connection::line(). Referenced by set(). |