Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

QoS_Session_Factory.cpp

Go to the documentation of this file.
00001 // QoS_Session_Factory.cpp
00002 // $Id: QoS_Session_Factory.cpp,v 1.1.1.2 2003/02/21 18:36:32 chad Exp $
00003 
00004 #include "QoS_Session_Factory.h"
00005 #include "QoS_Session_Impl.h"
00006 #include "ace/Log_Msg.h"
00007 
00008 ACE_RCSID(ace, QoS_Session_Factory, "$Id: QoS_Session_Factory.cpp,v 1.1.1.2 2003/02/21 18:36:32 chad Exp $")
00009 
00010 ACE_ALLOC_HOOK_DEFINE(ACE_QoS_Session_Factory)
00011 
00012 #if defined(ACE_HAS_RAPI)
00013 const enum ACE_QoS_Session_Factory::ACE_QoS_Session_Type
00014   ACE_QoS_Session_Factory::ACE_DEFAULT_QOS_SESSION = ACE_QoS_Session_Factory::ACE_RAPI_SESSION;
00015 #elif defined(ACE_HAS_WINSOCK2_GQOS)
00016   const enum ACE_QoS_Session_Factory::ACE_QoS_Session_Type
00017   ACE_QoS_Session_Factory::ACE_DEFAULT_QOS_SESSION = ACE_QoS_Session_Factory::ACE_GQOS_SESSION;
00018 #else
00019 #  error "QoS type not supported.  Cannot build."
00020 #endif /* ACE_HAS_RAPI */ 
00021 
00022 ACE_QoS_Session_Factory::ACE_QoS_Session_Factory (void)
00023 {
00024   ACE_TRACE ("ACE_QoS_Session_Factory::ACE_QoS_Session_Factory");
00025 }
00026 
00027 ACE_QoS_Session_Factory::~ACE_QoS_Session_Factory (void)
00028 {
00029   ACE_TRACE ("ACE_QoS_Session_Factory::~ACE_QoS_Session_Factory");
00030 }
00031 
00032 // Create a QoS session of the given type (RAPI or GQoS).
00033 ACE_QoS_Session *
00034 ACE_QoS_Session_Factory::create_session (ACE_QoS_Session_Type qos_session_type)
00035 {
00036 
00037   ACE_QoS_Session * qos_session = 0;
00038 
00039 #if defined (ACE_HAS_RAPI)
00040   if (qos_session_type == ACE_RAPI_SESSION)
00041     ACE_NEW_RETURN (qos_session,
00042                     ACE_RAPI_Session,
00043                     0);
00044 #endif /* ACE_HAS_RAPI */
00045 
00046   if (qos_session_type == ACE_GQOS_SESSION)
00047     ACE_NEW_RETURN (qos_session,
00048                     ACE_GQoS_Session,
00049                     0);
00050 
00051   if (this->add_session (qos_session) == -1)
00052     {
00053       delete qos_session;
00054       ACE_ERROR_RETURN ((LM_ERROR,
00055                          ACE_LIB_TEXT ("Error in adding session\n")),
00056                         0);
00057     }
00058 
00059   return qos_session;
00060 }
00061 
00062 // Destroy the QoS Session.
00063 int
00064 ACE_QoS_Session_Factory::destroy_session (ACE_QoS_Session *qos_session)
00065 {
00066 
00067   if ((qos_session != 0) && (this->remove_session (qos_session) == -1))
00068     ACE_ERROR_RETURN ((LM_ERROR,
00069                        ACE_LIB_TEXT ("Error in destroying session\n")),
00070                       -1);
00071 
00072   return 0;
00073 }
00074 
00075 // Add a session to the set of sessions created by this factory. This is a
00076 // private method called by the create_session ().
00077 int
00078 ACE_QoS_Session_Factory::add_session (ACE_QoS_Session *qos_session)
00079 {
00080   if (this->qos_session_set_.insert (qos_session) != 0)
00081     ACE_ERROR_RETURN ((LM_ERROR,
00082                        ACE_LIB_TEXT ("Error in adding a new session")
00083                        ACE_LIB_TEXT ("to the session set\n")),
00084                       -1);
00085 
00086   return 0;
00087 }
00088 
00089 // Remove a session from the set of sessions created by this factory. This is
00090 // a private method called by the destroy_session ().
00091 int
00092 ACE_QoS_Session_Factory::remove_session (ACE_QoS_Session *qos_session)
00093 {
00094   if (this->qos_session_set_.remove (qos_session) == -1)
00095     ACE_ERROR_RETURN ((LM_ERROR,
00096                        ACE_LIB_TEXT ("Error in removing a session")
00097                        ACE_LIB_TEXT ("from the session set\n")),
00098                       -1);
00099 
00100   return 0;
00101 }

Generated on Mon Jun 16 13:17:26 2003 for ACE_QoS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002