Helper class for managing the service context list information. More...
#include <Service_Context.h>
Public Member Functions | |
| TAO_Service_Context (void) | |
| Constructor. | |
| void | set_context (const IOP::ServiceContext &context) |
| = Generic components | |
| int | set_context (const IOP::ServiceContext &context, CORBA::Boolean replace) |
| void | set_context (IOP::ServiceContext &context) |
| int | get_context (IOP::ServiceContext &context) const |
| int | get_context (IOP::ServiceId id, const IOP::ServiceContext **context) const |
| int | get_context (IOP::ServiceId id, IOP::ServiceContext_out context) |
| void | set_context (IOP::ServiceId id, TAO_OutputCDR &cdr) |
| void | set_context (IOP::ServiceContext &context, TAO_OutputCDR &cdr) |
| bool | is_service_id (IOP::ServiceId id) |
| int | encode (TAO_OutputCDR &cdr) const |
| = Marshaling and demarshaling the list | |
| int | decode (TAO_InputCDR &cdr) |
| IOP::ServiceContextList & | service_info (void) |
| Return the underlying service context list. | |
| const IOP::ServiceContextList & | service_info (void) const |
Private Member Functions | |
| void | set_context_i (const IOP::ServiceContext &context) |
| Helper methods to implement set_context(). | |
| 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(). | |
| TAO_Service_Context (const TAO_Service_Context &) | |
| TAO_Service_Context & | operator= (const TAO_Service_Context &) |
Private Attributes | |
| IOP::ServiceContextList | service_context_ |
| The ServiceContextList info. | |
Friends | |
| class | TAO::CSD::FW_Server_Request_Wrapper |
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
Definition at line 60 of file Service_Context.h.
| TAO_Service_Context::TAO_Service_Context | ( | void | ) |
| TAO_Service_Context::TAO_Service_Context | ( | const TAO_Service_Context & | ) | [private] |
| void TAO_Service_Context::add_context_i | ( | const IOP::ServiceContext & | context | ) | [private] |
Definition at line 139 of file Service_Context.cpp.
{
// @@ TODO Some contexts can show up multiple times, others
// can't find out and take appropiate action.
CORBA::ULong const l = this->service_context_.length ();
this->service_context_.length (l + 1);
this->service_context_[l] = context;
}
| void TAO_Service_Context::add_context_i | ( | IOP::ServiceContext & | context | ) | [private] |
Definition at line 125 of file Service_Context.cpp.
{
// @@ TODO Some contexts can show up multiple times, others
// can't find out and take appropiate action.
CORBA::ULong const l = this->service_context_.length ();
this->service_context_.length (l + 1);
this->service_context_[l].context_id = context.context_id;
CORBA::ULong const max = context.context_data.maximum ();
CORBA::ULong const len = context.context_data.length ();
CORBA::Octet* const buf = context.context_data.get_buffer (1);
this->service_context_[l].context_data.replace (max, len, buf, 1);
}
| int TAO_Service_Context::decode | ( | TAO_InputCDR & | cdr | ) |
Definition at line 207 of file Service_Context.cpp.
{
if (!(cdr >> this->service_context_))
{
return 0;
}
return 1;
}
| int TAO_Service_Context::encode | ( | TAO_OutputCDR & | cdr | ) | const |
= Marshaling and demarshaling the list
Definition at line 201 of file Service_Context.cpp.
{
return (cdr << this->service_context_);
}
| 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 149 of file Service_Context.cpp.
{
for (CORBA::ULong i = 0; i != this->service_context_.length (); ++i)
{
if (context.context_id == this->service_context_[i].context_id)
{
context = this->service_context_[i];
return 1;
}
}
return 0;
}
| 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.
{
for (CORBA::ULong i = 0; i != this->service_context_.length (); ++i)
{
if (id == this->service_context_[i].context_id)
{
*context = &this->service_context_[i];
return 1;
}
}
return 0;
}
| 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.
Definition at line 180 of file Service_Context.cpp.
{
CORBA::ULong const len = this->service_context_.length ();
for (CORBA::ULong i = 0; i < len; ++i)
{
if (id == this->service_context_[i].context_id)
{
ACE_NEW_RETURN (context, IOP::ServiceContext, 0);
*(context.ptr ()) = this->service_context_[i];
return 1;
}
}
return 0;
}
| int TAO_Service_Context::get_context_i | ( | IOP::ServiceContext & | context | ) | const [private] |
Helper methods to implement get_context().
| bool TAO_Service_Context::is_service_id | ( | IOP::ServiceId | id | ) |
Is the id available in the underlying service context list? If so return true, else return false
Definition at line 39 of file Service_Context.inl.
{
for (CORBA::ULong i = 0;
i != this->service_context_.length ();
++i)
{
if (id == this->service_context_[i].context_id)
{
return true;
}
}
return false;
}
| TAO_Service_Context& TAO_Service_Context::operator= | ( | const TAO_Service_Context & | ) | [private] |
| IOP::ServiceContextList & TAO_Service_Context::service_info | ( | void | ) |
Return the underlying service context list.
Definition at line 14 of file Service_Context.inl.
{
return this->service_context_;
}
| const IOP::ServiceContextList & TAO_Service_Context::service_info | ( | void | ) | const |
Definition at line 20 of file Service_Context.inl.
{
return this->service_context_;
}
| 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 32 of file Service_Context.inl.
{
this->set_context_i (context, cdr);
}
| 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 66 of file Service_Context.cpp.
{
for (CORBA::ULong i = 0; i != this->service_context_.length (); ++i)
{
if (context.context_id == this->service_context_[i].context_id)
{
if (replace)
{
this->service_context_[i] = context;
return 1;
}
else
{
return 0;
}
}
}
this->add_context_i (context);
return 1;
}
| 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 60 of file Service_Context.cpp.
{
this->add_context_i (context);
}
| 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 26 of file Service_Context.inl.
{
this->set_context_i (id, cdr);
}
| 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 54 of file Service_Context.inl.
{
this->add_context_i (context);
}
| void TAO_Service_Context::set_context_i | ( | const IOP::ServiceContext & | context | ) | [private] |
Helper methods to implement set_context().
Definition at line 90 of file Service_Context.cpp.
{
// @@ TODO Some contexts can show up multiple times, others
// can't find out and take appropiate action.
for (CORBA::ULong i = 0; i != this->service_context_.length (); ++i)
{
if (context.context_id == this->service_context_[i].context_id)
{
this->service_context_[i] = context;
return;
}
}
this->add_context_i (context);
}
| void TAO_Service_Context::set_context_i | ( | IOP::ServiceId | id, | |
| TAO_OutputCDR & | cdr | |||
| ) | [private] |
Definition at line 20 of file Service_Context.cpp.
{
IOP::ServiceContext context;
context.context_id = id;
// Make a *copy* of the CDR stream...
size_t const length = cdr.total_length ();
context.context_data.length (static_cast<CORBA::ULong> (length));
CORBA::Octet *buf = context.context_data.get_buffer ();
for (const ACE_Message_Block *i = cdr.begin ();
i != 0;
i = i->cont ())
{
ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
buf += i->length ();
}
this->set_context_i (context);
}
| void TAO_Service_Context::set_context_i | ( | IOP::ServiceContext & | context, | |
| TAO_OutputCDR & | cdr | |||
| ) | [private] |
Definition at line 42 of file Service_Context.cpp.
{
// Make a *copy* of the CDR stream...
size_t const length = cdr.total_length ();
context.context_data.length (static_cast<CORBA::ULong> (length));
CORBA::Octet *buf = context.context_data.get_buffer ();
for (const ACE_Message_Block *i = cdr.begin ();
i != 0;
i = i->cont ())
{
ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
buf += i->length ();
}
}
| void TAO_Service_Context::set_context_i | ( | IOP::ServiceContext & | context | ) | [private] |
Definition at line 107 of file Service_Context.cpp.
{
for (CORBA::ULong i = 0; i != this->service_context_.length (); ++i)
{
if (context.context_id == this->service_context_[i].context_id)
{
CORBA::ULong const max = context.context_data.maximum ();
CORBA::ULong const len = context.context_data.length ();
CORBA::Octet * const buf = context.context_data.get_buffer (1);
this->service_context_[i].context_data.replace (max, len, buf, 1);
return;
}
}
this->add_context_i (context);
}
friend class TAO::CSD::FW_Server_Request_Wrapper [friend] |
Declare FW_Server_Request_Wrapper a friend This friendship makes the FW_Server_Request_Wrapper be able to clone the TAO_Service_Context data member in TAO_ServerRequest.
Definition at line 66 of file Service_Context.h.
IOP::ServiceContextList TAO_Service_Context::service_context_ [private] |
The ServiceContextList info.
Definition at line 148 of file Service_Context.h.
1.7.0