00001 #include "tao/DynamicInterface/Context.h"
00002
00003 ACE_RCSID (DynamicInterface,
00004 Context,
00005 "Context.cpp,v 1.20 2006/03/10 07:19:08 jtc Exp")
00006
00007 #include "tao/AnyTypeCode/TypeCode.h"
00008 #include "tao/Environment.h"
00009 #include "tao/CORBA_String.h"
00010 #include "tao/SystemException.h"
00011
00012 #include "ace/Guard_T.h"
00013
00014 #if !defined (__ACE_INLINE__)
00015 # include "tao/DynamicInterface/Context.inl"
00016 #endif
00017
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019
00020 CORBA::Context::Context (void)
00021 : refcount_ (1)
00022 {
00023 }
00024
00025 CORBA::Context::~Context (void)
00026 {
00027 }
00028
00029 CORBA::ULong
00030 CORBA::Context::_incr_refcnt (void)
00031 {
00032 return ++refcount_;
00033 }
00034
00035 CORBA::ULong
00036 CORBA::Context::_decr_refcnt (void)
00037 {
00038 const CORBA::ULong new_count = --this->refcount_;
00039
00040 if (new_count == 0)
00041 delete this;
00042
00043 return new_count;
00044 }
00045
00046 const char *
00047 CORBA::Context::context_name (ACE_ENV_SINGLE_ARG_DECL) const
00048 {
00049 ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (TAO::VMCID,
00050 CORBA::COMPLETED_NO),
00051 0);
00052 }
00053
00054 CORBA::Context_ptr
00055 CORBA::Context::parent (ACE_ENV_SINGLE_ARG_DECL) const
00056 {
00057 ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (TAO::VMCID,
00058 CORBA::COMPLETED_NO),
00059 0);
00060 }
00061
00062 void
00063 CORBA::Context::create_child (const char * ,
00064 CORBA::Context_out
00065 ACE_ENV_ARG_DECL)
00066 {
00067 ACE_THROW (CORBA::NO_IMPLEMENT (TAO::VMCID,
00068 CORBA::COMPLETED_NO));
00069 }
00070
00071 void
00072 CORBA::Context::set_one_value (const char * ,
00073 const CORBA::Any &
00074 ACE_ENV_ARG_DECL)
00075 {
00076 ACE_THROW (CORBA::NO_IMPLEMENT (TAO::VMCID,
00077 CORBA::COMPLETED_NO));
00078 }
00079
00080 void
00081 CORBA::Context::set_values (CORBA::NVList_ptr
00082 ACE_ENV_ARG_DECL)
00083 {
00084 ACE_THROW (CORBA::NO_IMPLEMENT (TAO::VMCID,
00085 CORBA::COMPLETED_NO));
00086 }
00087
00088 void
00089 CORBA::Context::delete_values (const char *
00090 ACE_ENV_ARG_DECL)
00091 {
00092 ACE_THROW (CORBA::NO_IMPLEMENT (TAO::VMCID,
00093 CORBA::COMPLETED_NO));
00094 }
00095
00096 void
00097 CORBA::Context::get_values (const char * ,
00098 CORBA::Flags ,
00099 const char * ,
00100 CORBA::NVList_ptr &
00101 ACE_ENV_ARG_DECL)
00102 {
00103 ACE_THROW (CORBA::NO_IMPLEMENT (TAO::VMCID,
00104 CORBA::COMPLETED_NO));
00105 }
00106
00107 CORBA::ContextList::ContextList (CORBA::ULong len,
00108 char* *ctx_list)
00109 : ref_count_ (1)
00110 {
00111 for (CORBA::ULong i=0; i < len; i++)
00112 {
00113 this->add (ctx_list [i]);
00114 }
00115 }
00116
00117 CORBA::ContextList::~ContextList (void)
00118 {
00119 for (CORBA::ULong i = 0; i < this->count (); ++i)
00120 {
00121 char **ctx;
00122
00123 if (this->ctx_list_.get (ctx, i) == -1)
00124 {
00125 return;
00126 }
00127
00128 CORBA::string_free (*ctx);
00129 }
00130 }
00131
00132 void
00133 CORBA::ContextList::add (char *ctx)
00134 {
00135 this->ctx_list_.enqueue_tail (CORBA::string_dup (ctx));
00136 }
00137
00138 void
00139 CORBA::ContextList::add_consume (char *ctx)
00140 {
00141 this->ctx_list_.enqueue_tail (ctx);
00142 }
00143
00144 char *
00145 CORBA::ContextList::item (CORBA::ULong slot
00146 ACE_ENV_ARG_DECL)
00147 {
00148 char **ctx = 0;
00149
00150 if (this->ctx_list_.get (ctx, slot) == -1)
00151 {
00152 ACE_THROW_RETURN (CORBA::TypeCode::Bounds (),
00153 0);
00154 }
00155 else
00156 {
00157 return CORBA::string_dup (*ctx);
00158 }
00159 }
00160
00161 void
00162 CORBA::ContextList::remove (CORBA::ULong
00163 ACE_ENV_ARG_DECL)
00164 {
00165 ACE_THROW (CORBA::NO_IMPLEMENT ());
00166 }
00167
00168 CORBA::ContextList_ptr
00169 CORBA::ContextList::_duplicate (void)
00170 {
00171 ++this->ref_count_;
00172 return this;
00173 }
00174
00175 void
00176 CORBA::ContextList::_destroy (void)
00177 {
00178 CORBA::ULong current = --this->ref_count_;
00179
00180 if (current == 0)
00181 {
00182 delete this;
00183 }
00184 }
00185
00186 void
00187 CORBA::ContextList::_incr_refcnt (void)
00188 {
00189 this->ref_count_++;
00190 }
00191
00192 void
00193 CORBA::ContextList::_decr_refcnt (void)
00194 {
00195 this->ref_count_--;
00196
00197 if (this->ref_count_ != 0)
00198 {
00199 delete this;
00200 }
00201 }
00202
00203 TAO_END_VERSIONED_NAMESPACE_DECL