Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / QoS / QoS_Session_Factory.cpp
blob3ff403db99d8a5e87bdce79723c51bfd084d1b98
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;
16 #else
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).
31 ACE_QoS_Session *
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,
39 ACE_RAPI_Session,
40 0);
41 #endif /* ACE_HAS_RAPI */
43 if (qos_session_type == ACE_GQOS_SESSION)
44 ACE_NEW_RETURN (qos_session,
45 ACE_GQoS_Session,
46 0);
48 if (this->add_session (qos_session) == -1)
50 delete qos_session;
51 ACELIB_ERROR_RETURN ((LM_ERROR,
52 ACE_TEXT ("Error in adding session\n")),
53 0);
56 return qos_session;
59 // Destroy the QoS Session.
60 int
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")),
66 -1);
68 return 0;
71 // Add a session to the set of sessions created by this factory. This is a
72 // private method called by the create_session ().
73 int
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")),
80 -1);
82 return 0;
85 // Remove a session from the set of sessions created by this factory. This is
86 // a private method called by the destroy_session ().
87 int
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")),
94 -1);
96 return 0;
99 ACE_END_VERSIONED_NAMESPACE_DECL