TrackerRequestSessionFactoryImpl.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2006-2007 by Peter Dimov.
00004 
00005 This file is part of Calitko (http://www.calitko.org).
00006 
00007 Calitko is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 Calitko is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Calitko; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 */
00022 
00023 #ifndef PROTOCOLS__BIT_TORRENT__TRACKERS__TRACKER_REQUEST_SESSION_FACTORY_IMPL_H
00024 #define PROTOCOLS__BIT_TORRENT__TRACKERS__TRACKER_REQUEST_SESSION_FACTORY_IMPL_H
00025 
00026 #include "Imports.h"
00027 #include "HttpRequestSession.h"
00028 #include "TrackerRequestSession.h"
00029 #include "TrackerRequestSessionFactory.h"
00030 
00031 namespace Protocols {
00032 namespace BitTorrent {
00033 namespace Trackers {
00034 
00036 
00058 class TrackerRequestSessionFactoryImpl : public TrackerRequestSessionFactory
00059 {
00060     CALITKO_TESTABLE
00061     REFERENCE_OBJECT (TrackerRequestSessionFactoryImpl)
00062 
00063 public:
00064                             TrackerRequestSessionFactoryImpl (
00065                                 TrackerRequestSessionFactoryStatus *);
00066                             ~TrackerRequestSessionFactoryImpl();
00067 
00068     TrackerRequestSession   *createSession (const Torrent &);
00069     void                    destroySession (TrackerRequestSession *);
00070 
00071     uint                    holdedSessionsCount() const;
00072 
00073     // Implementation for the TrackerRequestSessionStatus interface:
00074     void        trackerRequestSessionEstablished (TrackerRequestSession *);
00075     void        trackerRequestSessionError (TrackerRequestSession *,
00076                                             const QString &);
00077     void        trackerRequestSessionResponseRecieved (TrackerRequestSession *,
00078                                                        const TrackerResponse &);
00079     void        trackerRequestSessionClosing (TrackerRequestSession *);
00080     void        trackerRequestSessionClosed (TrackerRequestSession *);
00081 
00082 private:
00083     bool        isHoldedSession (TrackerRequestSession *) const;
00084 
00085 private:
00087     typedef QPair <HttpRequestSession *, TrackerRequestSessionStatus *>
00088         TrackerRequestSessionData;
00090     typedef QMap <TrackerRequestSession *, TrackerRequestSessionData>
00091         TrackerRequestSessionsWithDataStorage;
00092 
00093     TrackerRequestSessionFactoryStatus      *status_;
00094     TrackerRequestSessionsWithDataStorage   sessionsStorage_;
00095 };
00096 
00097 } // namespace Trackers
00098 } // namespace BitTorrent
00099 } // namespace Protocols
00100 
00101 #endif // PROTOCOLS__BIT_TORRENT__TRACKERS__TRACKER_REQUEST_SESSION_FACTORY_IMPL_H