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

  1 martin 1.10 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.11 //
  3 martin 1.10 // 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.11 //
 10 martin 1.10 // 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.11 //
 17 martin 1.10 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.11 //
 20 martin 1.10 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.11 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.10 // 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.11 //
 28 martin 1.10 //////////////////////////////////////////////////////////////////////////
 29 mike   1.2  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #ifndef Pegasus_WQLSimplePropertySource_h
 33             #define Pegasus_WQLSimplePropertySource_h
 34             
 35             #include <Pegasus/Common/Config.h>
 36             #include <Pegasus/WQL/WQLPropertySource.h>
 37             #include <Pegasus/Common/HashTable.h>
 38             
 39             PEGASUS_NAMESPACE_BEGIN
 40             
 41             /** This class provides a simple property source implementation mainly for
 42                 testing purposes only.
 43             
 44                 It maintains a hash table which maps property names to values (represented
 45                 using WQLOperand objects).
 46             
 47                 This class implements getValue() by simply looking up the property name
 48                 in the map and fetching the corresponding value.
 49             
 50 kumpf  1.12     The addValue() method is used to add property-name/value pairs to the
 51 mike   1.2      internal map.
 52             
 53                 Since this class is intended for testing purposes, all of the methods
 54                 are inline to avoid making the library any larger.
 55             */
 56             class WQLSimplePropertySource : public WQLPropertySource
 57             {
 58             public:
 59             
 60                 /** Default constructor.
 61                 */
 62                 WQLSimplePropertySource()
 63                 {
 64                 }
 65             
 66                 /** Virtual destructor.
 67                 */
 68                 virtual ~WQLSimplePropertySource()
 69                 {
 70                 }
 71             
 72 mike   1.2      /** Get the value for the property with the given name. Simply looks up
 73 karl   1.9          the property name in the internal map to fetch the value.
 74 kumpf  1.12 
 75 karl   1.9          @param propertyName name of property to be retrieved.
 76                     @param value value of property.
 77                     @return true is such a property exists and false otherwise.
 78 mike   1.2      */
 79                 virtual Boolean getValue(
 80 kumpf  1.12     const CIMName& propertyName,
 81 karl   1.9      WQLOperand& value) const
 82 mike   1.2      {
 83 karl   1.9          return _map.lookup(propertyName.getString(), value);
 84 mike   1.2      }
 85             
 86                 /** Add the given propert-name/value pair to the internal map.
 87 kumpf  1.12 
 88 karl   1.9          @param propertyName name of property.
 89                     @param value value of property.
 90                     @return true if no such property already existed and false otherwise.
 91 mike   1.2      */
 92                 Boolean addValue(
 93 kumpf  1.12     const CIMName& propertyName,
 94 karl   1.9      const WQLOperand& value)
 95 mike   1.2      {
 96 karl   1.9          return _map.insert(propertyName.getString(), value);
 97 mike   1.2      }
 98             
 99             private:
100             
101                 typedef HashTable<
102 karl   1.9      String, WQLOperand, EqualFunc<String>, HashFunc<String> > Map;
103 mike   1.2  
104                 Map _map;
105             };
106             
107             PEGASUS_NAMESPACE_END
108             
109             #endif /* Pegasus_WQLSimplePropertySource_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2