Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TAO_VALUEBASE_H
00014 #define TAO_VALUEBASE_H
00015
00016 #include "ace/pre.h"
00017
00018 #include "tao/Valuetype/valuetype_export.h"
00019 #include "tao/orbconf.h"
00020
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif
00024
00025 #include "tao/Valuetype/Value_CORBA_methods.h"
00026 #include "tao/Valuetype/Value_VarOut_T.h"
00027
00028 #include "tao/Object_Argument_T.h"
00029 #include "tao/Arg_Traits_T.h"
00030 #include "tao/Any_Insert_Policy_T.h"
00031
00032 #include "ace/Basic_Types.h"
00033 #include "ace/Synch_Traits.h"
00034 #include "ace/Thread_Mutex.h"
00035 #include "ace/Atomic_Op.h"
00036 #include "ace/Null_Mutex.h"
00037 #include "ace/Vector_T.h"
00038
00039 #if defined (TAO_EXPORT_MACRO)
00040 #undef TAO_EXPORT_MACRO
00041 #endif
00042 #define TAO_EXPORT_MACRO TAO_Valuetype_Export
00043
00044 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00045
00046 class TAO_Valuetype_Export TAO_ChunkInfo
00047 {
00048 public:
00049 TAO_ChunkInfo (CORBA::Boolean do_chunking = 0,
00050 CORBA::Long init_level = 0);
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 CORBA::Boolean start_chunk (TAO_OutputCDR &strm);
00065
00066
00067
00068
00069
00070
00071 CORBA::Boolean end_chunk (TAO_OutputCDR &strm);
00072
00073
00074
00075
00076
00077 CORBA::Boolean handle_chunking (TAO_InputCDR &strm);
00078
00079
00080
00081 CORBA::Boolean skip_chunks (TAO_InputCDR &strm);
00082
00083
00084 CORBA::Boolean write_previous_chunk_size (TAO_OutputCDR &strm);
00085
00086
00087
00088
00089 CORBA::Boolean reserve_chunk_size (TAO_OutputCDR &strm);
00090
00091
00092
00093 CORBA::Boolean chunking_;
00094
00095
00096 CORBA::Long value_nesting_level_;
00097
00098 char* chunk_size_pos_;
00099
00100
00101
00102 size_t length_to_chunk_octets_pos_;
00103
00104 char* chunk_octets_end_pos_;
00105 };
00106
00107 namespace CORBA
00108 {
00109 class ValueFactoryBase;
00110 typedef ValueFactoryBase *ValueFactory;
00111
00112 class ValueBase;
00113
00114 typedef TAO_Value_Var_T<ValueBase> ValueBase_var;
00115 typedef TAO_Value_Out_T<ValueBase> ValueBase_out;
00116
00117
00118
00119
00120
00121
00122
00123
00124 class TAO_Valuetype_Export ValueBase
00125 {
00126 public:
00127 friend class TAO_ChunkInfo;
00128
00129 typedef ValueBase* _ptr_type;
00130 typedef ValueBase_var _var_type;
00131 typedef ValueBase_out _out_type;
00132
00133 typedef ACE_Vector < ACE_CString > Repository_Id_List;
00134
00135
00136
00137
00138 virtual void _add_ref (void) = 0;
00139 virtual void _remove_ref (void) = 0;
00140 virtual CORBA::ULong _refcount_value (void) = 0;
00141
00142
00143 static CORBA::ValueBase* _downcast (CORBA::ValueBase *);
00144
00145
00146
00147
00148 static void _tao_any_destructor (void *);
00149 virtual CORBA::TypeCode_ptr _tao_type (void) const = 0;
00150
00151
00152 virtual const char * _tao_obv_repository_id (void) const = 0;
00153
00154
00155
00156
00157
00158
00159 virtual void _tao_obv_truncatable_repo_ids (Repository_Id_List &) const = 0;
00160
00161
00162
00163
00164
00165 static CORBA::Boolean _tao_marshal (TAO_OutputCDR &strm,
00166 const ValueBase *_this,
00167 ptrdiff_t formal_type_id = 0);
00168
00169
00170
00171 static CORBA::Boolean _tao_unmarshal (TAO_InputCDR &strm,
00172 ValueBase *&new_object);
00173
00174
00175
00176
00177
00178
00179
00180 static CORBA::Boolean _tao_unmarshal_pre (TAO_InputCDR &strm,
00181 CORBA::ValueBase *&valuetype,
00182 const char * const repo_id,
00183 CORBA::Boolean& is_null_object,
00184 CORBA::Boolean& is_indirected);
00185
00186 CORBA::Boolean _tao_unmarshal_post (TAO_InputCDR &strm);
00187
00188
00189
00190 static CORBA::Boolean _tao_validate_box_type (
00191 TAO_InputCDR &strm,
00192 TAO_InputCDR &indirected_strm,
00193 const char * const repo_id_expected,
00194 CORBA::Boolean & null_object,
00195 CORBA::Boolean & is_indirected);
00196
00197 #if defined (GEN_OSTREAM_OPS)
00198
00199
00200
00201 static std::ostream& _tao_stream (std::ostream &strm, const ValueBase *value);
00202 virtual std::ostream& _tao_stream_v (std::ostream &strm) const;
00203
00204 #endif
00205
00206 public:
00207
00208
00209 virtual CORBA::Boolean _tao_marshal_v (TAO_OutputCDR &) const = 0;
00210
00211
00212 virtual CORBA::Boolean _tao_unmarshal_v (TAO_InputCDR &) = 0;
00213
00214
00215
00216
00217
00218
00219 virtual void truncation_hook ();
00220
00221 protected:
00222 ValueBase (void);
00223 ValueBase (const ValueBase&);
00224 virtual ~ValueBase (void);
00225
00226
00227
00228 CORBA::Boolean is_truncatable_;
00229
00230
00231
00232
00233
00234 CORBA::Boolean chunking_;
00235
00236
00237
00238
00239 virtual CORBA::Boolean _tao_match_formal_type (ptrdiff_t ) const = 0;
00240
00241 private:
00242
00243 static CORBA::Boolean _tao_unmarshal_value_indirection_pre (TAO_InputCDR &strm,
00244 TAO_InputCDR &indirected_strm);
00245
00246 static CORBA::Boolean _tao_unmarshal_value_indirection (TAO_InputCDR &strm,
00247 CORBA::ValueBase *&value);
00248
00249 static CORBA::Boolean _tao_unmarshal_repo_id_indirection (TAO_InputCDR &strm,
00250 ACE_CString& repo_id);
00251
00252 static CORBA::Boolean _tao_unmarshal_codebase_url_indirection (TAO_InputCDR &strm,
00253 ACE_CString& codebase_url);
00254
00255 static CORBA::Boolean _tao_write_repository_id (TAO_OutputCDR &strm,
00256 ACE_CString& id);
00257
00258
00259 static CORBA::Boolean _tao_write_special_value(TAO_OutputCDR &strm,
00260 const CORBA::ValueBase * value);
00261
00262 static CORBA::Boolean _tao_write_value(TAO_OutputCDR &strm,
00263 const CORBA::ValueBase * value,
00264 ptrdiff_t formal_type_id);
00265
00266
00267
00268 CORBA::Boolean _tao_write_value_header(TAO_OutputCDR &strm,
00269 ptrdiff_t formal_type_id) const;
00270
00271
00272
00273 static CORBA::Boolean _tao_read_repository_id (TAO_InputCDR& strm,
00274 ACE_CString& id);
00275
00276
00277
00278 static CORBA::Boolean _tao_read_repository_id_list (TAO_InputCDR& strm,
00279 Repository_Id_List& ids);
00280
00281
00282
00283 static CORBA::Boolean _tao_read_codebase_url (TAO_InputCDR& strm,
00284 ACE_CString& codebase_url);
00285
00286
00287 private:
00288 ValueBase & operator= (const ValueBase &);
00289
00290 #ifdef SUN_CC_HAS_PVFC_BUG
00291
00292 private:
00293 unsigned long tao_sun_cc_pvfc_bug_fix_;
00294
00295 #endif
00296
00297 };
00298
00299
00300 extern TAO_Valuetype_Export TypeCode_ptr const _tc_ValueBase;
00301 extern TAO_Valuetype_Export TypeCode_ptr const _tc_EventBase;
00302
00303
00304
00305
00306
00307
00308
00309
00310 class TAO_Valuetype_Export DefaultValueRefCountBase
00311 : public virtual ValueBase
00312 {
00313 public:
00314 virtual void _add_ref (void);
00315 virtual void _remove_ref (void);
00316 virtual CORBA::ULong _refcount_value (void);
00317
00318
00319
00320 void _tao_add_ref (void);
00321 void _tao_remove_ref (void);
00322 CORBA::ULong _tao_refcount_value (void);
00323
00324 protected:
00325 DefaultValueRefCountBase (void);
00326 DefaultValueRefCountBase (const DefaultValueRefCountBase&);
00327 virtual ~DefaultValueRefCountBase ();
00328
00329 private:
00330 void operator= (const DefaultValueRefCountBase &);
00331
00332 private:
00333
00334 ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
00335 };
00336
00337
00338
00339
00340
00341 }
00342
00343
00344
00345
00346
00347
00348
00349
00350 namespace TAO_OBV_GIOP_Flags
00351 {
00352 const CORBA::Long Value_tag_base = 0x7fffff00L;
00353 const CORBA::Long Value_tag_sigbits = 0x7fffff00L;
00354 const CORBA::Long Codebase_url = 1;
00355 const CORBA::Long Type_info_sigbits = 0x00000006L;
00356 const CORBA::Long Type_info_none = 0;
00357 const CORBA::Long Type_info_single = 2;
00358 const CORBA::Long Type_info_list = 6;
00359 const CORBA::Long Chunking_tag_sigbits = 0x00000008L;
00360 const CORBA::Long Indirection_tag = 0xFFFFFFFF;
00361 const CORBA::Long Null_tag = 0x00000000L;
00362
00363 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean is_null_ref (CORBA::Long tag);
00364 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean is_value_tag (CORBA::Long tag);
00365 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean has_codebase_url (CORBA::Long tag);
00366 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean has_no_type_info (CORBA::Long tag);
00367 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean has_single_type_info (CORBA::Long tag);
00368 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean has_list_type_info (CORBA::Long tag);
00369 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean is_chunked (CORBA::Long tag);
00370 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean is_indirection_tag (CORBA::Long tag);
00371 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean is_indirection (CORBA::Long tag);
00372 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean is_block_size (CORBA::Long tag);
00373 TAO_NAMESPACE_INLINE_FUNCTION CORBA::Boolean is_end_tag (CORBA::Long tag);
00374 }
00375
00376 TAO_Valuetype_Export CORBA::Boolean
00377 operator<< (TAO_OutputCDR&, const CORBA::ValueBase *);
00378
00379 TAO_Valuetype_Export CORBA::Boolean
00380 operator>> (TAO_InputCDR&, CORBA::ValueBase *&);
00381
00382 #if defined (GEN_OSTREAM_OPS)
00383
00384
00385 TAO_Valuetype_Export std::ostream&
00386 operator<< (std::ostream&, CORBA::ValueBase *);
00387
00388 #endif
00389
00390
00391 namespace TAO
00392 {
00393 template<>
00394 class TAO_Valuetype_Export Arg_Traits<CORBA::ValueBase>
00395 : public Object_Arg_Traits_T<CORBA::ValueBase *,
00396 CORBA::ValueBase_var,
00397 CORBA::ValueBase_out,
00398 TAO::Value_Traits<CORBA::ValueBase>,
00399 TAO::Any_Insert_Policy_Stream>
00400 {
00401 };
00402
00403 template<>
00404 struct TAO_Valuetype_Export Value_Traits<CORBA::ValueBase>
00405 {
00406 static void add_ref (CORBA::ValueBase *);
00407 static void remove_ref (CORBA::ValueBase *);
00408
00409
00410
00411 static void release (CORBA::ValueBase *);
00412 };
00413 }
00414
00415 TAO_END_VERSIONED_NAMESPACE_DECL
00416
00417 #if defined (__ACE_INLINE__)
00418 # include "tao/Valuetype/ValueBase.inl"
00419 #endif
00420
00421 #include "ace/post.h"
00422
00423 #endif