summaryrefslogtreecommitdiff
path: root/TAO/tao/AnyTypeCode/TypeCode_Case_Base_T.cpp
blob: 9e5215d71fd46064df50022312b0965b67abcb77 (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
#ifndef TAO_TYPECODE_CASE_CPP
#define TAO_TYPECODE_CASE_CPP

#include "tao/AnyTypeCode/TypeCode_Case_Base_T.h"
#include "ace/OS_NS_string.h"

#ifndef __ACE_INLINE__
# include "tao/AnyTypeCode/TypeCode_Case_Base_T.inl"
#endif /* __ACE_INLINE__ */

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

template <typename StringType, typename TypeCodeType>
TAO::TypeCode::Case<StringType, TypeCodeType>::~Case (void)
{
}

template <typename StringType, typename TypeCodeType>
bool
TAO::TypeCode::Case<StringType, TypeCodeType>::equal (CORBA::ULong index,
                                                      CORBA::TypeCode_ptr tc) const
{
  // Check case names.
  char const * const lhs_name = this->name ();
  char const * const rhs_name = tc->member_name (index);

  if (std::strcmp (lhs_name, rhs_name) != 0)
    return false;

  // Check case TypeCodes.
  CORBA::TypeCode_ptr const lhs_tc = this->type ();
  CORBA::TypeCode_var const rhs_tc =
    tc->member_type (index);

  CORBA::Boolean const equal_members =
    lhs_tc->equal (rhs_tc.in ());

  if (!equal_members)
    return false;

  // Check case label.
  return this->equal_label (index, tc);
}

template <typename StringType, typename TypeCodeType>
bool
TAO::TypeCode::Case<StringType, TypeCodeType>::equivalent (
  CORBA::ULong index,
  CORBA::TypeCode_ptr tc) const
{
  // Member names are ignore when determining equivalence.

  // Check case TypeCodes.
  CORBA::TypeCode_ptr const lhs_tc = this->type ();
  CORBA::TypeCode_var const rhs_tc =
    tc->member_type (index);

  CORBA::Boolean const equivalent_members =
    lhs_tc->equivalent (rhs_tc.in ());

  if (!equivalent_members)
    return 0;

  // Check case label.
  // The label must be equal when determining equivalence, too.
  return this->equal_label (index, tc);
}

TAO_END_VERSIONED_NAMESPACE_DECL

#endif  /* TAO_TYPECODE_CASE_CPP */