1 // QoS_Session_Factory.cpp
2 #include "QoS_Session_Factory.h"
3 #include "QoS_Session_Impl.h"
4 #include "ace/Log_Category.h"
6 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
8 ACE_ALLOC_HOOK_DEFINE(ACE_QoS_Session_Factory
)
10 #if defined(ACE_HAS_RAPI)
11 const enum ACE_QoS_Session_Factory::ACE_QoS_Session_Type
12 ACE_QoS_Session_Factory::ACE_DEFAULT_QOS_SESSION
= ACE_QoS_Session_Factory::ACE_RAPI_SESSION
;
13 #elif defined(ACE_HAS_WINSOCK2_GQOS)
14 const enum ACE_QoS_Session_Factory::ACE_QoS_Session_Type
15 ACE_QoS_Session_Factory::ACE_DEFAULT_QOS_SESSION
= ACE_QoS_Session_Factory::ACE_GQOS_SESSION
;
17 # error "QoS type not supported. Cannot build."
18 #endif /* ACE_HAS_RAPI */
20 ACE_QoS_Session_Factory::ACE_QoS_Session_Factory ()
22 ACE_TRACE ("ACE_QoS_Session_Factory::ACE_QoS_Session_Factory");
25 ACE_QoS_Session_Factory::~ACE_QoS_Session_Factory ()
27 ACE_TRACE ("ACE_QoS_Session_Factory::~ACE_QoS_Session_Factory");
30 // Create a QoS session of the given type (RAPI or GQoS).
32 ACE_QoS_Session_Factory::create_session (ACE_QoS_Session_Type qos_session_type
)
34 ACE_QoS_Session
* qos_session
= 0;
36 #if defined (ACE_HAS_RAPI)
37 if (qos_session_type
== ACE_RAPI_SESSION
)
38 ACE_NEW_RETURN (qos_session
,
41 #endif /* ACE_HAS_RAPI */
43 if (qos_session_type
== ACE_GQOS_SESSION
)
44 ACE_NEW_RETURN (qos_session
,
48 if (this->add_session (qos_session
) == -1)
51 ACELIB_ERROR_RETURN ((LM_ERROR
,
52 ACE_TEXT ("Error in adding session\n")),
59 // Destroy the QoS Session.
61 ACE_QoS_Session_Factory::destroy_session (ACE_QoS_Session
*qos_session
)
63 if ((qos_session
!= 0) && (this->remove_session (qos_session
) == -1))
64 ACELIB_ERROR_RETURN ((LM_ERROR
,
65 ACE_TEXT ("Error in destroying session\n")),
71 // Add a session to the set of sessions created by this factory. This is a
72 // private method called by the create_session ().
74 ACE_QoS_Session_Factory::add_session (ACE_QoS_Session
*qos_session
)
76 if (this->qos_session_set_
.insert (qos_session
) != 0)
77 ACELIB_ERROR_RETURN ((LM_ERROR
,
78 ACE_TEXT ("Error in adding a new session")
79 ACE_TEXT ("to the session set\n")),
85 // Remove a session from the set of sessions created by this factory. This is
86 // a private method called by the destroy_session ().
88 ACE_QoS_Session_Factory::remove_session (ACE_QoS_Session
*qos_session
)
90 if (this->qos_session_set_
.remove (qos_session
) == -1)
91 ACELIB_ERROR_RETURN ((LM_ERROR
,
92 ACE_TEXT ("Error in removing a session")
93 ACE_TEXT ("from the session set\n")),
99 ACE_END_VERSIONED_NAMESPACE_DECL