(file) Return to InstanceProvider.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Providers / sample / InstanceProvider

  1 karl  1.28 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.2  //
  3 karl  1.25 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.20 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.25 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.26 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.28 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 mike  1.2  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15            // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18            // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20 karl  1.25 // 
 21 mike  1.2  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30            //==============================================================================
 31            //
 32            // Author: Chip Vincent (cvincent@us.ibm.com)
 33            //
 34 kumpf 1.21 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 35 mike  1.2  //
 36            //%/////////////////////////////////////////////////////////////////////////////
 37            
 38            #include "InstanceProvider.h"
 39            
 40 dave.sudlik 1.22 PEGASUS_USING_PEGASUS;
 41 mike        1.2  
 42                  InstanceProvider::InstanceProvider(void)
 43                  {
 44                  }
 45                  
 46                  InstanceProvider::~InstanceProvider(void)
 47                  {
 48                  }
 49                  
 50 chip        1.3  void InstanceProvider::initialize(CIMOMHandle & cimom)
 51 mike        1.2  {
 52                  	// create default instances
 53 chip        1.6  	CIMInstance instance1("Sample_InstanceProviderClass");
 54 chip        1.23     instance1.setPath(CIMObjectPath("Sample_InstanceProviderClass.Identifier=1"));
 55 mike        1.2  
 56                  	instance1.addProperty(CIMProperty("Identifier", Uint8(1)));   // key
 57                  	instance1.addProperty(CIMProperty("Message", String("Hello World")));
 58                  
 59 kumpf       1.11 	_instances.append(instance1);
 60 mike        1.2  
 61 chip        1.6  	CIMInstance instance2("Sample_InstanceProviderClass");
 62 chip        1.23 	instance2.setPath(CIMObjectPath("Sample_InstanceProviderClass.Identifier=2"));
 63 mike        1.2  
 64                  	instance2.addProperty(CIMProperty("Identifier", Uint8(2)));   // key
 65 chip        1.6  	instance2.addProperty(CIMProperty("Message", String("Yo Planet")));
 66 mike        1.2  
 67 kumpf       1.11 	_instances.append(instance2);
 68 mike        1.2  
 69 chip        1.6  	CIMInstance instance3("Sample_InstanceProviderClass");
 70 chip        1.23 	instance3.setPath(CIMObjectPath("Sample_InstanceProviderClass.Identifier=3"));
 71 mike        1.2  
 72                  	instance3.addProperty(CIMProperty("Identifier", Uint8(3)));   // key
 73 chip        1.6  	instance3.addProperty(CIMProperty("Message", String("Hey Earth")));
 74 mike        1.2  
 75 kumpf       1.11 	_instances.append(instance3);
 76 mike        1.2  }
 77                  
 78                  void InstanceProvider::terminate(void)
 79                  {
 80 kumpf       1.19 	delete this;
 81 mike        1.2  }
 82                  
 83                  void InstanceProvider::getInstance(
 84                  	const OperationContext & context,
 85 kumpf       1.10 	const CIMObjectPath & instanceReference,
 86 kumpf       1.17 	const Boolean includeQualifiers,
 87                  	const Boolean includeClassOrigin,
 88 kumpf       1.9  	const CIMPropertyList & propertyList,
 89 kumpf       1.16 	InstanceResponseHandler & handler)
 90 mike        1.2  {
 91 chip        1.6  	// convert a potential fully qualified reference into a local reference
 92                  	// (class name and keys only).
 93 chip        1.24 	CIMObjectPath localReference =
 94                          CIMObjectPath(
 95                              String(),
 96                              CIMNamespaceName(),
 97                              instanceReference.getClassName(),
 98                              instanceReference.getKeyBindings());
 99 chip        1.6  
100 mike        1.2  	// begin processing the request
101                  	handler.processing();
102                  
103                  	// instance index corresponds to reference index
104 chip        1.3  	for(Uint32 i = 0, n = _instances.size(); i < n; i++)
105 mike        1.2  	{
106 chip        1.23 		if(localReference == _instances[i].getPath())
107 mike        1.2  		{
108                  			// deliver requested instance
109 kumpf       1.11 			handler.deliver(_instances[i]);
110 mike        1.2  
111                  			break;
112                  		}
113                  	}
114                  
115                  	// complete processing the request
116                  	handler.complete();
117                  }
118                  
119                  void InstanceProvider::enumerateInstances(
120                  	const OperationContext & context,
121 kumpf       1.10 	const CIMObjectPath & classReference,
122 kumpf       1.17 	const Boolean includeQualifiers,
123                  	const Boolean includeClassOrigin,
124 kumpf       1.9  	const CIMPropertyList & propertyList,
125 kumpf       1.16 	InstanceResponseHandler & handler)
126 mike        1.2  {
127                  	// begin processing the request
128                  	handler.processing();
129                  
130 chip        1.3  	for(Uint32 i = 0, n = _instances.size(); i < n; i++)
131 mike        1.2  	{
132 chip        1.6  		// deliver instance
133 kumpf       1.11 		handler.deliver(_instances[i]);
134 mike        1.2  	}
135                  
136                  	// complete processing the request
137                  	handler.complete();
138                  }
139                  
140                  void InstanceProvider::enumerateInstanceNames(
141                  	const OperationContext & context,
142 kumpf       1.10 	const CIMObjectPath & classReference,
143 kumpf       1.16 	ObjectPathResponseHandler & handler)
144 mike        1.2  {
145                  	// begin processing the request
146                  	handler.processing();
147                  
148 chip        1.3  	for(Uint32 i = 0, n = _instances.size(); i < n; i++)
149 mike        1.2  	{
150                  		// deliver reference
151 chip        1.23 		handler.deliver(_instances[i].getPath());
152 mike        1.2  	}
153                  
154                  	// complete processing the request
155                  	handler.complete();
156                  }
157                  
158 jim.wunderlich 1.27 
159                     // ***********************************************************************
160                     //
161                     // The modify, create and delete Instance methods are not supported
162                     // because this Sample Provider only uses the Pegasus public interface
163                     // which does not provide any locks. Locks are required to support the
164                     // maintenance of a dynamic data store in a multi-threaded environment.
165                     //
166                     // ***********************************************************************
167 mike           1.2  void InstanceProvider::modifyInstance(
168                     	const OperationContext & context,
169 kumpf          1.10 	const CIMObjectPath & instanceReference,
170 mike           1.2  	const CIMInstance & instanceObject,
171 kumpf          1.17 	const Boolean includeQualifiers,
172 kumpf          1.9  	const CIMPropertyList & propertyList,
173 kumpf          1.16 	ResponseHandler & handler)
174 mike           1.2  {
175 jim.wunderlich 1.27   // deliver exception to the ProviderManager, which in turn will return the 
176                       // error message to the requestor
177                       
178                       throw CIMNotSupportedException("InstanceProvider::modifyInstance()");
179 mike           1.2  }
180                     
181 jim.wunderlich 1.27 // ***********************************************************************
182                     //
183                     // The modify, create and delete Instance methods are not supported
184                     // because this Sample Provider only uses the Pegasus public interface
185                     // which does not provide any locks. Locks are required to support the
186                     // maintenance of a dynamic data store in a multi-threaded environment.
187                     //
188                     // ***********************************************************************
189 mike           1.2  void InstanceProvider::createInstance(
190 kumpf          1.21     const OperationContext & context,
191                         const CIMObjectPath & instanceReference,
192                         const CIMInstance & instanceObject,
193                         ObjectPathResponseHandler & handler)
194                     {
195 jim.wunderlich 1.27   // deliver exception to the ProviderManager, which in turn will return the 
196                       // error message to the requestor
197                       
198                       throw CIMNotSupportedException("InstanceProvider::createInstance()");
199                     }
200 chip           1.23 
201 mike           1.2  
202 jim.wunderlich 1.27 // ***********************************************************************
203                     //
204                     // The modify, create and delete Instance methods are not supported
205                     // because this Sample Provider only uses the Pegasus public interface
206                     // which does not provide any locks. Locks are required to support the
207                     // maintenance of a dynamic data store in a multi-threaded environment.
208                     //
209                     // ***********************************************************************
210 mike           1.2  void InstanceProvider::deleteInstance(
211                     	const OperationContext & context,
212 kumpf          1.10 	const CIMObjectPath & instanceReference,
213 kumpf          1.16 	ResponseHandler & handler)
214 mike           1.2  {
215 jim.wunderlich 1.27   // deliver exception to the ProviderManager, which in turn will return the 
216                       // error message to the requestor
217                       
218                       throw CIMNotSupportedException("InstanceProvider::deleteInstance()");
219 mike           1.2  }
220                     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2