Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Service_Context Class Reference

Helper class for managing the service context list information. More...

#include <Service_Context.h>

Collaboration diagram for TAO_Service_Context:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_Service_Context (void)
 Constructor. More...

void set_context (const IOP::ServiceContext &context)
 = Generic components Insert the component into the list, making a copy of the octet sequence. More...

int set_context (const IOP::ServiceContext &context, CORBA::Boolean replace)
 Insert the component into the list, making a copy of the octet sequence. Search the list before insertion so that the insertion does not cause a duplicate context to be in the list. If the replace flag is true, update the specified context. Return 0 if the component was present and the replace flag was not set to true. More...

void set_context (IOP::ServiceContext &context)
 Insert the component into the list, but efficiently stealing the contents of the octet sequence. More...

int get_context (IOP::ServiceContext &context) const
 Get a copy of the context identified by <context.context_id>, return 0 if the component is not present. More...

int get_context (IOP::ServiceId id, const IOP::ServiceContext **context) const
 Get a reference to a context identified by id, return 0 if the component is not present. More...

int get_context (IOP::ServiceId id, IOP::ServiceContext_out context)
 Get a copy of the Service Context corresponding to the given ServiceId. The caller owns the returned Service Context. More...

void set_context (IOP::ServiceId id, TAO_OutputCDR &cdr)
 Set the context from the CDR stream and add that to the service Context list. More...

void set_context (IOP::ServiceContext &context, TAO_OutputCDR &cdr)
 Set the context from the CDR stream and return the context back to the caller. *Does not* modify the underlying service context list. More...

int is_service_id (IOP::ServiceId id)
 Is the <id> available in the underlying service context list? If so return 1, else return 0. More...

int encode (TAO_OutputCDR &cdr) const
 = Marshaling and demarshaling the list. More...

int decode (TAO_InputCDR &cdr)
IOP::ServiceContextListservice_info (void)
 Return the underlying service context list. More...

const IOP::ServiceContextListservice_info (void) const

Private Methods

void set_context_i (const IOP::ServiceContext &context)
 Helper methods to implement set_context(). More...

void set_context_i (IOP::ServiceContext &context)
void add_context_i (const IOP::ServiceContext &context)
void add_context_i (IOP::ServiceContext &context)
void set_context_i (IOP::ServiceId id, TAO_OutputCDR &cdr)
void set_context_i (IOP::ServiceContext &context, TAO_OutputCDR &cdr)
int get_context_i (IOP::ServiceContext &context) const
 Helper methods to implement get_context(). More...


Private Attributes

IOP::ServiceContextList service_context_
 The ServiceContextList info. More...


Detailed Description

Helper class for managing the service context list information.

This class is used to manipulate and access the service context list that is passed around with every GIOP request/reply. The definition of the service context list is simply a sequence of the following structures: typedef unsigned long ServiceId; struct ServiceContext { ServiceId context_id; sequence <octet> context_data; }; typedef sequence <ServiceContext> ServiceContextList;

the real motivation behind this class is to consolidate all the marshalling and unmarshalling information pertaining to service context list

Note: Somewhere down the line we may want to use this class for fast access to the info that we need from the Service Context List.

Definition at line 54 of file Service_Context.h.


Constructor & Destructor Documentation

ACE_INLINE TAO_Service_Context::TAO_Service_Context void   
 

Constructor.

Definition at line 6 of file Service_Context.inl.

00007   : service_context_ ()
00008 {
00009 }


Member Function Documentation

void TAO_Service_Context::add_context_i IOP::ServiceContext   context [private]
 

Definition at line 126 of file Service_Context.cpp.

References IOP::ServiceContext::context_data, IOP::ServiceContext::context_id, TAO_Unbounded_Base_Sequence::length, IOP::_TAO_Unbounded_Sequence_IOP_ServiceContextList::replace, and service_context_.

00127 {
00128   // @@ TODO Some contexts can show up multiple times, others
00129   //    can't find out and take appropiate action.
00130   CORBA::ULong l = this->service_context_.length ();
00131   this->service_context_.length (l + 1);
00132   this->service_context_[l].context_id = context.context_id;
00133   CORBA::ULong max = context.context_data.maximum ();
00134   CORBA::ULong len = context.context_data.length ();
00135   CORBA::Octet* buf = context.context_data.get_buffer (1);
00136   this->service_context_[l].context_data.replace (max, len, buf, 1);
00137 }

void TAO_Service_Context::add_context_i const IOP::ServiceContext   context [private]
 

Definition at line 140 of file Service_Context.cpp.

References TAO_Unbounded_Base_Sequence::length, and service_context_.

Referenced by set_context, and set_context_i.

00141 {
00142   // @@ TODO Some contexts can show up multiple times, others
00143   //    can't find out and take appropiate action.
00144   CORBA::ULong l = this->service_context_.length ();
00145   this->service_context_.length (l + 1);
00146   this->service_context_[l] = context;
00147 }

int TAO_Service_Context::decode TAO_InputCDR   cdr
 

Definition at line 205 of file Service_Context.cpp.

References service_context_.

00206 {
00207   if ((cdr >> this->service_context_) == 0)
00208     return 0;
00209 
00210   return 1;
00211 }

int TAO_Service_Context::encode TAO_OutputCDR   cdr const
 

= Marshaling and demarshaling the list.

Definition at line 199 of file Service_Context.cpp.

References service_context_.

00200 {
00201   return (cdr << this->service_context_);
00202 }

int TAO_Service_Context::get_context IOP::ServiceId    id,
IOP::ServiceContext_out    context
 

Get a copy of the Service Context corresponding to the given ServiceId. The caller owns the returned Service Context.

Returns:
0 If a Service Context with the given ServiceId doesn't exist.

Definition at line 178 of file Service_Context.cpp.

References ACE_NEW_RETURN, TAO_Unbounded_Base_Sequence::length, IOP::ServiceContext_out::ptr, and service_context_.

00180 {
00181   CORBA::ULong len = this->service_context_.length ();
00182 
00183   for (CORBA::ULong i = 0; i < len; ++i)
00184     {
00185       if (id == this->service_context_[i].context_id)
00186         {
00187           ACE_NEW_RETURN (context, IOP::ServiceContext, 0);
00188 
00189           *(context.ptr ()) = this->service_context_[i];
00190 
00191           return 1;
00192         }
00193     }
00194 
00195   return 0;
00196 }

int TAO_Service_Context::get_context IOP::ServiceId    id,
const IOP::ServiceContext **    context
const
 

Get a reference to a context identified by id, return 0 if the component is not present.

Definition at line 164 of file Service_Context.cpp.

References TAO_Unbounded_Base_Sequence::length, and service_context_.

00165 {
00166   for (CORBA::ULong i = 0; i != this->service_context_.length (); ++i)
00167     {
00168       if (id == this->service_context_[i].context_id)
00169         {
00170           *context = &this->service_context_[i];
00171           return 1;
00172         }
00173     }
00174   return 0;
00175 }

int TAO_Service_Context::get_context IOP::ServiceContext   context const
 

Get a copy of the context identified by <context.context_id>, return 0 if the component is not present.

Definition at line 150 of file Service_Context.cpp.

References IOP::ServiceContext::context_id, TAO_Unbounded_Base_Sequence::length, and service_context_.

Referenced by TAO_GIOP_Message_Generator_Parser_12::process_bidir_context, and TAO_Codeset_Manager::process_service_context.

00151 {
00152   for (CORBA::ULong i = 0; i != this->service_context_.length (); ++i)
00153     {
00154       if (context.context_id == this->service_context_[i].context_id)
00155         {
00156           context = this->service_context_[i];
00157           return 1;
00158         }
00159     }
00160   return 0;
00161 }

int TAO_Service_Context::get_context_i IOP::ServiceContext   context const [private]
 

Helper methods to implement get_context().

ACE_INLINE int TAO_Service_Context::is_service_id IOP::ServiceId    id
 

Is the <id> available in the underlying service context list? If so return 1, else return 0.

Definition at line 42 of file Service_Context.inl.

References TAO_Unbounded_Base_Sequence::length, and service_context_.

Referenced by TAO_GIOP_Message_Generator_Parser_12::check_bidirectional_context.

00043 {
00044   for (CORBA::ULong i = 0;
00045        i != this->service_context_.length ();
00046        ++i)
00047     {
00048       if (id == this->service_context_[i].context_id)
00049         {
00050           return 1;
00051         }
00052     }
00053   return 0;
00054 }

ACE_INLINE const IOP::ServiceContextList & TAO_Service_Context::service_info void    const
 

Definition at line 18 of file Service_Context.inl.

References service_context_.

00019 {
00020   return this->service_context_;
00021 }

ACE_INLINE IOP::ServiceContextList & TAO_Service_Context::service_info void   
 

Return the underlying service context list.

Definition at line 12 of file Service_Context.inl.

References service_context_.

Referenced by TAO_ServerRequest::reply_service_info, TAO_Operation_Details::reply_service_info, TAO_ServerRequest::request_service_info, and TAO_Operation_Details::request_service_info.

00013 {
00014   return this->service_context_;
00015 }

ACE_INLINE void TAO_Service_Context::set_context IOP::ServiceContext   context,
TAO_OutputCDR   cdr
 

Set the context from the CDR stream and return the context back to the caller. *Does not* modify the underlying service context list.

Definition at line 33 of file Service_Context.inl.

References set_context_i.

00035 {
00036   this->set_context_i (context,
00037                        cdr);
00038 }

ACE_INLINE void TAO_Service_Context::set_context IOP::ServiceId    id,
TAO_OutputCDR   cdr
 

Set the context from the CDR stream and add that to the service Context list.

Definition at line 25 of file Service_Context.inl.

References set_context_i.

00027 {
00028   this->set_context_i (id,
00029                        cdr);
00030 }

void TAO_Service_Context::set_context IOP::ServiceContext   context
 

Insert the component into the list, but efficiently stealing the contents of the octet sequence.

Definition at line 87 of file Service_Context.cpp.

References add_context_i.

00088 {
00089   this->add_context_i (context);
00090 }

int TAO_Service_Context::set_context const IOP::ServiceContext   context,
CORBA::Boolean    replace
 

Insert the component into the list, making a copy of the octet sequence. Search the list before insertion so that the insertion does not cause a duplicate context to be in the list. If the replace flag is true, update the specified context. Return 0 if the component was present and the replace flag was not set to true.

Definition at line 65 of file Service_Context.cpp.

References add_context_i, IOP::ServiceContext::context_id, TAO_Unbounded_Base_Sequence::length, and service_context_.

00067 {
00068   for (CORBA::ULong i = 0; i != this->service_context_.length (); ++i)
00069     {
00070       if (context.context_id == this->service_context_[i].context_id)
00071         {
00072           if (replace)
00073             {
00074               this->service_context_[i] = context;
00075               return 1;
00076             }
00077           else
00078             return 0;
00079         }
00080     }
00081 
00082   this->add_context_i (context);
00083   return 1;
00084 }

void TAO_Service_Context::set_context const IOP::ServiceContext   context
 

= Generic components Insert the component into the list, making a copy of the octet sequence.

Definition at line 59 of file Service_Context.cpp.

References add_context_i.

Referenced by TAO_ClientRequestInfo_i::add_request_service_context, TAO_Codeset_Manager::generate_service_context, and TAO_IIOP_Transport::set_bidir_context_info.

00060 {
00061   this->add_context_i (context);
00062 }

void TAO_Service_Context::set_context_i IOP::ServiceContext   context,
TAO_OutputCDR   cdr
[private]
 

Definition at line 40 of file Service_Context.cpp.

References ACE_OutputCDR::begin, ACE_Message_Block::cont, IOP::ServiceContext::context_data, ACE_Message_Block::length, ACE_OS_String::memcpy, ACE_Message_Block::rd_ptr, and ACE_OutputCDR::total_length.

00042 {
00043   // Make a *copy* of the CDR stream...
00044   size_t length = cdr.total_length ();
00045   context.context_data.length (ACE_static_cast(CORBA::ULong, length));
00046   CORBA::Octet *buf = context.context_data.get_buffer ();
00047 
00048   for (const ACE_Message_Block *i = cdr.begin ();
00049        i != 0;
00050        i = i->cont ())
00051     {
00052       ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
00053       buf += i->length ();
00054     }
00055 }

void TAO_Service_Context::set_context_i IOP::ServiceId    id,
TAO_OutputCDR   cdr
[private]
 

Definition at line 16 of file Service_Context.cpp.

References ACE_OutputCDR::begin, ACE_Message_Block::cont, IOP::ServiceContext::context_data, IOP::ServiceContext::context_id, ACE_Message_Block::length, ACE_OS_String::memcpy, ACE_Message_Block::rd_ptr, set_context_i, and ACE_OutputCDR::total_length.

00018 {
00019   IOP::ServiceContext context;
00020   context.context_id = id;
00021 
00022   // Make a *copy* of the CDR stream...
00023   size_t length = cdr.total_length ();
00024   context.context_data.length (ACE_static_cast(CORBA::ULong, length));
00025   CORBA::Octet *buf = context.context_data.get_buffer ();
00026 
00027   for (const ACE_Message_Block *i = cdr.begin ();
00028        i != 0;
00029        i = i->cont ())
00030     {
00031       ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
00032       buf += i->length ();
00033     }
00034 
00035   this->set_context_i (context);
00036 }

void TAO_Service_Context::set_context_i IOP::ServiceContext   context [private]
 

Definition at line 109 of file Service_Context.cpp.

References add_context_i, IOP::ServiceContext::context_data, IOP::ServiceContext::context_id, TAO_Unbounded_Base_Sequence::length, IOP::_TAO_Unbounded_Sequence_IOP_ServiceContextList::replace, and service_context_.

00110 {
00111   for (CORBA::ULong i = 0; i != this->service_context_.length (); ++i)
00112     {
00113       if (context.context_id == this->service_context_[i].context_id)
00114         {
00115           CORBA::ULong max = context.context_data.maximum ();
00116           CORBA::ULong len = context.context_data.length ();
00117           CORBA::Octet* buf = context.context_data.get_buffer (1);
00118           this->service_context_[i].context_data.replace (max, len, buf, 1);
00119           return;
00120         }
00121     }
00122   this->add_context_i (context);
00123 }

void TAO_Service_Context::set_context_i const IOP::ServiceContext   context [private]
 

Helper methods to implement set_context().

Definition at line 93 of file Service_Context.cpp.

References add_context_i, IOP::ServiceContext::context_id, TAO_Unbounded_Base_Sequence::length, and service_context_.

Referenced by set_context, and set_context_i.

00094 {
00095   // @@ TODO Some contexts can show up multiple times, others
00096   //    can't find out and take appropiate action.
00097   for (CORBA::ULong i = 0; i != this->service_context_.length (); ++i)
00098     {
00099       if (context.context_id == this->service_context_[i].context_id)
00100         {
00101           this->service_context_[i] = context;
00102           return;
00103         }
00104     }
00105   this->add_context_i (context);
00106 }


Member Data Documentation

IOP::ServiceContextList TAO_Service_Context::service_context_ [private]
 

The ServiceContextList info.

Definition at line 137 of file Service_Context.h.

Referenced by add_context_i, decode, encode, get_context, is_service_id, service_info, set_context, and set_context_i.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:39:32 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002