Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / tao / Abstract_Servant_Base.h
blob2fb670808a48af72ac57db145f0c1a84de270827
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Abstract_Servant_Base.h
7 * This files contains the TAO_Abstract_ServantBase, which is used
8 * as a way to decouple the PortableServer from the TAO Core,
9 * and make it possible to keep the reference to the servant in
10 * the CORBA::Object class.
12 * @author Angelo Corsaro <corsaro@cs.wustl.edu>
14 //=============================================================================
16 #ifndef TAO_ABSTRACT_SERVANT_BASE_H_
17 #define TAO_ABSTRACT_SERVANT_BASE_H_
19 #include /**/ "ace/pre.h"
21 #include /**/ "tao/TAO_Export.h"
23 #if !defined (ACE_LACKS_PRAGMA_ONCE)
24 # pragma once
25 #endif /* ACE_LACKS_PRAGMA_ONCE */
27 #include "tao/Basic_Types.h"
28 #include "tao/Collocation_Strategy.h"
29 #include "tao/CORBA_methods.h"
30 #include "tao/Pseudo_VarOut_T.h"
32 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
34 class TAO_ServerRequest;
35 class TAO_Stub;
36 class TAO_Abstract_ServantBase;
37 class TAO_ServantBase;
39 namespace CORBA
41 class InterfaceDef;
42 typedef InterfaceDef *InterfaceDef_ptr;
44 class Object;
45 typedef Object *Object_ptr;
46 typedef TAO_Pseudo_Var_T<Object> Object_var;
47 typedef TAO_Pseudo_Out_T<Object> Object_out;
50 namespace TAO
52 class Argument;
54 namespace Portable_Server
56 class Servant_Upcall;
60 typedef void (*TAO_Skeleton)(
61 TAO_ServerRequest &,
62 TAO::Portable_Server::Servant_Upcall *,
63 TAO_ServantBase *);
65 typedef void (*TAO_Collocated_Skeleton)(
66 TAO_Abstract_ServantBase *,
67 TAO::Argument **);
69 class TAO_Export TAO_Abstract_ServantBase
71 public:
72 /// Destructor
73 virtual ~TAO_Abstract_ServantBase (void);
75 /// Local implementation of the CORBA::Object::_is_a method.
76 virtual CORBA::Boolean _is_a (const char* logical_type_id) = 0;
78 #if (TAO_HAS_MINIMUM_CORBA == 0)
79 /// Default @c _non_existent: always returns false.
80 virtual CORBA::Boolean _non_existent (void) = 0;
82 #if !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO)
83 /// Query the Interface Repository.
84 virtual CORBA::InterfaceDef_ptr _get_interface (void) = 0;
86 /// Default @c _get_component: always returns nil.
87 virtual CORBA::Object_ptr _get_component (void) = 0;
88 #endif
90 /// Default @c _repository_id
91 virtual char * _repository_id (void) = 0;
92 #endif /* TAO_HAS_MINIMUM_CORBA */
94 //@{
95 /**
96 * @name Reference Counting Operations
98 /// Increase reference count by one.
99 virtual void _add_ref (void) = 0;
102 * Decreases reference count by one; if the resulting reference
103 * count equals zero, _remove_ref invokes delete on its this pointer
104 * in order to destroy the servant.
106 virtual void _remove_ref (void) = 0;
108 /// Returns the current reference count value.
109 virtual CORBA::ULong _refcount_value (void) const = 0;
110 //@}
112 /// This is an auxiliary method for _this() and _narrow().
113 virtual TAO_Stub *_create_stub (void) = 0;
115 /// Find an operation in the operation table and return a
116 /// TAO_Skeleton which can be used to make upcalls
117 virtual int _find (const char *opname,
118 TAO_Skeleton &skelfunc,
119 const size_t length = 0) = 0;
121 /// Find an operation in the operation table and return a
122 /// TAO_Collocated_Skeleton which can be used to make upcalls onto
123 /// collocated servants.
124 virtual int _find (const char *opname,
125 TAO_Collocated_Skeleton &skelfunc,
126 TAO::Collocation_Strategy s,
127 const size_t length = 0) = 0;
129 virtual void _collocated_dispatch (::CORBA::Object_ptr obj,
130 ::CORBA::Object_out forward_obj,
131 bool &is_forwarded,
132 TAO::Argument ** args,
133 int num_args,
134 const char * op,
135 size_t op_len,
136 TAO::Collocation_Strategy strategy) = 0;
138 protected:
139 /// Default constructor, only derived classes can be created.
140 TAO_Abstract_ServantBase (void);
142 /// Copy constructor, protected so no instances can be created.
143 TAO_Abstract_ServantBase (const TAO_Abstract_ServantBase &);
145 /// Assignment operator.
146 TAO_Abstract_ServantBase &operator= (const TAO_Abstract_ServantBase &);
148 /// Dispatches a request to the object
150 * Find the operation, cast the type to the most derived type,
151 * demarshall all the parameters from the request and finally
152 * invokes the operation, storing the results and out parameters (if
153 * any) or the exceptions thrown into @a request.
155 virtual void _dispatch (
156 TAO_ServerRequest &request,
157 TAO::Portable_Server::Servant_Upcall *servant_upcall) = 0;
159 /// Get this interface's repository id (TAO specific).
160 virtual const char *_interface_repository_id (void) const = 0;
163 TAO_END_VERSIONED_NAMESPACE_DECL
165 #if defined(__ACE_INLINE__)
166 #include "tao/Abstract_Servant_Base.inl"
167 #endif /* __ACE_INLINE__ */
169 #include /**/ "ace/post.h"
171 #endif /* TAO_ABSTRACT_SERVANT_BASE_H_ */