Protocols::BitTorrent::Trackers::TrackerRequestSessionFactoryImpl Class Reference

#include <TrackerRequestSessionFactoryImpl.h> [code]

Inherits Protocols::BitTorrent::Trackers::TrackerRequestSessionFactory.

Inheritance diagram for Protocols::BitTorrent::Trackers::TrackerRequestSessionFactoryImpl:

Inheritance graph
[legend]
Collaboration diagram for Protocols::BitTorrent::Trackers::TrackerRequestSessionFactoryImpl:

Collaboration graph
[legend]
List of all members.

Detailed Description

Implementation of the TrackerRequestSessionFactory interface.

See TrackerRequestSessionFactory class (interface) description for more info about the purpose of this class.

It does not throw its own exceptions and lets any thrown exceptions through to the user. In case an exception (e.g. bad_alloc) gets thrown, the instance of this class will be left in an unchanged state. Thus, the class meets the strong guarantee of exception safety.

Todo:
What with the holdedSessionsCount() member function? It's not needed by users of this class, but it's needed in the tests (without it I can't test the destroySession() function behavior properly).
Todo:
Implement real HttpRequestSession and TrackerRequestSessionStatus instance creation in the createSession() member function. Now it's impossible to call any member function of the created session!
Todo:
After the DhtTrackerRequestSession is implemented we'll need to modify the TrackerRequestSessionData type (among others) because the session will definitely not need a HttpRequestSession instance in the ctor.

Definition at line 58 of file TrackerRequestSessionFactoryImpl.h.

Public Member Functions

 TrackerRequestSessionFactoryImpl (TrackerRequestSessionFactoryStatus *)
 Constructor.
 ~TrackerRequestSessionFactoryImpl ()
 Destructor.
TrackerRequestSessioncreateSession (const Torrent &)
 Creates a TrackerRequestSession according to the torrent.
void destroySession (TrackerRequestSession *)
 Destroys selected session.
uint holdedSessionsCount () const
void trackerRequestSessionEstablished (TrackerRequestSession *)
 Forwards the recieved notification to the factory notifications listener.
void trackerRequestSessionError (TrackerRequestSession *, const QString &)
 Forwards the recieved notification to the factory notifications listener.
void trackerRequestSessionResponseRecieved (TrackerRequestSession *, const TrackerResponse &)
 Forwards the recieved notification to the factory notifications listener.
void trackerRequestSessionClosing (TrackerRequestSession *)
 Forwards the recieved notification to the factory notifications listener.
void trackerRequestSessionClosed (TrackerRequestSession *)
 Forwards the recieved notification to the factory notifications listener.

Private Types

typedef QPair< HttpRequestSession *,
TrackerRequestSessionStatus * > 
TrackerRequestSessionData
 Data passed to sessions ctors.
typedef QMap< TrackerRequestSession *,
TrackerRequestSessionData
TrackerRequestSessionsWithDataStorage
 Storage of sessions with their data.

Private Member Functions

CALITKO_TESTABLE TrackerRequestSessionFactoryImpl (const TrackerRequestSessionFactoryImpl &)
TrackerRequestSessionFactoryImploperator= (const TrackerRequestSessionFactoryImpl &)
bool isHoldedSession (TrackerRequestSession *) const
 Check whether the selected session is currently "holded" by the factory.

Private Attributes

TrackerRequestSessionFactoryStatusstatus_
TrackerRequestSessionsWithDataStorage sessionsStorage_


Member Typedef Documentation

typedef QPair<HttpRequestSession *, TrackerRequestSessionStatus *> Protocols::BitTorrent::Trackers::TrackerRequestSessionFactoryImpl::TrackerRequestSessionData [private]
 

Data passed to sessions ctors.

Definition at line 88 of file TrackerRequestSessionFactoryImpl.h.

typedef QMap<TrackerRequestSession *, TrackerRequestSessionData> Protocols::BitTorrent::Trackers::TrackerRequestSessionFactoryImpl::TrackerRequestSessionsWithDataStorage [private]
 

Storage of sessions with their data.

Definition at line 91 of file TrackerRequestSessionFactoryImpl.h.


Constructor & Destructor Documentation

CALITKO_TESTABLE Protocols::BitTorrent::Trackers::TrackerRequestSessionFactoryImpl::TrackerRequestSessionFactoryImpl const TrackerRequestSessionFactoryImpl  )  [private]
 

TrackerRequestSessionFactoryImpl::TrackerRequestSessionFactoryImpl TrackerRequestSessionFactoryStatus trackerRequestFactorySessionStatus  ) 
 

Constructor.

Parameters:
trackerRequestFactorySessionStatus Notifications listener.
Constructs a TrackerRequestSessionFactoryImpl object. No status notifications are sent.

Definition at line 36 of file TrackerRequestSessionFactoryImpl.cpp.

TrackerRequestSessionFactoryImpl::~TrackerRequestSessionFactoryImpl  ) 
 

Destructor.

Destroys a TrackerRequestSessionFactoryImpl object. No status notifications are sent.

Definition at line 48 of file TrackerRequestSessionFactoryImpl.cpp.


Member Function Documentation

TrackerRequestSession * TrackerRequestSessionFactoryImpl::createSession const Torrent torrent  )  [virtual]
 

Creates a TrackerRequestSession according to the torrent.

Parameters:
torrent Non-empty Torrent instance.
Precondition:
torrent must be non-empty, e.g. != Torrent().
Created session is owned by the factory and it must be destroyed by calling the destroySession() member function. Destroying the session differently (e.g. by calling operator delete) results in undefined behavior! No status notifications are sent.

See also:
destroySession()

Implements Protocols::BitTorrent::Trackers::TrackerRequestSessionFactory.

Definition at line 67 of file TrackerRequestSessionFactoryImpl.cpp.

void TrackerRequestSessionFactoryImpl::destroySession TrackerRequestSession session  )  [virtual]
 

Destroys selected session.

Parameters:
session TrackerRequestSession instance created by this factory.
Precondition:
session must be a session that was created by this factory and wasn't destroyed yet.
No status notifications are sent.

Note:
After the session is destroyed the pointer to it becomes invalid.
See also:
createSession()

Implements Protocols::BitTorrent::Trackers::TrackerRequestSessionFactory.

Definition at line 114 of file TrackerRequestSessionFactoryImpl.cpp.

uint TrackerRequestSessionFactoryImpl::holdedSessionsCount  )  const
 

"Holded" means that they (sessions) were created by this factory (instance) and were not destroyed yet. No status notifications are sent.

Definition at line 130 of file TrackerRequestSessionFactoryImpl.cpp.

bool TrackerRequestSessionFactoryImpl::isHoldedSession TrackerRequestSession session  )  const [private]
 

Check whether the selected session is currently "holded" by the factory.

Parameters:
session TrackerRequestSession instance that was created by this factory.
Returns:
true if the session is currently "holded" by the factory.

false otherwise.

Definition at line 234 of file TrackerRequestSessionFactoryImpl.cpp.

TrackerRequestSessionFactoryImpl& Protocols::BitTorrent::Trackers::TrackerRequestSessionFactoryImpl::operator= const TrackerRequestSessionFactoryImpl  )  [private]
 

void TrackerRequestSessionFactoryImpl::trackerRequestSessionClosed TrackerRequestSession session  ) 
 

Forwards the recieved notification to the factory notifications listener.

Parameters:
session TrackerRequestSession instance created by this factory.
Precondition:
session must be a session that was created by this factory and wasn't destroyed yet.
trackerRequestSessionFactorySessionClosed() status notification will be called.

Definition at line 220 of file TrackerRequestSessionFactoryImpl.cpp.

void TrackerRequestSessionFactoryImpl::trackerRequestSessionClosing TrackerRequestSession session  ) 
 

Forwards the recieved notification to the factory notifications listener.

Parameters:
session TrackerRequestSession instance created by this factory.
Precondition:
session must be a session that was created by this factory and wasn't destroyed yet.
trackerRequestSessionFactorySessionClosing() status notification will be called.

Definition at line 202 of file TrackerRequestSessionFactoryImpl.cpp.

void TrackerRequestSessionFactoryImpl::trackerRequestSessionError TrackerRequestSession session,
const QString &  errorMessage
 

Forwards the recieved notification to the factory notifications listener.

Parameters:
session TrackerRequestSession instance created by this factory.
errorMessage Error message containing the session failure reason.
Precondition:
session must be a session that was created by this factory and wasn't destroyed yet.
trackerRequestSessionFactorySessionError() status notification will be called.

Definition at line 164 of file TrackerRequestSessionFactoryImpl.cpp.

void TrackerRequestSessionFactoryImpl::trackerRequestSessionEstablished TrackerRequestSession session  ) 
 

Forwards the recieved notification to the factory notifications listener.

Parameters:
session TrackerRequestSession instance created by this factory.
Precondition:
session must be a session that was created by this factory and wasn't destroyed yet.
trackerRequestSessionFactorySessionEstablished() status notification will be called.

Definition at line 145 of file TrackerRequestSessionFactoryImpl.cpp.

void TrackerRequestSessionFactoryImpl::trackerRequestSessionResponseRecieved TrackerRequestSession session,
const TrackerResponse trackerResponse
 

Forwards the recieved notification to the factory notifications listener.

Parameters:
session TrackerRequestSession instance created by this factory.
trackerResponse Recieved tracker response by the session.
Precondition:
session must be a session that was created by this factory and wasn't destroyed yet.
trackerRequestSessionFactoryResponseRecieved() status notification will be called.

Definition at line 183 of file TrackerRequestSessionFactoryImpl.cpp.


Member Data Documentation

TrackerRequestSessionsWithDataStorage Protocols::BitTorrent::Trackers::TrackerRequestSessionFactoryImpl::sessionsStorage_ [private]
 

Definition at line 94 of file TrackerRequestSessionFactoryImpl.h.

TrackerRequestSessionFactoryStatus* Protocols::BitTorrent::Trackers::TrackerRequestSessionFactoryImpl::status_ [private]
 

Definition at line 93 of file TrackerRequestSessionFactoryImpl.h.


The documentation for this class was generated from the following files: