(file) Return to context.cpp CVS log (file) (dir) Up to [OMI] / omi / micxx

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

ViewCVS 0.9.2