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 #include "context.h"
|
27 mike 1.1
28 MI_BEGIN_NAMESPACE
29
30 Context::Context(MI_Context* context) :
31 m_context(context),
32 m_result(0)
33 {
34 }
35
36 Context::Context(MI_Context* context, MI_Result* result) :
37 m_context(context),
38 m_result(result)
39 {
40 }
41
42 /* ATTN: is this safe? */
43 Context::Context(const Context& x)
44 {
45 m_context = x.m_context;
46 m_result = x.m_result;
47 }
48 mike 1.1
49 MI_Result Context::Post(const Instance& instance)
50 {
51 return MI_PostInstance(m_context, instance.m_instance);
52 }
53
54 MI_Result Context::Post(MI_Result result)
55 {
56 if (NULL != m_result)
57 {
58 *m_result = result;
59 return MI_RESULT_OK;
60 }
61 else
62 {
63 MI_Result r = MI_PostResult(m_context, result);
64
65 // invalidate context, since PostResult must be the last operation on
66 // MI_Context
67 m_context = 0;
68
69 mike 1.1 return r;
70 }
71 }
72
73 MI_Result Context::Post(
74 const Instance& indication,
75 MI_Uint32 subscriptionIDCount,
76 const String& bookmark)
77 {
78 return MI_PostIndication(m_context, indication.m_instance,
79 subscriptionIDCount, bookmark.Str());
80 }
81
82 MI_Result Context::Post(MI_Result result, const String& message)
83 {
84 if (NULL != m_result)
85 {
86 *m_result = result;
87 return MI_RESULT_OK;
88 }
89
90 mike 1.1 MI_Result r = MI_PostResultWithMessage(m_context, result, message.Str());
91
92 // invalidate context, since PostResult must be the last operation on
93 // MI_Context
94 m_context = 0;
95
96 return r;
97 }
98
99 MI_Result Context::Post(MI_Result result, const CIM_Error_Class& instance)
100 {
101 if (NULL != m_result)
102 {
103 *m_result = result;
104 return MI_RESULT_OK;
105 }
106
107 const Instance* tmp = reinterpret_cast<const Instance*>(&instance);
108 MI_Result r = MI_PostResultWithError(m_context, result, tmp->m_instance);
109
110 // invalidate context, since PostResult must be the last operation on
111 mike 1.1 // MI_Context
112 m_context = 0;
113
114 return r;
115 }
116
117 MI_Result Context::RequestUnload()
118 {
119 return MI_RequestUnload(m_context);
120 }
121
122 MI_Result Context::RefuseUnload()
123 {
124 return MI_RefuseUnload(m_context);
125 }
126
127 MI_END_NAMESPACE
|