summaryrefslogtreecommitdiff
path: root/TAO/tao/managed_types.h
blob: 6c4ea8f40219452b1ad4f8529876fa6726f3d09d (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
160
161
162
// This may look like C, but it's really -*- C++ -*-
//
// ============================================================================
//
// = LIBRARY
//    TAO
//
// = FILENAME
//    managed_types.h
//
// = DESCRIPTION
//    C++ mapping of sequences of strings/objrefs or struct/union members with
//    strings/objrefs require a special managed type. These types are define
//    din this header file.

// = AUTHOR
//    Aniruddha Gokhale
//
// ============================================================================

#if !defined(TAO_MANAGED_TYPES_H)
#define TAO_MANAGED_TYPES_H

class ACE_Svc_Export TAO_String_ManagedType
{
  // = TITLE
  //   TAO_String_ManagedType
  // = DESCRIPTION
  //   String var class. Provides automatic deallocation of storage
  //   for the string once it goes out of scope.

public:
  TAO_String_ManagedType (void);
  // default constructor

  TAO_String_ManagedType (char *p, CORBA::Boolean release=1);
  // constructor, owns p

  TAO_String_ManagedType (const char *p, CORBA::Boolean release=1);
  // constructor. Makes a copy of p

  TAO_String_ManagedType (const TAO_String_ManagedType &s, CORBA::Boolean release=1);
  // copy constructor

  ~TAO_String_ManagedType (void);
  // destructor

  TAO_String_ManagedType &operator= (char *p);
  // assignment operator

  TAO_String_ManagedType &operator= (const char *p);
  // assignment to a const char*. Makes a copy.

  TAO_String_ManagedType &operator= (const TAO_String_ManagedType &s);
  // assignment operator

  operator char *();
  // access and modify

  operator const char *() const;
  // only read privileges

  char &operator[] (CORBA::ULong index);
  // allows access and modification using an index

  char operator[] (CORBA::ULong index) const;
  // allows only accessing thru an index

  // = in, out, out, and _retn operations.
  // ORBOS/97-05-15, Appendix C.2

  const char *in (void) const;
  // for in parameter

  char *&inout (void);
  // for inout parameter

  char *&out (void);
  // for out parameter

  char *_retn (void);
  // for string of return type

 private:
  char *ptr_;
  // instance.

  CORBA::Boolean release_;
  // do we own it
};

#if 0
// TODO: @@@ XXXASG
template <T_ptr>
class ACE_Svc_Export TAO_ObjRef_ManagedType
{
  // = TITLE
  //   String var class. Provides automatic deallocation of storage
  //   for the string once it goes out of scope.

public:
  TAO_ObjRef_ManagedType (void);
  // default constructor

  TAO_ObjRef_ManagedType (T_ptr p, CORBA::Boolean release=1);
  // constructor, owns p

  TAO_ObjRef_ManagedType (const T_ptr p, CORBA::Boolean release=1);
  // constructor. Makes a copy of p

  TAO_ObjRef_ManagedType (const TAO_ObjRef_ManagedType &s, CORBA::Boolean release=1);
  // copy constructor

  ~TAO_ObjRef_ManagedType (void);
  // destructor

  TAO_ObjRef_ManagedType &operator= (T_ptr p);
  // assignment operator

  TAO_ObjRef_ManagedType &operator= (const T_ptr p);
  // assignment to a const char*. Makes a copy.

  TAO_ObjRef_ManagedType &operator= (const TAO_ObjRef_ManagedType &s);
  // assignment operator

  operator T_ptr ();
  // access and modify

  operator const T_ptr () const;
  // only read privileges

  char &operator[] (ULong index);
  // allows access and modification using an index

  char operator[] (ULong index) const;
  // allows only accessing thru an index

  // = in, out, out, and _retn operations.
  // ORBOS/97-05-15, Appendix C.2

  const T_ptr in (void) const;
  // for in parameter

  T_ptr &inout (void);
  // for inout parameter

  T_ptr &out (void);
  // for out parameter

  T_ptr _retn (void);
  // for string of return type

 private:
  CORBA::Boolean release_;
  // do we own it?

  T_ptr ptr_;
  // instance.
};
#endif /* if 0 */

#endif /* if !defined */