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