Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / CSD_Framework / CSD_Strategy_Base.h
blobbe497e1797060dcbce7e89f65bdfd3e4d6ca7e46
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file CSD_Strategy_Base.h
7 * @author Tim Bradley <bradley_t@ociweb.com>
8 */
9 //=============================================================================
11 #ifndef TAO_CSD_FW_CUSTOM_SERVANT_DISPATCHING_STRATEGY_H
12 #define TAO_CSD_FW_CUSTOM_SERVANT_DISPATCHING_STRATEGY_H
14 #include /**/ "ace/pre.h"
16 #include "tao/CSD_Framework/CSD_FW_Export.h"
18 #include "tao/PortableServer/PortableServer.h"
19 #include "tao/PortableServer/Servant_Upcall.h"
20 #include "tao/PortableServer/Servant_Base.h"
21 #include "tao/TAO_Server_Request.h"
22 #include "tao/LocalObject.h"
25 #if !defined (ACE_LACKS_PRAGMA_ONCE)
26 # pragma once
27 #endif /* ACE_LACKS_PRAGMA_ONCE */
29 #include "tao/CSD_Framework/CSD_FrameworkC.h"
31 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
33 class TAO_Root_POA;
34 namespace PortableServer
36 class POAManager;
39 namespace TAO
41 namespace CSD
43 /**
44 * @class Strategy_Base
46 * @brief Base class for all Custom Servant Dispatching Strategies.
48 * This class serves as the base class for all "custom" strategies that
49 * perform servant dispatching. An instance of (a subclass of) this class
50 * can be applied to a POA object. Any servant requests for the POA will
51 * be "dispatched" to this strategy object.
54 class TAO_CSD_FW_Export Strategy_Base
55 : public CSD_Framework::Strategy,
56 public ::CORBA::LocalObject
58 public:
59 /// Result Type for dispatching method(s).
60 enum DispatchResult
62 // The request dispatching has been handled.
63 DISPATCH_HANDLED,
65 // The request dispatching has been rejected.
66 DISPATCH_REJECTED,
68 // Defer to "default" dispatching strategy (use the caller's thread).
69 DISPATCH_DEFERRED
72 /// Virtual Destructor.
73 virtual ~Strategy_Base();
75 /// This method is invoked to "attach" this strategy object to
76 /// the supplied POA. Returns true for success, and false for failure.
77 CORBA::Boolean apply_to(PortableServer::POA_ptr poa );
79 protected:
80 /// Default Constructor.
81 Strategy_Base();
83 /// Subclass provides implementation to dispatch a remote request.
84 virtual DispatchResult dispatch_remote_request_i
85 (TAO_ServerRequest& server_request,
86 const PortableServer::ObjectId& object_id,
87 PortableServer::POA_ptr poa,
88 const char* operation,
89 PortableServer::Servant servant) = 0;
91 /// Subclass provides implementation to dispatch a collocated request.
92 virtual DispatchResult dispatch_collocated_request_i
93 (TAO_ServerRequest& server_request,
94 const PortableServer::ObjectId& object_id,
95 PortableServer::POA_ptr poa,
96 const char* operation,
97 PortableServer::Servant servant) = 0;
99 /// Event - The POA has been activated.
100 virtual bool poa_activated_event_i(TAO_ORB_Core& orb_core) = 0;
102 /// Event - The POA has been deactivated.
103 virtual void poa_deactivated_event_i() = 0;
105 /// Event - A servant has been activated.
106 virtual void servant_activated_event_i
107 (PortableServer::Servant servant,
108 const PortableServer::ObjectId& oid);
110 /// Event - A servant has been deactivated.
111 virtual void servant_deactivated_event_i
112 (PortableServer::Servant servant,
113 const PortableServer::ObjectId& oid);
115 private:
116 /// Only our friend, the proxy, is allowed to invoke our private operations.
117 /// This allows us to not pollute the public interface of the CSD Strategy_Base
118 /// subclasses with methods that should never be called (except by the
119 /// proxy, of course).
120 friend class Strategy_Proxy;
122 /// This CSD Strategy_Base has been asked to dispatch a (collocated or remote)
123 /// request.
124 void dispatch_request(TAO_ServerRequest& server_request,
125 ::TAO::Portable_Server::Servant_Upcall& upcall);
127 /// Event - The POA has been activated. This happens when the POA_Manager
128 /// is activated.
129 bool poa_activated_event(TAO_ORB_Core& orb_core);
131 /// Event - The POA has been deactivated. This happens when the
132 /// POAManager is deactivated, or when the POA is destroyed.
133 void poa_deactivated_event();
135 /// Event - A servant has been activated.
136 void servant_activated_event(PortableServer::Servant servant,
137 const PortableServer::ObjectId& oid);
139 /// Event - A servant has been deactivated. This also occurs when
140 /// the POA is destroyed.
141 void servant_deactivated_event(PortableServer::Servant servant,
142 const PortableServer::ObjectId& oid);
144 /// The POA to which this strategy has been applied.
145 ::PortableServer::POA_var poa_;
147 /// This flag indicates that the POA is currently active (true) or
148 /// currently inactive (false).
149 bool poa_activated_;
154 TAO_END_VERSIONED_NAMESPACE_DECL
156 #if defined (__ACE_INLINE__)
157 # include "tao/CSD_Framework/CSD_Strategy_Base.inl"
158 #endif /* __ACE_INLINE__ */
160 #include /**/ "ace/post.h"
162 #endif /* TAO_CSD_FW_CUSTOM_SERVANT_DISPATCHING_STRATEGY_H */