summaryrefslogtreecommitdiff
path: root/TAO/tests/DynAny_Test/DynUnion_i.h
blob: 282780f3e1789f9d611608017626f026962ef5a8 (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
144
145
146
147
148
149
150
151
152
153
154
155
156
// $Id$

// ========================================================================
//
// = LIBRARY
//    TAO/tests/DynAny_Test
//
// = FILENAME
//    DynUnion_i.h
//
// = AUTHOR
//    Jeff Parsons <jp4@cs.wustl.edu>
//
// ========================================================================

#if !defined DYNUNION_I_H
#define DYNUNION_I_H

class DynUnion_i : public POA_DynUnion
{
public:
  DynUnion_i (const CORBA_Any& any);
  DynUnion_i (CORBA_TypeCode_ptr tc);
  ~DynUnion_i (void);

  // Functions specific to DynUnion
  CORBA::Boolean        set_as_default      (CORBA::Environment& env);
  void                  set_as_default      (CORBA::Boolean set_as_default,
                                             CORBA::Environment&);
  DynAny_ptr            discriminator       (CORBA::Environment& env);
  TCKind                discriminator_kind  (CORBA::Environment& env);
  DynAny_ptr            member              (CORBA::Environment& env);
  char*                 member_name         (CORBA::Environment& env);
  void                  member_name         (const char* member_name,
                                             CORBA::Environment& env);
  TCKind                member_kind         (CORBA::Environment& env);

  // Common functions
  void                  assign              (DynAny_ptr dyn_any,
                                             CORBA::Environment &env);
  DynAny_ptr            copy                (CORBA::Environment &env);
  void                  destroy             (CORBA::Environment &env);
  void                  from_any            (const CORBA::Any& any,
                                             CORBA::Environment &env);
  CORBA::Any_ptr        to_any              (CORBA::Environment &env);
  CORBA::TypeCode_ptr   type                (CORBA::Environment &);
  DynAny_ptr            current_component   (CORBA::Environment &env);
  CORBA::Boolean        next                (CORBA::Environment &env);
  CORBA::Boolean        seek                (CORBA::Long index,
                                             CORBA::Environment &env);
  void                  rewind              (CORBA::Environment &env);

  // The insert and get functions.

  void                  insert_boolean      (CORBA::Boolean value,
                                             CORBA::Environment &env);
  void                  insert_octet        (CORBA::Octet value,
                                             CORBA::Environment &env);
  void                  insert_char         (CORBA::Char value,
                                             CORBA::Environment &env);
  void                  insert_short        (CORBA::Short value,
                                             CORBA::Environment &env);
  void                  insert_ushort       (CORBA::UShort value,
                                             CORBA::Environment &env);
  void                  insert_long         (CORBA::Long value,
                                             CORBA::Environment &env);
  void                  insert_ulong        (CORBA::ULong value,
                                             CORBA::Environment &env);
  void                  insert_float        (CORBA::Float value,
                                             CORBA::Environment &env);
  void                  insert_double       (CORBA::Double value,
                                             CORBA::Environment &env);
  void                  insert_string       (char * value,
                                            CORBA::Environment &env);
  void                  insert_reference    (CORBA::Object_ptr value,
                                             CORBA::Environment &env);
  void                  insert_typecode     (CORBA::TypeCode_ptr value,
                                             CORBA::Environment &env);
  void                  insert_longlong     (CORBA::LongLong value,
                                             CORBA::Environment &env);
  void                  insert_ulonglong    (CORBA::ULongLong value,
                                            CORBA::Environment &env);
  void                  insert_wchar        (CORBA::WChar value,
                                            CORBA::Environment &env);
  void                  insert_any          (const CORBA::Any& value,
                                             CORBA::Environment &env);

  CORBA::Boolean        get_boolean         (CORBA::Environment &env);
  CORBA::Octet          get_octet           (CORBA::Environment &env);
  CORBA::Char           get_char            (CORBA::Environment &env);
  CORBA::Short          get_short           (CORBA::Environment &env);
  CORBA::UShort         get_ushort          (CORBA::Environment &env);
  CORBA::Long           get_long            (CORBA::Environment &env);
  CORBA::ULong          get_ulong           (CORBA::Environment &env);
  CORBA::Float          get_float           (CORBA::Environment &env);
  CORBA::Double         get_double          (CORBA::Environment &env);
  char *                get_string          (CORBA::Environment &env);
  CORBA::Object_ptr     get_reference       (CORBA::Environment &env);
  CORBA::TypeCode_ptr   get_typecode        (CORBA::Environment &env);
  CORBA::LongLong       get_longlong        (CORBA::Environment &env);
  CORBA::ULongLong      get_ulonglong       (CORBA::Environment &env);
  CORBA::WChar          get_wchar           (CORBA::Environment &env);
  CORBA::Any_ptr        get_any             (CORBA::Environment &env);

private:
  CORBA::TypeCode_var   type_;
  DynAny_var            discriminator_;
  CORBA::ULong          index_;
  DynAny_var            member_;

  class Extractor_base
  {
  public:
    virtual 
    CORBA::Boolean      check_match         (const CORBA_Any& inside_any,
                                             const CORBA_Any& outside_any) = 0;
  };

  template <class Type>
  class Extractor : public Extractor_base
  {
  public:
    CORBA::Boolean      check_match         (const CORBA_Any& inside_any,
                                             const CORBA_Any& outside_any);
  private:
    Type                arg_index_, 
                        member_index_;
  };

  class WChar_extractor : public Extractor_base
  {
  public:
    CORBA::Boolean      check_match         (const CORBA_Any& inside_any,
                                             const CORBA_Any& outside_any);
  private:
    CORBA::WChar        arg_index_, 
                        member_index_;
  };

  class Enum_extractor : public Extractor_base
  {
  public:
    CORBA::Boolean      check_match         (const CORBA_Any& inside_any,
                                             const CORBA_Any& outside_any);
  private:
    CORBA::ULong        arg_index_, 
                        member_index_;
  };

  Extractor_base*       get_extractor       (CORBA::TCKind kind);

  void                  set_from_any        (const CORBA_Any& any,
                                             CORBA::Environment &env);
};

#endif /* DYNUNION_I_H */