summaryrefslogtreecommitdiff
path: root/TAO/tao/DynamicInterface/DII_Arguments.cpp
blob: 3ecfa63d85bfcd51234b70022dbdd78aa3661d43 (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
// $Id$

#include "tao/DynamicInterface/DII_Arguments.h"

#include "tao/AnyTypeCode/NVList.h"
#include "tao/AnyTypeCode/Any_Impl.h"
#include "tao/AnyTypeCode/DynamicC.h"
#include "tao/Exception.h"
#include "tao/CDR.h"


ACE_RCSID (DynamicInterface,
           DII_Arguments,
           "$Id$")

#if !defined (__ACE_INLINE__)
# include "tao/DynamicInterface/DII_Arguments.inl"
#endif /* ! __ACE_INLINE__ */

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  CORBA::Boolean
  NamedValue_Argument::demarshal (TAO_InputCDR &cdr)
  {
    try
      {
        if (this->x_ !=0 && this->x_->value ()->impl ())
          {
            this->x_->value ()->impl ()->_tao_decode (cdr
                                                     );
          }
      }
    catch ( ::CORBA::Exception&)
      {
        return false;
      }

    this->byte_order_ = cdr.byte_order ();

    return true;
  }

  void
  NamedValue_Argument::interceptor_value (CORBA::Any *any) const
  {
    (*any) <<= *this->x_->value ();
  }

  // ========================================================================

  CORBA::Boolean
  NVList_Argument::marshal (TAO_OutputCDR &cdr)
  {
    try
      {
        this->x_->_tao_encode (cdr,
                               CORBA::ARG_IN | CORBA::ARG_INOUT
                              );
      }
    catch ( ::CORBA::Exception&)
      {
        return false;
      }

    return true;
  }

  CORBA::Boolean
  NVList_Argument::demarshal (TAO_InputCDR &cdr)
  {

    try
      {
        // Now, get all the "return", "out", and "inout" parameters
        // from the response message body ... return parameter is
        // first, the rest are in the order defined in the IDL spec
        // (which is also the order that DII users are required to
        // use).

        this->x_->_tao_incoming_cdr (
            cdr,
            CORBA::ARG_OUT | CORBA::ARG_INOUT,
            this->lazy_evaluation_
           );
      }
    catch ( ::CORBA::Exception&)
      {
        return false;
      }

    return true;
  }

  void
  NVList_Argument::interceptor_paramlist (Dynamic::ParameterList *lst)
  {
    CORBA::ULong const len = this->x_->count ();
    lst->length (len);

    for (CORBA::ULong i = 0; i < len; ++i)
      {
        if (!this->x_->item (i)->value ())
          return;

        (*lst)[i].argument.replace (
          this->x_->item (i)->value ()->impl ());

        switch (this->x_->item (i)->flags ())
          {
          case CORBA::ARG_IN:
            {
              (*lst)[i].mode = CORBA::PARAM_IN;
              break;
            }
          case CORBA::ARG_INOUT:
            {
              (*lst)[i].mode = CORBA::PARAM_INOUT;
              break;
            }
          case CORBA::ARG_OUT:
            {
              (*lst)[i].mode = CORBA::PARAM_OUT;
              break;
            }
          default:
            break;
          }
      }
  }
}

TAO_END_VERSIONED_NAMESPACE_DECL