00001 // -*- C++ -*- 00002 // 00003 // Context.h,v 1.23 2006/06/19 14:51:11 parsons Exp 00004 00005 //============================================================================= 00006 /** 00007 * @file Context.h 00008 * 00009 * Context.h,v 1.23 2006/06/19 14:51:11 parsons Exp 00010 * 00011 * Header file for CORBA Context class. 00012 * 00013 * @author Jeff Parsons <parsons@cs.wustl.edu> 00014 */ 00015 //============================================================================= 00016 00017 #ifndef TAO_CONTEXT_H 00018 #define TAO_CONTEXT_H 00019 00020 #include /**/ "ace/pre.h" 00021 00022 #include "tao/DynamicInterface/dynamicinterface_export.h" 00023 00024 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00025 # pragma once 00026 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00027 00028 #include "tao/DynamicInterface/DII_CORBA_methods.h" 00029 #include "tao/AnyTypeCode/AnyTypeCode_methods.h" 00030 00031 #include "tao/Pseudo_VarOut_T.h" 00032 #include "tao/orbconf.h" 00033 #include "tao/Basic_Types.h" 00034 #include "tao/ORB_Constants.h" 00035 #include "tao/default_environment.h" 00036 00037 #include "ace/Unbounded_Queue.h" 00038 #include "ace/Atomic_Op.h" 00039 #include "ace/CORBA_macros.h" 00040 #include "ace/Synch_Traits.h" 00041 00042 #if defined (TAO_EXPORT_MACRO) 00043 #undef TAO_EXPORT_MACRO 00044 #endif 00045 #define TAO_EXPORT_MACRO TAO_DynamicInterface_Export 00046 00047 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00048 00049 namespace CORBA 00050 { 00051 typedef ULong Flags; 00052 00053 class NVList; 00054 typedef NVList *NVList_ptr; 00055 00056 class Environment; 00057 00058 typedef TAO_Pseudo_Var_T<Context> Context_var; 00059 typedef TAO_Pseudo_Out_T<Context> Context_out; 00060 00061 typedef TAO_Pseudo_Var_T<ContextList> ContextList_var; 00062 typedef TAO_Pseudo_Out_T<ContextList> ContextList_out; 00063 00064 /** 00065 * @class Context 00066 * 00067 * @brief CORBA::Context 00068 * 00069 * TAO's minimal implementation of the Context interface. Since 00070 * Contexts are inherently un-typesafe, there use is deprecated and 00071 * the feature may eventaully disappear from CORBA. It is 00072 * implemented only to make the arg list of 00073 * CORBA::Object::_create_request() compliant. The only (pointer) 00074 * value that should be passed is 0. 00075 */ 00076 class TAO_DynamicInterface_Export Context 00077 { 00078 public: 00079 00080 Context (void); 00081 00082 ~Context (void); 00083 00084 // = Pseudo-object methods 00085 static Context *_duplicate (Context*); 00086 static Context *_nil (void); 00087 00088 // = Reference counting. 00089 CORBA::ULong _incr_refcnt (void); 00090 CORBA::ULong _decr_refcnt (void); 00091 00092 // = All the spec-required functions below will just throw a 00093 // CORBA::NO_IMPLEMENT exception and do nothing else. 00094 00095 const char *context_name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const; 00096 00097 CORBA::Context_ptr parent (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) const; 00098 00099 void create_child (const char *child_ctx_name, 00100 CORBA::Context_out child_ctx 00101 ACE_ENV_ARG_DECL_WITH_DEFAULTS); 00102 00103 void set_one_value (const char *propname, 00104 const CORBA::Any &propvalue 00105 ACE_ENV_ARG_DECL_WITH_DEFAULTS); 00106 00107 void set_values (CORBA::NVList_ptr values 00108 ACE_ENV_ARG_DECL_WITH_DEFAULTS); 00109 00110 void delete_values (const char *propname 00111 ACE_ENV_ARG_DECL_WITH_DEFAULTS); 00112 00113 void get_values (const char *start_scope, 00114 CORBA::Flags op_flags, 00115 const char *pattern, 00116 CORBA::NVList_ptr &values 00117 ACE_ENV_ARG_DECL_WITH_DEFAULTS); 00118 00119 // Useful for template programming. 00120 typedef CORBA::Context_ptr _ptr_type; 00121 typedef CORBA::Context_var _var_type; 00122 typedef CORBA::Context_out _out_type; 00123 00124 private: 00125 /// Reference counter. 00126 ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_; 00127 }; 00128 00129 /** 00130 * @class ContextList 00131 * 00132 * @brief ContextList definition taken from CORBA v2.3a Dec 1998 00133 * 00134 * Maintains a list of strings for Contexts. 00135 */ 00136 class TAO_DynamicInterface_Export ContextList 00137 { 00138 public: 00139 /// Constructor. 00140 ContextList (void); 00141 00142 /// Constructor - initialize given a length and an array of 00143 /// strings. 00144 ContextList (CORBA::ULong len, 00145 char **ctx_list); 00146 00147 /// Destructor. 00148 ~ContextList (void); 00149 00150 /// Return the number of elements. 00151 CORBA::ULong count (void); 00152 00153 /// Increment the reference count. 00154 ContextList_ptr _duplicate (void); 00155 00156 /// Increment the reference count. 00157 static ContextList_ptr _duplicate (ContextList *); 00158 00159 /// Decrement the reference count and delete if it is 0. 00160 void _destroy (void); 00161 00162 /// Return null pointer of this type. 00163 static ContextList_ptr _nil (); 00164 00165 /// Add a string to the list. 00166 void add (char *ctx); 00167 00168 /// Add and consume a string to the list. 00169 void add_consume (char *ctx); 00170 00171 /// Return the typecode at slot i. Raises the "Bounds" exception. 00172 char *item (CORBA::ULong slot 00173 ACE_ENV_ARG_DECL_WITH_DEFAULTS); 00174 00175 /// Remove the typecode at slot i. Raises the "Bounds" exception. 00176 void remove (CORBA::ULong slot 00177 ACE_ENV_ARG_DECL_WITH_DEFAULTS); 00178 00179 /// Increment and decrement ref counts. 00180 void _incr_refcnt (void); 00181 void _decr_refcnt (void); 00182 00183 // Useful for template programming. 00184 typedef CORBA::ContextList_ptr _ptr_type; 00185 typedef CORBA::ContextList_var _var_type; 00186 typedef CORBA::ContextList_out _out_type; 00187 00188 private: 00189 // Not allowed. 00190 ContextList (const ContextList &); 00191 ContextList &operator= (const ContextList &); 00192 00193 /// Reference counter. 00194 ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> ref_count_; 00195 00196 /// Internal list of typecodes. 00197 ACE_Unbounded_Queue<char *> ctx_list_; 00198 }; 00199 } // End CORBA namespace. 00200 00201 TAO_END_VERSIONED_NAMESPACE_DECL 00202 00203 #if defined (__ACE_INLINE__) 00204 # include "tao/DynamicInterface/Context.inl" 00205 #endif /* __ACE_INLINE__ */ 00206 00207 #include /**/ "ace/post.h" 00208 00209 #endif /* TAO_CONTEXT_H */