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