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

  1 karl  1.8 //%2006////////////////////////////////////////////////////////////////////////
  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 karl  1.7 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10           // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.8 // 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 kumpf 1.3 // 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 mike  1.2 // 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           // 
 21 kumpf 1.3 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 mike  1.2 // 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 kumpf 1.3 // 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 mike  1.2 // 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           //%/////////////////////////////////////////////////////////////////////////////
 33           
 34           #ifndef Pegasus_WQLSimplePropertySource_h
 35           #define Pegasus_WQLSimplePropertySource_h
 36           
 37           #include <Pegasus/Common/Config.h>
 38           #include <Pegasus/WQL/WQLPropertySource.h>
 39           #include <Pegasus/Common/HashTable.h>
 40           
 41           PEGASUS_NAMESPACE_BEGIN
 42           
 43           /** This class provides a simple property source implementation mainly for
 44               testing purposes only.
 45           
 46               It maintains a hash table which maps property names to values (represented
 47               using WQLOperand objects).
 48 mike  1.2 
 49               This class implements getValue() by simply looking up the property name
 50               in the map and fetching the corresponding value.
 51           
 52               The addValue() method is used to add property-name/value pairs to the 
 53               internal map.
 54           
 55               Since this class is intended for testing purposes, all of the methods
 56               are inline to avoid making the library any larger.
 57           */
 58           class WQLSimplePropertySource : public WQLPropertySource
 59           {
 60           public:
 61           
 62               /** Default constructor.
 63               */
 64               WQLSimplePropertySource()
 65               {
 66               }
 67           
 68               /** Virtual destructor.
 69 mike  1.2     */
 70               virtual ~WQLSimplePropertySource()
 71               {
 72               }
 73           
 74               /** Get the value for the property with the given name. Simply looks up
 75 karl  1.9         the property name in the internal map to fetch the value.
 76               
 77                   @param propertyName name of property to be retrieved.
 78                   @param value value of property.
 79                   @return true is such a property exists and false otherwise.
 80 mike  1.2     */
 81               virtual Boolean getValue(
 82 karl  1.9     const CIMName& propertyName, 
 83               WQLOperand& value) const
 84 mike  1.2     {
 85 karl  1.9         return _map.lookup(propertyName.getString(), value);
 86 mike  1.2     }
 87           
 88               /** Add the given propert-name/value pair to the internal map.
 89 karl  1.9     
 90                   @param propertyName name of property.
 91                   @param value value of property.
 92                   @return true if no such property already existed and false otherwise.
 93 mike  1.2     */
 94               Boolean addValue(
 95 karl  1.9     const CIMName& propertyName, 
 96               const WQLOperand& value)
 97 mike  1.2     {
 98 karl  1.9         return _map.insert(propertyName.getString(), value);
 99 mike  1.2     }
100           
101           private:
102           
103               typedef HashTable<
104 karl  1.9     String, WQLOperand, EqualFunc<String>, HashFunc<String> > Map;
105 mike  1.2 
106               Map _map;
107           };
108           
109           PEGASUS_NAMESPACE_END
110           
111           #endif /* Pegasus_WQLSimplePropertySource_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2