summaryrefslogtreecommitdiff
path: root/TAO/tao/DynamicInterface/Dynamic_Implementation.h
blob: 7e7ed6c0c672a0a9a205a3be9f49e74eb41a193d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// This may look like C, but it's really -*- C++ -*-
// $Id$

// ============================================================================
//
// = LIBRARY
//    DynamicInterface
//
// = FILENAME
//    Dynamic_Implementation.h
//
// = DESCRIPTION
//    Header file for class TAO_DynamicImplementation.
//
// = AUTHOR
//    Irfan Pyarali <irfan@cs.wustl.edu>
//
// ============================================================================

#ifndef TAO_DYNAMIC_IMPLEMENTATION_H
#define TAO_DYNAMIC_IMPLEMENTATION_H

#include /**/ "ace/pre.h"

#include "dynamicinterface_export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "tao/PortableServer/Servant_Base.h"

namespace CORBA
{
  typedef char *RepositoryId;
  typedef String_var RepositoryId_var;

  class ServerRequest;
  typedef ServerRequest *ServerRequest_ptr;
}

/**
 * @class TAO_DynamicImplementation
 *
 * @brief Base class for DSI.
 *
 * It is expected that the <invoke> and <_primary_interface>
 * methods will be only invoked by the POA in the context of
 * serving a CORBA request. Invoking this method in other
 * circumstances may lead to unpredictable results.
 */
class TAO_DynamicInterface_Export TAO_DynamicImplementation
  : public virtual TAO_ServantBase
{
public:
  /// The invoke() method receives requests issued to any CORBA object
  /// incarnated by the DSI servant and performs the processing
  /// necessary to execute the request.
  virtual void invoke (CORBA::ServerRequest_ptr request
                       ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0;

  /// The _primary_interface() method receives an ObjectId value and a
  /// POA_ptr as input parameters and returns a valid RepositoryId
  /// representing the most-derived interface for that oid.
  virtual CORBA::RepositoryId _primary_interface (
      const PortableServer::ObjectId &oid,
      PortableServer::POA_ptr poa
      ACE_ENV_ARG_DECL_WITH_DEFAULTS
    ) = 0;

  /// Local implementation of the CORBA::Object::_is_a method.
  virtual CORBA::Boolean _is_a (const char *logical_type_id
                                ACE_ENV_ARG_DECL_WITH_DEFAULTS);

  /// Returns a CORBA::Object_ptr for the target object.
  CORBA::Object_ptr _this (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);

  /// Query the Interface Repository for the interface definition.
  virtual CORBA::InterfaceDef_ptr _get_interface (
      ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
    );

protected:

  /// Return 0.  Should never be used.
  virtual const char *_interface_repository_id (void) const;

  /// Simply returns "this"
  virtual void *_downcast (const char *repository_id);

  /// This is an auxiliary method for _this() and _narrow().
  virtual TAO_Stub *_create_stub (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);

  /// Turns around and calls invoke.
  virtual void _dispatch (TAO_ServerRequest &request,
                          void *context
                          ACE_ENV_ARG_DECL_WITH_DEFAULTS);

private:
  /// Encapsulates code common to _is_a(), _get_interface() and _create_stub().
  CORBA::RepositoryId get_id_from_primary_interface (
      ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
    );
};

#include /**/ "ace/post.h"

#endif /* TAO_DYNAMIC_IMPLEMENTATION_H */