summaryrefslogtreecommitdiff
path: root/TAO/tao/DynamicAny/DynValue_i.h
blob: f3f8884342e94f441e36786f017f1c9e64f99ae3 (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
157
158
159
// -*- C++ -*-
//=============================================================================
/**
 *  @file    DynValue_i.h
 *
 *  @author simon dot massey at prismtech dot com
 */
//=============================================================================


#ifndef TAO_DYNVALUE_I_H
#define TAO_DYNVALUE_I_H
#include /**/ "ace/pre.h"

#include "tao/DynamicAny/DynValueCommon_i.h"

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

#if defined (_MSC_VER)
# pragma warning(push)
# pragma warning (disable:4250)
#endif /* _MSC_VER */

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

/**
 * @class TAO_DynValue_i
 *
 * @brief Implementation of the DynValue class.
 */
class TAO_DynamicAny_Export TAO_DynValue_i
  : public virtual DynamicAny::DynValue,
    public virtual TAO_DynValueCommon_i
{
public:
  /// Constructor.
  TAO_DynValue_i (CORBA::Boolean allow_truncation=true);

  /// Destructor.
  ~TAO_DynValue_i ();

  /// Initialize using an Any.
  void init (const CORBA::Any& any);

  /// Initialize using a TypeCode and an input stream
  void init (CORBA::TypeCode_ptr tc, TAO_InputCDR &in);

  /// Initialize using just a TypeCode.
  void init (CORBA::TypeCode_ptr tc);

  // = LocalObject methods.
  static TAO_DynValue_i *_narrow (CORBA::Object_ptr obj);

  // = Functions specific to DynValue.
  virtual DynamicAny::FieldName current_member_name ();

  virtual CORBA::TCKind current_member_kind ();

  virtual DynamicAny::NameValuePairSeq * get_members ();

  virtual void set_members (const DynamicAny::NameValuePairSeq & value);

  virtual DynamicAny::NameDynAnyPairSeq * get_members_as_dyn_any ();

  virtual void set_members_as_dyn_any (
      const DynamicAny::NameDynAnyPairSeq & value);

  // = DynAny common functions not implemented in class TAO_DynCommon.
  virtual void from_any (const CORBA::Any & value);

  virtual CORBA::Any * to_any ();

  virtual CORBA::Boolean equal (DynamicAny::DynAny_ptr dyn_any);

  virtual void destroy ();

  virtual DynamicAny::DynAny_ptr current_component ();

  virtual void insert_val (CORBA::ValueBase * value);

  virtual CORBA::ValueBase * get_val ();

  // = DynValueCommon needed to be provided here
  virtual void set_to_value ();

private:
  /// List of base types.
  typedef ACE_Array_Base<CORBA::TypeCode_var> BaseTypesList_t;

  /// Decompose the given TypeCode into its hiarchical list of
  /// basetypes. The first element of the list is our actual type,
  /// each basetype follows in order backwards down the hiarchy.
  /// All types stored in the list are de-aliased. Optionally
  /// return the total_member_count of the fully derived type.
  static void get_base_types (
    CORBA::TypeCode_ptr,
    BaseTypesList_t &,
    CORBA::ULong *total_member_count = 0);

  /// Return the unaliased valuetype typecode that corresponds to
  /// index (0..total_members-1) from the given hiarchical list of
  /// the derived type and it basetypes.
  static CORBA::TypeCode_ptr get_correct_base_type (
    const BaseTypesList_t &base_types,
    CORBA::ULong &index);

  /// Return the member_type at index (0..total_members-1) from
  /// the given hiarchical list of the derived type and it basetypes.
  static CORBA::TypeCode_ptr get_member_type (
    const BaseTypesList_t &,
    CORBA::ULong index);

  /// Return the member_name at index (0..total_members-1) from
  /// the given hiarchical list of the derived type and it basetypes.
  static const char * get_member_name (
    const BaseTypesList_t &,
    CORBA::ULong index);

  /// Check if the typecode is acceptable.
  void check_typecode (CORBA::TypeCode_ptr tc);

  /// Common code from the init() functions, initializes the
  /// private bits from the given TypeCode
  void init_helper (CORBA::TypeCode_ptr tc);

  /// Code common to the init(Any) and the member
  /// function from_any().
  void from_any_helper (const CORBA::Any &any);

  /// Write the value to the output stream.
  void to_outputCDR (TAO_OutputCDR &);

  /// Read the value from the input stream
  void from_inputCDR (TAO_InputCDR &);

  /// These are not implimented!
  /// Use copy() or assign() instead of these.
  TAO_DynValue_i (const TAO_DynValue_i &src);
  TAO_DynValue_i &operator= (const TAO_DynValue_i &src);

  /// Each component of DynValue and DynValueBox is also a DynAny.
  ACE_Array_Base<DynamicAny::DynAny_var> da_members_;

  /// First element of this is our type, each basetype follows
  /// in order backwards down the hiarchy. All types stored are
  /// de-aliased.
  BaseTypesList_t da_base_types_;
};

TAO_END_VERSIONED_NAMESPACE_DECL

#if defined(_MSC_VER)
# pragma warning(pop)
#endif /* _MSC_VER */

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