1 mike 1.1 /*
2 **==============================================================================
3 **
4 ** Open Management Infrastructure (OMI)
5 **
6 ** Copyright (c) Microsoft Corporation
7 **
8 ** Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 ** use this file except in compliance with the License. You may obtain a copy
10 ** of the License at
11 **
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 **
14 ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 ** MERCHANTABLITY OR NON-INFRINGEMENT.
18 **
19 ** See the Apache 2 License for the specific language governing permissions
20 ** and limitations under the License.
21 **
22 mike 1.1 **==============================================================================
23 */
24
25 #ifndef _context_h
26 #define _context_h
27
28 #include <common.h>
29 #include <base/base.h>
|
30 krisbash 1.3 #include <base/Strand.h>
31 #include <pal/thread.h>
|
32 mike 1.1 #include "provmgr.h"
|
33 krisbash 1.3 #include <pal/lock.h>
|
34 mike 1.1
35 BEGIN_EXTERNC
36
|
37 krisbash 1.3 #define CONTEXT_STRANDAUX_TRYPOSTLEFT 0
38 #define CONTEXT_STRANDAUX_TRYPOSTLEFT_NOTIFY 1
39 #define CONTEXT_STRANDAUX_INVOKESUBSCRIBE 2
40
|
41 mike 1.1 typedef enum _Context_Type
42 {
|
43 krisbash 1.3 CTX_TYPE_SINGLE_ITEM = 0, /* regular execution, post results to the caller */
44 CTX_TYPE_IND_AGGREGATION, /* indication context (AggregationContext) */
45 CTX_TYPE_IND_SUBSCRIPTION, /* indication context (SubscriptionContext) */
46 CTX_TYPE_IND_LIFECYCLE, /* indication context (LifecycleContext) */
47 CTX_TYPE_IND_SUB_UNSUB, /* indication context for invoking Subscribe and Unsubscribe */
|
48 mike 1.1 CTX_TYPE_INVOKE_WITH_INSTANCE /* calling get before invoke - call invoke with result instance */
49 }
50 Context_Type;
51
|
52 krisbash 1.3 // for Context.tryingToPostLeft
53 #define CONTEXT_POSTLEFT_POSTING 1 // If Context_PostMessageLeft is trying to post to the left
54 #define CONTEXT_POSTLEFT_SCHEDULED 2 // If CONTEXT_STRANDAUX_POSTLEFT is currently scheduled
55
|
56 mike 1.1 typedef struct _Context
57 {
58 MI_Context base;
59 MI_Uint32 magic;
60
|
61 krisbash 1.3 Strand strand; // manages interaction with the component to the left (dispatcher, agent, etc.)
62 Lock lock;
63 Message * msgPostingLeft;
64 volatile ptrdiff_t tryingToPostLeft; // CONTEXT_POSTLEFT_* flags
65
|
66 mike 1.1 /* Pointer to the request message (containing the callback) */
|
67 krisbash 1.3 RequestMsg* request;
68 Message* loadRequest;
|
69 mike 1.1
70 /* chain processing */
|
71 krisbash 1.3 Context_Type ctxType;
|
72 mike 1.1
73 /* delayed invoke parameters */
|
74 krisbash 1.3 MI_MethodDecl* md;
75 MI_Instance* inst;
76 MI_Instance* instParams;
77 void * prov_self;
|
78 mike 1.1
79 /* Cancelled flag */
|
80 krisbash 1.3 MI_Boolean cancelled;
|
81 mike 1.1
82 /* Reference to Provider */
|
83 krisbash 1.3 Provider* provider;
|
84 mike 1.1
85 /* Result to caller */
|
86 krisbash 1.3 MI_Result* result;
|
87 mike 1.1
88 /* If non-null, PostInstance() only forwards 1st matching instance. */
|
89 krisbash 1.3 MI_Instance* instanceName;
|
90 mike 1.1
91 /* Whether instanceName has been matched yet. */
|
92 krisbash 1.3 MI_Boolean matchedInstanceName;
93
94 // Uncomment when no longer using Selector
95 // #if !defined(CONFIG_OS_WINDOWS)
96 /* If Context_PostMessageLeft is trying to post from the IO thread */
97 MI_Boolean postingOnIoThread;
98 // #endif
99
100 /* Information needed if provider does not post a response instance as part of a modify command*/
101 MI_Instance * keyInstance;
102 MI_Boolean postedModifyGetInstance;
103 MI_Boolean postedModifyEnumInstance;
104 MI_Boolean postedModifyInstance;
|
105 mike 1.1 }
106 Context;
107
|
108 krisbash 1.3 typedef enum _ContextInitOptions
109 {
110 ContextInit_CompleteOpen = 0,
111 ContextInit_DelayOpen = 1,
112 ContextInit_DontLeaveStrand = 2,
113 ContextInit_NoInteraction = 3
114 }
115 ContextInitOptions;
116
|
117 mike 1.1
|
118 krisbash 1.3 MI_Result _Context_Init(
119 _Out_ Context* self,
120 _In_opt_ Provider* provider,
121 _Inout_opt_ InteractionOpenParams* interactionParams,
122 ContextInitOptions options,
123 Context_Type ctxType );
124
125 void _Context_Destroy(
126 _Inout_ Context* self);
127
128 MI_INLINE
129 MI_Result Context_Init(
130 _Out_ Context* self,
131 _In_opt_ Provider* provider,
132 _Inout_opt_ InteractionOpenParams* interactionParams)
133 {
134 ContextInitOptions option = (NULL == interactionParams) ? ContextInit_NoInteraction : ContextInit_CompleteOpen;
135 return _Context_Init( self, provider, interactionParams, option, CTX_TYPE_SINGLE_ITEM );
136 }
137
138 MI_INLINE
139 krisbash 1.3 MI_Result Context_Init_ByType(
140 _Out_ Context* self,
141 _In_ Provider* provider,
142 _Inout_ InteractionOpenParams* interactionParams,
143 _In_ Context_Type ctxType )
144 {
145 return _Context_Init( self, provider, interactionParams, ContextInit_DontLeaveStrand, ctxType );
146 }
147
148 MI_INLINE
149 MI_Result Context_PartialInit(
150 _Out_ Context* self,
151 _In_ Provider* provider,
152 _Inout_ InteractionOpenParams* interactionParams)
153 {
154 return _Context_Init( self, provider, interactionParams, ContextInit_DelayOpen, CTX_TYPE_SINGLE_ITEM );
155 }
156
157 void Context_CompleteOpen(
158 _In_ Context* self,
159 _In_ InteractionOpenParams* params,
160 krisbash 1.3 MI_Result result);
161
162 void Context_Close(
163 _In_ _Post_invalid_ Context* self );
164
165 // this is to be used by provmgr to post schema; not exposed to the provider
166 void Context_PostSchema(
167 _In_ Context* self,
168 _In_ Message* msg);
169
170 // Post a message to the component to the left
171 void Context_PostMessageLeft(
172 _In_ Context* self,
173 _In_ Message* msg);
|
174 mike 1.1
175 extern MI_ContextFT __mi_contextFT;
176
|
177 krisbash 1.3 //
178 // Initialize subscribe/unsubscribe context
179 //
180 MI_Result Subunsub_Context_Init(
181 _Out_ Context* self,
182 _In_ MI_Result* result,
183 _In_ RequestMsg* msg);
184
|
185 mike 1.1 END_EXTERNC
186
187 #endif /* _context_h */
|