(file) Return to WQLSimplePropertySource.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / WQL

  1 karl  1.6 //%2004////////////////////////////////////////////////////////////////////////
  2 mike  1.2 //
  3 karl  1.6 // 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.5 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.6 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8           // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 mike  1.2 //
 10           // Permission is hereby granted, free of charge, to any person obtaining a copy
 11 kumpf 1.3 // of this software and associated documentation files (the "Software"), to
 12           // deal in the Software without restriction, including without limitation the
 13           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 14 mike  1.2 // sell copies of the Software, and to permit persons to whom the Software is
 15           // furnished to do so, subject to the following conditions:
 16           // 
 17 kumpf 1.3 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 18 mike  1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 19           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 20 kumpf 1.3 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 21           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 22           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 23 mike  1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 24           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 25           //
 26           //==============================================================================
 27           //
 28           // Author: Mike Brasher (mbrasher@bmc.com)
 29           //
 30 kumpf 1.4 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 31           //                (carolann_graves@hp.com)
 32 mike  1.2 //
 33           //%/////////////////////////////////////////////////////////////////////////////
 34           
 35           #ifndef Pegasus_WQLSimplePropertySource_h
 36           #define Pegasus_WQLSimplePropertySource_h
 37           
 38           #include <Pegasus/Common/Config.h>
 39           #include <Pegasus/WQL/WQLPropertySource.h>
 40           #include <Pegasus/Common/HashTable.h>
 41           
 42           PEGASUS_NAMESPACE_BEGIN
 43           
 44           /** This class provides a simple property source implementation mainly for
 45               testing purposes only.
 46           
 47               It maintains a hash table which maps property names to values (represented
 48               using WQLOperand objects).
 49           
 50               This class implements getValue() by simply looking up the property name
 51               in the map and fetching the corresponding value.
 52           
 53 mike  1.2     The addValue() method is used to add property-name/value pairs to the 
 54               internal map.
 55           
 56               Since this class is intended for testing purposes, all of the methods
 57               are inline to avoid making the library any larger.
 58           */
 59           class WQLSimplePropertySource : public WQLPropertySource
 60           {
 61           public:
 62           
 63               /** Default constructor.
 64               */
 65               WQLSimplePropertySource()
 66               {
 67               }
 68           
 69               /** Virtual destructor.
 70               */
 71               virtual ~WQLSimplePropertySource()
 72               {
 73               }
 74 mike  1.2 
 75               /** Get the value for the property with the given name. Simply looks up
 76           	the property name in the internal map to fetch the value.
 77           
 78           	@param propertyName name of property to be retrieved.
 79           	@param value value of property.
 80           	@return true is such a property exists and false otherwise.
 81               */
 82               virtual Boolean getValue(
 83 kumpf 1.4 	const CIMName& propertyName, 
 84 mike  1.2 	WQLOperand& value) const
 85               {
 86 kumpf 1.4 	return _map.lookup(propertyName.getString(), value);
 87 mike  1.2     }
 88           
 89               /** Add the given propert-name/value pair to the internal map.
 90           	
 91           	@param propertyName name of property.
 92           	@param value value of property.
 93           	@return true if no such property already existed and false otherwise.
 94               */
 95               Boolean addValue(
 96 kumpf 1.4 	const CIMName& propertyName, 
 97 mike  1.2 	const WQLOperand& value)
 98               {
 99 kumpf 1.4 	return _map.insert(propertyName.getString(), value);
100 mike  1.2     }
101           
102           private:
103           
104               typedef HashTable<
105           	String, WQLOperand, EqualFunc<String>, HashFunc<String> > Map;
106           
107               Map _map;
108           };
109           
110           PEGASUS_NAMESPACE_END
111           
112           #endif /* Pegasus_WQLSimplePropertySource_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2