summaryrefslogtreecommitdiff
path: root/TAO/tao/PortableServer/get_arg.h
blob: 38c21f200c939ac4dc1e55428ff1843467e7ff3d (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// -*- C++ -*-

//=============================================================================
/**
 *  @file get_arg.h
 *
 *  $Id$
 *
 *  Thru-POA/skeleton argument selection function templates.
 *  @par
 *  These function templates are used to choose between arguments
 *  supplied in thru-POA collocated invocations and arguments in
 *  uncollocated invocations.
 *
 *  @note A function template approach is used to avoid complicated
 *        argument conversions between stub supplied arguments and
 *        skeleton supplied ones.  For example, it is possible to make
 *        argument selection more transparent by taking advantage of
 *        run-time polymorphism.  However, that approach would incur
 *        additional footprint overhead on the client side due to the
 *        introduction of virtual tables, etc.
 *
 *  @author  Ossama Othman
 */
//=============================================================================

#ifndef TAO_GET_ARG_H
#define TAO_GET_ARG_H

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

#include "tao/operation_details.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  namespace Portable_Server
  {

    /// Get return value/argument.
    /**
     * @note It is possible to determine the return argument type
     *       using typedef traits found in the TAO::SArg_Traits<>
     *       template.  However, MSVC++ 6 does not support them
     *       properly.  Until we drop MSVC++ 6 support, we'll have to
     *       pass the return argument type in an additional template
     *       parameter.
     *
     * @todo Drop second template parameter, and replace
     *       " @c RET_ARG_TYPE " return type with
     *       " @c typename TAO::SArg_Traits<T>::ret_arg_type ".
     */
    template<typename T, typename RET_ARG_TYPE>
    RET_ARG_TYPE
    get_ret_arg (TAO_Operation_Details const * details,
                 TAO::Argument * const * skel_args)
    {
      return
        details
        ? static_cast<typename TAO::Arg_Traits<T>::ret_val *> (
            details->args ()[0])->arg ()
        : static_cast<typename TAO::SArg_Traits<T>::ret_val *> (
            skel_args[0])->arg ();
    }

    /// Get "in" argument.
    /**
     * @see @c get_ret_arg note to understand why we currently use a
     *      second template parameter.
     *
     * @todo Drop second template parameter, and replace
     *       " @c IN_ARG_TYPE " return type with
     *       " @c typename TAO::SArg_Traits<T>::in_arg_type ".
     */
    template<typename T, typename IN_ARG_TYPE>
    IN_ARG_TYPE
    get_in_arg (TAO_Operation_Details const * details,
                TAO::Argument * const * skel_args,
                size_t i)
    {
      return
        (details != 0 && details->args () != 0)
        ? static_cast<typename TAO::Arg_Traits<T>::in_arg_val *> (
            details->args ()[i])->arg ()
        : static_cast<typename TAO::SArg_Traits<T>::in_arg_val *> (
            skel_args[i])->arg ();
    }

    /// Get "inout" argument.
    /**
     * @see @c get_ret_arg note to understand why we currently use a
     *      second template parameter.
     *
     * @todo Drop second template parameter, and replace
     *       " @c INOUT_ARG_TYPE " return type with
     *       " @c typename TAO::SArg_Traits<T>::inout_arg_type ".
     */
    template<typename T, typename INOUT_ARG_TYPE>
    INOUT_ARG_TYPE
    get_inout_arg (TAO_Operation_Details const * details,
                   TAO::Argument * const * skel_args,
                   size_t i)
    {
      return
        details
        ? static_cast<typename TAO::Arg_Traits<T>::inout_arg_val *> (
            details->args ()[i])->arg ()
        : static_cast<typename TAO::SArg_Traits<T>::inout_arg_val *> (
            skel_args[i])->arg ();
    }

    /// Get "out" argument.
    /**
     * @see @c get_ret_arg note to understand why we currently use a
     *      second template parameter.
     *
     * @todo Drop second template parameter, and replace
     *       " @c OUT_ARG_TYPE " return type with
     *       " @c typename TAO::SArg_Traits<T>::out_arg_type ".
     */
    template<typename T, typename OUT_ARG_TYPE>
    OUT_ARG_TYPE
    get_out_arg (TAO_Operation_Details const * details,
                 TAO::Argument * const * skel_args,
                 size_t i)
    {
      return
        details
        ? static_cast<typename TAO::Arg_Traits<T>::out_arg_val *> (
            details->args ()[i])->arg ()
        : static_cast<typename TAO::SArg_Traits<T>::out_arg_val *> (
            skel_args[i])->arg ();
    }

  }
}

TAO_END_VERSIONED_NAMESPACE_DECL

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

#endif  /* TAO_GET_ARG_H*/