summaryrefslogtreecommitdiff
path: root/TAO/tao/DynamicInterface/Context.cpp
blob: 9ca2232f3f3e47ea8dd6b92218ad90d6f90d3d36 (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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#include "Context.h"


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


#include "tao/Typecode.h"
#include "tao/NVList.h"
#include "tao/Environment.h"
#include "tao/CORBA_String.h"

#include "ace/Guard_T.h"

#if !defined (__ACE_INLINE__)
# include "Context.inl"
#endif /* ! __ACE_INLINE__ */


CORBA::Context::Context (void)
  : refcount_ (1)
{
}

CORBA::Context::~Context (void)
{
}

CORBA::ULong
CORBA::Context::_incr_refcnt (void)
{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    ace_mon,
                    this->refcount_lock_,
                    0);

  return refcount_++;
}

CORBA::ULong
CORBA::Context::_decr_refcnt (void)
{
  {
    ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                      ace_mon,
                      this->refcount_lock_,
                      0);

    this->refcount_--;

    if (this->refcount_ != 0)
      {
        return this->refcount_;
      }
  }

  delete this;
  return 0;
}

const char *
CORBA::Context::context_name (ACE_ENV_SINGLE_ARG_DECL) const
{
  ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (TAO_DEFAULT_MINOR_CODE,
                                         CORBA::COMPLETED_NO),
                    0);
}

CORBA::Context_ptr
CORBA::Context::parent (ACE_ENV_SINGLE_ARG_DECL) const
{
  ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (TAO_DEFAULT_MINOR_CODE,
                                         CORBA::COMPLETED_NO),
                    0);
}

void
CORBA::Context::create_child (const char * /* child_ctx_name */,
                              CORBA::Context_out /* child_ctx */
                              ACE_ENV_ARG_DECL)
{
  ACE_THROW (CORBA::NO_IMPLEMENT (TAO_DEFAULT_MINOR_CODE,
                                  CORBA::COMPLETED_NO));
}

void
CORBA::Context::set_one_value (const char * /* propname */,
                               const CORBA::Any & /* propvalue */
                               ACE_ENV_ARG_DECL)
{
  ACE_THROW (CORBA::NO_IMPLEMENT (TAO_DEFAULT_MINOR_CODE,
                                  CORBA::COMPLETED_NO));
}

void
CORBA::Context::set_values (CORBA::NVList_ptr
                            ACE_ENV_ARG_DECL)
{
  ACE_THROW (CORBA::NO_IMPLEMENT (TAO_DEFAULT_MINOR_CODE,
                                  CORBA::COMPLETED_NO));
}

void
CORBA::Context::delete_values (const char * /* propname */
                               ACE_ENV_ARG_DECL)
{
  ACE_THROW (CORBA::NO_IMPLEMENT (TAO_DEFAULT_MINOR_CODE,
                                  CORBA::COMPLETED_NO));
}

void
CORBA::Context::get_values (const char * /* start_scope */,
                            CORBA::Flags /* op_flags */,
                            const char * /* pattern */,
                            CORBA::NVList_ptr & /* values */
                            ACE_ENV_ARG_DECL)
{
  ACE_THROW (CORBA::NO_IMPLEMENT (TAO_DEFAULT_MINOR_CODE,
                                  CORBA::COMPLETED_NO));
}

CORBA::ContextList::ContextList (CORBA::ULong len,
                                 char* *ctx_list)
  : ref_count_ (1)
{
  for (CORBA::ULong i=0; i < len; i++)
    {
      this->add (ctx_list [i]);
    }
}

CORBA::ContextList::~ContextList (void)
{
  for (CORBA::ULong i = 0; i < this->count (); ++i)
    {
      char **ctx;

      if (this->ctx_list_.get (ctx, i) == -1)
        {
          return;
        }

      CORBA::string_free (*ctx);
    }
}

void
CORBA::ContextList::add (char *ctx)
{
  this->ctx_list_.enqueue_tail (CORBA::string_dup (ctx));
}

void
CORBA::ContextList::add_consume (char *ctx)
{
  this->ctx_list_.enqueue_tail (ctx);
}

char *
CORBA::ContextList::item (CORBA::ULong slot
                         ACE_ENV_ARG_DECL)
{
  char **ctx = 0;

  if (this->ctx_list_.get (ctx, slot) == -1)
    {
      ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
                        0);
    }
  else
    {
      return CORBA::string_dup (*ctx);
    }
}

void
CORBA::ContextList::remove (CORBA::ULong
                           ACE_ENV_ARG_DECL)
{
  ACE_THROW (CORBA::NO_IMPLEMENT ());
}

CORBA::ContextList_ptr
CORBA::ContextList::_duplicate (void)
{
  ++this->ref_count_;
  return this;
}

void
CORBA::ContextList::_destroy (void)
{
  CORBA::ULong current = --this->ref_count_;

  if (current == 0)
    {
      delete this;
    }
}

void
CORBA::ContextList::_incr_refcnt (void)
{
  this->ref_count_++;
}

void
CORBA::ContextList::_decr_refcnt (void)
{
  this->ref_count_--;

  if (this->ref_count_ != 0)
    {
      delete this;
    }
}

#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)

  template class TAO_Pseudo_Var_T<CORBA::Context>;
  template class TAO_Pseudo_Out_T<CORBA::Context, CORBA::Context_var>;
  template class TAO_Pseudo_Var_T<CORBA::ContextList>;
  template class TAO_Pseudo_Out_T<CORBA::ContextList, CORBA::ContextList_var>;

#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)

# pragma instantiate TAO_Pseudo_Var_T<CORBA::Context>
# pragma instantiate TAO_Pseudo_Out_T<CORBA::Context, CORBA::Context_var>
# pragma instantiate TAO_Pseudo_Var_T<CORBA::ContextList>
# pragma instantiate TAO_Pseudo_Out_T<CORBA::ContextList, CORBA::ContextList_var>

#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */