Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Service_Context.h
blobfc1668c4125b49b84a044e83229e557d60270df8
1 // -*- C++ -*-
3 // ===================================================================
4 /**
5 * @file Service_Context.h
7 * @author Balachandran Natarajan <bala@cs.wustl.edu>
8 */
9 // ===================================================================
11 #ifndef TAO_SERVICE_CONTEXT_H
12 #define TAO_SERVICE_CONTEXT_H
14 #include /**/ "ace/pre.h"
16 #include "tao/IOPC.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
24 namespace TAO
26 namespace CSD
28 class FW_Server_Request_Wrapper;
32 /**
33 * @class TAO_Service_Context
35 * @brief Helper class for managing the service context list
36 * information.
38 * This class is used to manipulate and access the service context
39 * list that is passed around with every GIOP request/reply. The
40 * definition of the service context list is simply a sequence of the
41 * following structures:
42 * typedef unsigned long ServiceId;
43 * struct ServiceContext
44 * {
45 * ServiceId context_id;
46 * sequence <octet> context_data;
47 * };
48 * typedef sequence <ServiceContext> ServiceContextList;
50 * the real motivation behind this class is to consolidate all the
51 * marshalling and unmarshalling information pertaining to service
52 * context list
54 * @note Somewhere down the line we may want to use this class for
55 * fast access to the info that we need from the Service Context
56 * List.
58 class TAO_Export TAO_Service_Context
60 public:
61 /// Declare FW_Server_Request_Wrapper a friend
62 /// This friendship makes the FW_Server_Request_Wrapper be able to
63 /// clone the TAO_Service_Context data member in TAO_ServerRequest.
64 friend class TAO::CSD::FW_Server_Request_Wrapper;
66 /// Constructor
67 TAO_Service_Context ();
69 /// = Generic components
71 /// Insert the component into the list, making a copy of the octet
72 /// sequence.
73 void set_context (const IOP::ServiceContext &context);
75 /// Insert the component into the list, making a copy of the octet
76 /// sequence. Search the list before insertion so that the
77 /// insertion does not cause a duplicate context to be in the list.
78 /// If the replace flag is true, update the specified context.
79 /// Return 0 if the component was present and the replace flag
80 /// was not set to true.
81 int set_context (const IOP::ServiceContext &context, CORBA::Boolean replace);
83 /// Insert the component into the list, but efficiently stealing the
84 /// contents of the octet sequence.
85 void set_context (IOP::ServiceContext &context);
87 /// Get a copy of the context identified by <context.context_id>, return
88 /// 0 if the component is not present.
89 int get_context (IOP::ServiceContext &context) const;
91 /// Get a reference to a context identified by id, return
92 /// 0 if the component is not present.
93 int get_context (IOP::ServiceId id, const IOP::ServiceContext **context) const;
95 /// Get a copy of the Service Context corresponding to the given
96 /// ServiceId. The caller owns the returned Service Context.
97 /**
98 * @return 0 If a Service Context with the given ServiceId doesn't
99 * exist.
101 int get_context (IOP::ServiceId id, IOP::ServiceContext_out context);
103 /// Set the context from the CDR stream and add that to the service
104 /// Context list
105 void set_context (IOP::ServiceId id, TAO_OutputCDR &cdr);
107 /// Set the context from the CDR stream and return the context back
108 /// to the caller. *Does not* modify the underlying service context
109 /// list.
110 void set_context (IOP::ServiceContext &context, TAO_OutputCDR &cdr);
112 /// Is the @a id available in the underlying service context list? If
113 /// so return true, else return false
114 bool is_service_id (IOP::ServiceId id);
116 /// = Marshaling and demarshaling the list
117 int encode (TAO_OutputCDR& cdr) const;
118 int decode (TAO_InputCDR& cdr);
120 /// Return the underlying service context list
121 IOP::ServiceContextList &service_info ();
123 /// @note This method is only for backward comptiblity. We
124 /// need to get this removed once RT folks have their service
125 /// addition info done through this interface
126 const IOP::ServiceContextList &service_info () const;
128 private:
129 /// Helper methods to implement set_context()
130 void set_context_i (const IOP::ServiceContext &context);
131 void set_context_i (IOP::ServiceContext &context);
132 void add_context_i (const IOP::ServiceContext &context);
133 void add_context_i (IOP::ServiceContext &context);
134 void set_context_i (IOP::ServiceId id, TAO_OutputCDR &cdr);
135 void set_context_i (IOP::ServiceContext &context, TAO_OutputCDR &cdr);
137 /// Helper methods to implement get_context()
138 int get_context_i (IOP::ServiceContext &context) const;
140 // Prevent copying
141 TAO_Service_Context (const TAO_Service_Context &);
142 TAO_Service_Context &operator= (const TAO_Service_Context &);
144 private:
145 /// The ServiceContextList info.
146 IOP::ServiceContextList service_context_;
149 TAO_END_VERSIONED_NAMESPACE_DECL
151 #if defined (__ACE_INLINE__)
152 # include "tao/Service_Context.inl"
153 #endif /* ! __ACE_INLINE__ */
155 #include /**/ "ace/post.h"
157 #endif /* TAO_SERVICE_CONTEXT_H */