1 martin 1.4 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.5 //
|
3 martin 1.4 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.5 //
|
10 martin 1.4 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.5 //
|
17 martin 1.4 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.5 //
|
20 martin 1.4 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.5 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.4 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.5 //
|
28 martin 1.4 //////////////////////////////////////////////////////////////////////////
|
29 kumpf 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include "ProviderStatus.h"
|
33 kumpf 1.3 #include <Pegasus/Common/Time.h>
34 #include <Pegasus/Common/PegasusAssert.h>
|
35 kumpf 1.1
36 PEGASUS_NAMESPACE_BEGIN
37
38 ProviderStatus::ProviderStatus()
39 {
|
40 kumpf 1.3 setInitialized(false);
|
41 kumpf 1.1 }
42
43 ProviderStatus::~ProviderStatus()
44 {
45 }
46
47 Boolean ProviderStatus::isInitialized()
48 {
49 AutoMutex lock(_statusMutex);
50 return _isInitialized;
51 }
52
53 void ProviderStatus::setInitialized(Boolean initialized)
54 {
55 AutoMutex lock(_statusMutex);
56 _isInitialized = initialized;
|
57 kumpf 1.3
58 if (!_isInitialized)
59 {
60 _module = 0;
61 _cimomHandle = 0;
62 _currentOperations = 0;
63 _indicationsEnabled = false;
64 _currentSubscriptions = 0;
65 }
66
67 Time::gettimeofday(&_lastOperationEndTime);
|
68 kumpf 1.1 }
69
70 ProviderModule* ProviderStatus::getModule() const
71 {
72 return _module;
73 }
74
75 void ProviderStatus::setModule(ProviderModule* module)
76 {
77 _module = module;
78 }
79
|
80 kumpf 1.3 CIMOMHandle* ProviderStatus::getCIMOMHandle()
|
81 kumpf 1.1 {
|
82 kumpf 1.3 return _cimomHandle;
|
83 kumpf 1.1 }
84
|
85 kumpf 1.3 void ProviderStatus::setCIMOMHandle(CIMOMHandle* cimomHandle)
|
86 kumpf 1.1 {
|
87 kumpf 1.3 _cimomHandle = cimomHandle;
|
88 kumpf 1.1 }
89
|
90 kumpf 1.3 void ProviderStatus::getLastOperationEndTime(struct timeval* t)
|
91 kumpf 1.1 {
|
92 kumpf 1.3 PEGASUS_ASSERT(t != 0);
93 AutoMutex lock(_lastOperationEndTimeMutex);
94 memcpy(t, &_lastOperationEndTime, sizeof(struct timeval));
|
95 kumpf 1.1 }
96
|
97 kumpf 1.3 Boolean ProviderStatus::isIdle()
|
98 kumpf 1.1 {
|
99 kumpf 1.3 if (!_isInitialized ||
100 (_currentOperations.get() > 0) ||
101 _indicationsEnabled)
|
102 kumpf 1.1 {
|
103 kumpf 1.3 return false;
|
104 kumpf 1.1 }
105
|
106 kumpf 1.3 if (_cimomHandle)
|
107 kumpf 1.1 {
|
108 kumpf 1.3 return _cimomHandle->unload_ok();
|
109 kumpf 1.1 }
110
|
111 kumpf 1.3 return true;
|
112 kumpf 1.1 }
113
|
114 kumpf 1.3 void ProviderStatus::operationBegin()
115 {
116 _currentOperations++;
117 }
|
118 kumpf 1.1
|
119 kumpf 1.3 void ProviderStatus::operationEnd()
|
120 kumpf 1.1 {
|
121 kumpf 1.3 _currentOperations--;
|
122 kumpf 1.1
|
123 kumpf 1.3 // Update the timer used to detect idle providers
124 AutoMutex lock(_lastOperationEndTimeMutex);
125 Time::gettimeofday(&_lastOperationEndTime);
126 }
|
127 kumpf 1.1
|
128 kumpf 1.3 Uint32 ProviderStatus::numCurrentOperations() const
129 {
130 return _currentOperations.get();
|
131 kumpf 1.1 }
132
|
133 kumpf 1.3 Boolean ProviderStatus::getIndicationsEnabled() const
|
134 kumpf 1.1 {
|
135 kumpf 1.3 return _indicationsEnabled;
|
136 kumpf 1.1 }
137
|
138 kumpf 1.3 void ProviderStatus::setIndicationsEnabled(Boolean indicationsEnabled)
|
139 kumpf 1.1 {
|
140 kumpf 1.3 _indicationsEnabled = indicationsEnabled;
|
141 kumpf 1.1 }
142
143 Boolean ProviderStatus::testIfZeroAndIncrementSubscriptions()
144 {
145 AutoMutex lock(_currentSubscriptionsMutex);
146 return (_currentSubscriptions++ == 0);
147 }
148
149 Boolean ProviderStatus::decrementSubscriptionsAndTestIfZero()
150 {
151 AutoMutex lock(_currentSubscriptionsMutex);
152 return (--_currentSubscriptions == 0);
153 }
154
155 Boolean ProviderStatus::testSubscriptions()
156 {
157 AutoMutex lock(_currentSubscriptionsMutex);
158 return (_currentSubscriptions > 0);
159 }
160
161 void ProviderStatus::resetSubscriptions()
162 kumpf 1.1 {
163 AutoMutex lock(_currentSubscriptionsMutex);
164 _currentSubscriptions = 0;
165 }
166
167 void ProviderStatus::setProviderInstance(const CIMInstance& instance)
168 {
169 _providerInstance = instance;
170 }
171
172 CIMInstance ProviderStatus::getProviderInstance()
173 {
174 return _providerInstance;
175 }
176
|
177 kumpf 1.3 Mutex& ProviderStatus::getStatusMutex()
178 {
179 return _statusMutex;
180 }
181
|
182 kumpf 1.1 PEGASUS_NAMESPACE_END
|